Release #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| verify: | |
| name: Verify Release Metadata | |
| runs-on: ubuntu-latest | |
| outputs: | |
| release_tag: ${{ steps.release.outputs.release_tag }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Cargo Artifacts | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Resolve Release Tag | |
| id: release | |
| run: | | |
| if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then | |
| version="$(sed -nE 's/^version = "([^"]+)"/\1/p' Cargo.toml | head -n1)" | |
| echo "release_tag=v${version}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "release_tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Check Release Metadata | |
| run: ./scripts/check-release.sh "${{ steps.release.outputs.release_tag }}" | |
| - name: Check Workspace | |
| run: cargo check --workspace --locked | |
| - name: List hubuum_client_derive Package Contents | |
| run: cargo package --list -p hubuum_client_derive | |
| - name: List hubuum_client Package Contents | |
| run: cargo package --list -p hubuum_client | |
| publish-hubuum-client-derive: | |
| name: Publish hubuum_client_derive | |
| runs-on: ubuntu-latest | |
| needs: verify | |
| if: github.event_name == 'push' | |
| environment: release | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Cargo Artifacts | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Authenticate to crates.io | |
| id: auth | |
| uses: rust-lang/crates-io-auth-action@v1 | |
| - name: Check whether hubuum_client_derive is already published | |
| id: published | |
| run: | | |
| version="$(sed -nE 's/^version = "([^"]+)"/\1/p' hubuum_client_derive/Cargo.toml | head -n1)" | |
| tmpdir="$(mktemp -d)" | |
| mkdir -p "${tmpdir}/src" | |
| printf "" > "${tmpdir}/src/lib.rs" | |
| printf '%s\n' \ | |
| '[package]' \ | |
| 'name = "hubuum-client-release-probe"' \ | |
| 'version = "0.0.0"' \ | |
| 'edition = "2024"' \ | |
| '' \ | |
| '[dependencies]' \ | |
| "hubuum_client_derive = \"=${version}\"" \ | |
| > "${tmpdir}/Cargo.toml" | |
| if cargo metadata --manifest-path "${tmpdir}/Cargo.toml" --format-version 1 >/dev/null 2>&1; then | |
| echo "published=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "published=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Publish hubuum_client_derive | |
| if: steps.published.outputs.published != 'true' | |
| run: | | |
| set +e | |
| output="$(cargo publish -p hubuum_client_derive --locked 2>&1)" | |
| status=$? | |
| set -e | |
| printf '%s\n' "$output" | |
| if [ "$status" -eq 0 ]; then | |
| exit 0 | |
| fi | |
| if printf '%s\n' "$output" | grep -Fq "already exists on crates.io index"; then | |
| exit 0 | |
| fi | |
| exit "$status" | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} | |
| publish-hubuum-client: | |
| name: Publish hubuum_client | |
| runs-on: ubuntu-latest | |
| needs: publish-hubuum-client-derive | |
| if: github.event_name == 'push' | |
| environment: release | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Cargo Artifacts | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Authenticate to crates.io | |
| id: auth | |
| uses: rust-lang/crates-io-auth-action@v1 | |
| - name: Wait for hubuum_client_derive to appear in the index | |
| run: | | |
| version="$(sed -nE 's/^version = "([^"]+)"/\1/p' hubuum_client_derive/Cargo.toml | head -n1)" | |
| for attempt in $(seq 1 60); do | |
| tmpdir="$(mktemp -d)" | |
| mkdir -p "${tmpdir}/src" | |
| printf "" > "${tmpdir}/src/lib.rs" | |
| printf '%s\n' \ | |
| '[package]' \ | |
| 'name = "hubuum-client-release-probe"' \ | |
| 'version = "0.0.0"' \ | |
| 'edition = "2024"' \ | |
| '' \ | |
| '[dependencies]' \ | |
| "hubuum_client_derive = \"=${version}\"" \ | |
| > "${tmpdir}/Cargo.toml" | |
| if cargo metadata --manifest-path "${tmpdir}/Cargo.toml" --format-version 1 >/tmp/hubuum-client-derive-metadata.log 2>&1; then | |
| exit 0 | |
| fi | |
| cat /tmp/hubuum-client-derive-metadata.log | |
| echo "hubuum_client_derive ${version} is not visible yet (attempt ${attempt}/60)" | |
| sleep 10 | |
| done | |
| echo "Timed out waiting for hubuum_client_derive ${version} to reach crates.io" >&2 | |
| exit 1 | |
| - name: Check whether hubuum_client is already published | |
| id: published | |
| run: | | |
| version="$(sed -nE 's/^version = "([^"]+)"/\1/p' Cargo.toml | head -n1)" | |
| tmpdir="$(mktemp -d)" | |
| mkdir -p "${tmpdir}/src" | |
| printf "" > "${tmpdir}/src/lib.rs" | |
| printf '%s\n' \ | |
| '[package]' \ | |
| 'name = "hubuum-client-release-probe"' \ | |
| 'version = "0.0.0"' \ | |
| 'edition = "2024"' \ | |
| '' \ | |
| '[dependencies]' \ | |
| "hubuum_client = \"=${version}\"" \ | |
| > "${tmpdir}/Cargo.toml" | |
| if cargo metadata --manifest-path "${tmpdir}/Cargo.toml" --format-version 1 >/dev/null 2>&1; then | |
| echo "published=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "published=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Publish hubuum_client | |
| if: steps.published.outputs.published != 'true' | |
| run: | | |
| set +e | |
| output="$(cargo publish -p hubuum_client --locked 2>&1)" | |
| status=$? | |
| set -e | |
| printf '%s\n' "$output" | |
| if [ "$status" -eq 0 ]; then | |
| exit 0 | |
| fi | |
| if printf '%s\n' "$output" | grep -Fq "already exists on crates.io index"; then | |
| exit 0 | |
| fi | |
| exit "$status" | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} |