Create a Release #149
Workflow file for this run
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
| # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
| name: Create a Release | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [main] | |
| tags: | |
| - "v*" | |
| permissions: | |
| id-token: write # needed for trusted publishing (OIDC) to npm and crates.io | |
| contents: write # needed to create a release | |
| jobs: | |
| build: | |
| uses: ./.github/workflows/dep_build.yml | |
| secrets: inherit | |
| with: | |
| environment: release | |
| benchmarks: | |
| uses: ./.github/workflows/dep_benchmarks.yml | |
| secrets: inherit | |
| with: | |
| download-benchmarks: true | |
| upload-benchmarks: true | |
| environment: release | |
| set-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.set-version.outputs.version }} | |
| dry_run: ${{ steps.set-version.outputs.dry_run }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Set version | |
| id: set-version | |
| shell: bash | |
| run: | | |
| git fetch --tags || true | |
| # Extract the version number from the tag name, which is expected to be in the format 'vX.Y.Z' | |
| # if not, default to '0.0.0' to avoid errors in subsequent steps | |
| if [[ "${GITHUB_REF}" =~ refs/tags/v([0-9]+\.[0-9]+\.[0-9]+) ]]; then | |
| version="${BASH_REMATCH[1]}" | |
| dry_run=false | |
| else | |
| version="0.0.0" | |
| dry_run=true | |
| fi | |
| echo "Setting version to 'v$version'" | |
| echo "version=$version" >> $GITHUB_OUTPUT | |
| echo "dry_run=$dry_run" >> $GITHUB_OUTPUT | |
| create-release-branch: | |
| needs: [build, benchmarks, set-version] | |
| runs-on: ubuntu-latest | |
| if: ${{ needs.set-version.outputs.dry_run == 'false' }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Create Release Branch | |
| shell: bash | |
| run: | | |
| git checkout -b release/v${{ needs.set-version.outputs.version }} | |
| git push --set-upstream origin release/v${{ needs.set-version.outputs.version }} | |
| publish-gh-release: | |
| needs: [build, benchmarks, set-version] | |
| uses: ./.github/workflows/gh-publish.yml | |
| with: | |
| version: ${{ needs.set-version.outputs.version }} | |
| dry_run: ${{ needs.set-version.outputs.dry_run != 'false' }} | |
| publish-npm-packages: | |
| needs: [build, benchmarks, set-version] | |
| uses: ./.github/workflows/npm-publish.yml | |
| with: | |
| version: ${{ needs.set-version.outputs.version }} | |
| dry_run: ${{ needs.set-version.outputs.dry_run != 'false' }} | |
| publish-cargo-crates: | |
| needs: [build, benchmarks, set-version] | |
| uses: ./.github/workflows/cargo-publish.yml | |
| with: | |
| version: ${{ needs.set-version.outputs.version }} | |
| dry_run: ${{ needs.set-version.outputs.dry_run != 'false' }} |