diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3e58d447..14ac2efe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,6 +6,7 @@ # * checks for a Git Tag that looks like a release # * builds artifacts with cargo-dist (archives, installers, hashes) # * uploads those artifacts to temporary workflow zip +# * on success, uploads the artifacts to Axo Releases and makes an Announcement # * on success, uploads the artifacts to a Github Release # # Note that the Github Release will be created with a generated @@ -54,6 +55,7 @@ jobs: publishing: ${{ !github.event.pull_request }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + AXO_RELEASES_TOKEN: ${{ secrets.AXO_RELEASES_TOKEN }} steps: - uses: actions/checkout@v4 with: @@ -62,7 +64,7 @@ jobs: # we specify bash to get pipefail; it guards against the `curl` command # failing. otherwise `sh` won't catch that `curl` returned non-0 shell: bash - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.11.0-prerelease.1/cargo-dist-installer.sh | sh" + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.11.0-prerelease.2/cargo-dist-installer.sh | sh" # sure would be cool if github gave us proper conditionals... # so here's a doubly-nested ternary-via-truthiness to try to provide the best possible # functionality based on whether this is a pull_request, and whether it's from a fork. @@ -70,7 +72,7 @@ jobs: # but also really annoying to build CI around when it needs secrets to work right.) - id: plan run: | - cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json + cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || (env.AXO_RELEASES_TOKEN && 'host --steps=check') || 'plan' }} --output-format=json > plan-dist-manifest.json echo "cargo dist ran successfully" cat plan-dist-manifest.json echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT" @@ -162,7 +164,7 @@ jobs: submodules: recursive - name: Install cargo-dist shell: bash - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.11.0-prerelease.1/cargo-dist-installer.sh | sh" + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.11.0-prerelease.2/cargo-dist-installer.sh | sh" # Get all the local artifacts for the global tasks to use (for e.g. checksums) - name: Fetch local artifacts uses: actions/download-artifact@v4 @@ -189,7 +191,16 @@ jobs: path: | ${{ steps.cargo-dist.outputs.paths }} ${{ env.BUILD_MANIFEST_NAME }} - # Determines if we should publish/announce + # Uploads the artifacts to Axo Releases and tentatively creates Releases for them. + # This makes perma URLs like /v1.0.0/ live for subsequent publish steps to use, but + # leaves them "disconnected" from the release history (for the purposes of + # "list the releases" or "give me the latest releases"). + # + # If all the subsequent "publish" steps succeed, the "announce" job will "connect" + # the releases and concepts like "latest" will be updated. Otherwise you're hopefully + # in a decent position to roll back the release without anyone noticing it! + # This is imperfect with things like "publish to crates.io" being irreversible, but + # at worst you're in a better position to yank the version with minimum disruption. host: needs: - plan @@ -199,6 +210,7 @@ jobs: if: ${{ always() && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + AXO_RELEASES_TOKEN: ${{ secrets.AXO_RELEASES_TOKEN }} runs-on: "ubuntu-20.04" outputs: val: ${{ steps.host.outputs.manifest }} @@ -207,7 +219,7 @@ jobs: with: submodules: recursive - name: Install cargo-dist - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.11.0-prerelease.1/cargo-dist-installer.sh | sh" + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.11.0-prerelease.2/cargo-dist-installer.sh | sh" # Fetch artifacts from scratch-storage - name: Fetch artifacts uses: actions/download-artifact@v4 @@ -215,6 +227,7 @@ jobs: pattern: artifacts-* path: target/distrib/ merge-multiple: true + # Upload files to Axo Releases and create the Releases # This is a harmless no-op for Github Releases, hosting for that happens in "announce" - id: host shell: bash @@ -267,6 +280,7 @@ jobs: done git push + # Create an Announcement for all the Axo Releases, updating the "latest" release # Create a Github Release while uploading all files to it announce: needs: @@ -280,10 +294,22 @@ jobs: runs-on: "ubuntu-20.04" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + AXO_RELEASES_TOKEN: ${{ secrets.AXO_RELEASES_TOKEN }} steps: - uses: actions/checkout@v4 with: submodules: recursive + - name: Install cargo-dist + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.11.0-prerelease.2/cargo-dist-installer.sh | sh" + - name: Fetch Axo Artifacts + uses: actions/download-artifact@v4 + with: + pattern: artifacts-* + path: target/distrib/ + merge-multiple: true + - name: Announce Axo Releases + run: | + cargo dist host --steps=announce ${{ needs.plan.outputs.tag-flag }} - name: "Download Github Artifacts" uses: actions/download-artifact@v4 with: diff --git a/Cargo.toml b/Cargo.toml index d5ac2be2..c51399cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,7 +87,7 @@ lto = "thin" # Config for 'cargo dist' [workspace.metadata.dist] # The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax) -cargo-dist-version = "0.11.0-prerelease.1" +cargo-dist-version = "0.11.0-prerelease.2" # CI backends to support ci = ["github"] # The installers to generate for each app @@ -108,6 +108,8 @@ npm-scope = "@axodotdev" features = ["build-with-tailwind"] # Publish jobs to run in CI pr-run-mode = "plan" +# Where to host releases +hosting = ["axodotdev", "github"] [[workspace.metadata.dist.extra-artifacts]] artifacts = ["oranda-config-schema.json"]