| # Licensed to the Apache Software Foundation (ASF) under one |
| # or more contributor license agreements. See the NOTICE file |
| # distributed with this work for additional information |
| # regarding copyright ownership. The ASF licenses this file |
| # to you under the Apache License, Version 2.0 (the |
| # "License"); you may not use this file except in compliance |
| # with the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, |
| # software distributed under the License is distributed on an |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| # KIND, either express or implied. See the License for the |
| # specific language governing permissions and limitations |
| # under the License. |
| |
| name: Release |
| |
| on: |
| push: |
| tags: [ "v*.*.*" ] |
| workflow_dispatch: |
| |
| permissions: |
| contents: read |
| |
| env: |
| CARGO_INCREMENTAL: "0" |
| CARGO_TERM_COLOR: always |
| RUSTUP_TOOLCHAIN: stable |
| |
| concurrency: |
| group: release-${{ github.ref }} |
| cancel-in-progress: false |
| |
| jobs: |
| check: |
| name: Check package |
| runs-on: ubuntu-24.04 |
| timeout-minutes: 30 |
| outputs: |
| version: ${{ steps.package.outputs.version }} |
| steps: |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| with: |
| fetch-depth: 0 |
| - name: Install stable toolchain |
| run: >- |
| rustup toolchain install stable |
| --profile minimal |
| --no-self-update |
| - id: package |
| name: Read package version |
| shell: bash |
| run: | |
| version="$(cargo metadata --no-deps --format-version 1 | jq --raw-output '.packages[] | select(.name == "asyncband") | .version')" |
| if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| echo "The asyncband package version must be a stable X.Y.Z version, got: ${version}" >&2 |
| exit 1 |
| fi |
| echo "version=${version}" >> "${GITHUB_OUTPUT}" |
| - name: Check tag |
| if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| shell: bash |
| env: |
| PACKAGE_VERSION: ${{ steps.package.outputs.version }} |
| run: | |
| case "${GITHUB_REF_NAME}" in |
| "v${PACKAGE_VERSION}") |
| ;; |
| "v${PACKAGE_VERSION}-rc."*) |
| rc="${GITHUB_REF_NAME#v${PACKAGE_VERSION}-rc.}" |
| if [[ ! "${rc}" =~ ^[1-9][0-9]*$ ]]; then |
| echo "Invalid release candidate tag: ${GITHUB_REF_NAME}" >&2 |
| exit 1 |
| fi |
| ;; |
| *) |
| echo "Tag ${GITHUB_REF_NAME} does not match package version ${PACKAGE_VERSION}." >&2 |
| exit 1 |
| ;; |
| esac |
| git fetch --no-tags origin main:refs/remotes/origin/main |
| tag_commit="$(git rev-parse "${GITHUB_REF_NAME}^{commit}")" |
| if ! git merge-base --is-ancestor "${tag_commit}" origin/main; then |
| echo "Release tag ${GITHUB_REF_NAME} does not point to a commit on main." >&2 |
| exit 1 |
| fi |
| - name: Check crates.io package |
| run: cargo publish --package asyncband --locked --dry-run |
| |
| publish: |
| name: Publish to crates.io |
| # Only the final tag approved through the ASF release vote may publish to crates.io. |
| if: ${{ github.ref == format('refs/tags/v{0}', needs.check.outputs.version) }} |
| needs: check |
| runs-on: ubuntu-24.04 |
| timeout-minutes: 30 |
| environment: release |
| permissions: |
| contents: read |
| id-token: write |
| steps: |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| - name: Install stable toolchain |
| run: >- |
| rustup toolchain install stable |
| --profile minimal |
| --no-self-update |
| - id: auth |
| name: Authenticate with crates.io |
| uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 # v1.0.5 |
| - name: Publish asyncband |
| run: cargo publish --package asyncband --locked |
| env: |
| CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} |