Skip to content

Commit

Permalink
chore: use axo releases
Browse files Browse the repository at this point in the history
  • Loading branch information
Gankra committed Feb 23, 2024
1 parent c599e8f commit 37fdd5b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
36 changes: 31 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -62,15 +64,15 @@ 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.
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
# 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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 }}
Expand All @@ -207,14 +219,15 @@ 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
with:
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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
Expand Down

0 comments on commit 37fdd5b

Please sign in to comment.