name: GitHub Release
permissions:
contents: write
on:
workflow_run:
workflows:
- crates.io Publish
types:
- completed
jobs:
github-release:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: ${{ github.event.workflow_run.head_sha }}
fetch-depth: 0
- name: Resolve release tag
run: |
git fetch origin 'refs/tags/v*:refs/tags/v*'
published_sha="${{ github.event.workflow_run.head_sha }}"
tags="$(git tag --points-at "$published_sha" --list 'v*')"
count="$(printf '%s\n' "$tags" | sed '/^$/d' | wc -l)"
if [ "$count" -ne 1 ]; then
echo "Expected exactly one v* tag pointing at $published_sha"
printf '%s\n' "$tags"
exit 1
fi
tag="$tags"
echo "RELEASE_TAG=$tag" >> "$GITHUB_ENV"
- name: Install stable Rust
uses: dtolnay/rust-toolchain@stable
- name: Verify tag matches crate version
run: |
version="$(cargo metadata --no-deps --format-version 1 \
| jq -r '.packages[] | select(.name == "ciranda") | .version')"
if [ "$RELEASE_TAG" != "v$version" ]; then
echo "Tag $RELEASE_TAG does not match Cargo.toml version $version"
exit 1
fi
- name: Cache cargo artifacts
uses: Swatinem/rust-cache@v2
- name: Build release binary
run: cargo build --locked --release
- name: Package release asset
run: |
target="$(rustc -vV | sed -n 's/^host: //p')"
asset="ciranda-$RELEASE_TAG-$target.tar.gz"
mkdir -p dist/package
cp target/release/ciranda dist/package/ciranda
cp README.md LICENSE-APACHE LICENSE-MIT dist/package/
tar -czf "dist/$asset" -C dist/package .
cd dist
sha256sum "$asset" > "$asset.sha256"
- name: Create GitHub Release
run: |
asset="$(find dist -maxdepth 1 -name 'ciranda-*.tar.gz' -print)"
gh release create "$RELEASE_TAG" \
"$asset" \
"$asset.sha256" \
--verify-tag \
--title "$RELEASE_TAG" \
--generate-notes
env:
GH_TOKEN: ${{ github.token }}