name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
release:
name: Release ${{ github.ref_name }}
if: github.repository == 'apache/casbin-sqlx-adapter'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.meta.outputs.version }}
is_rc: ${{ steps.meta.outputs.is_rc }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Resolve version from tag
id: meta
run: .github/scripts/release.sh meta "$GITHUB_REF_NAME"
- name: Build source tarball for the vote
if: steps.meta.outputs.is_rc == 'true'
run: .github/scripts/release.sh archive "${{ steps.meta.outputs.version }}" "$RUNNER_TEMP/dist"
- name: Fetch and verify the voted tarball from the ASF release area
if: steps.meta.outputs.is_rc == 'false'
run: .github/scripts/release.sh verify "${{ steps.meta.outputs.version }}" "$RUNNER_TEMP/dist"
- name: Write release notes
env:
VERSION: ${{ steps.meta.outputs.version }}
BASENAME: ${{ steps.meta.outputs.basename }}
IS_RC: ${{ steps.meta.outputs.is_rc }}
run: |
set -euo pipefail
NOTES="$RUNNER_TEMP/notes.md"
if [ "$IS_RC" = true ]; then
cat >"$NOTES" <<EOF
Release candidate for Apache Casbin SQLx Adapter (Incubating) $VERSION. **This is not an Apache release**; it is the source tarball for the Apache vote.
Release manager: download \`$BASENAME.tar.gz\` and its \`.sha512\`, sign the tarball with your key from the Casbin KEYS file, stage all three files under \`dist/dev/incubator/casbin/\`, and start the vote. See RELEASING.md.
EOF
else
cat >"$NOTES" <<EOF
Apache Casbin SQLx Adapter (Incubating) $VERSION (crate: casbin-sqlx-adapter).
The attached files are the voted source release, byte for byte as published at https://downloads.apache.org/incubator/casbin/sqlx-adapter-$VERSION-incubating/ (verify with https://www.apache.org/info/verification.html). The crate on crates.io is built from these sources.
EOF
fi
printf '\n---\n\n' >>"$NOTES"
cat DISCLAIMER >>"$NOTES"
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
IS_RC: ${{ steps.meta.outputs.is_rc }}
run: |
set -euo pipefail
FLAGS=(--verify-tag --title "$TAG" --notes-file "$RUNNER_TEMP/notes.md")
if [ "$IS_RC" = true ]; then
FLAGS+=(--prerelease --latest=false)
fi
# gh refuses to create a release that already exists, so a re-run can
# never silently replace published assets.
gh release create "$TAG" "$RUNNER_TEMP"/dist/* "${FLAGS[@]}"
publish:
name: Publish to crates.io
needs: release
if: needs.release.outputs.is_rc == 'false'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Verify the voted tarball matches this tag
run: .github/scripts/release.sh verify "${{ needs.release.outputs.version }}" "$RUNNER_TEMP/dist"
- name: Write the version into Cargo.toml
run: .github/scripts/release.sh set-version "${{ needs.release.outputs.version }}"
- name: Install Rust toolchain
run: rustup update stable --no-self-update && rustup default stable
- name: Publish crate
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --allow-dirty