|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + bump: |
| 7 | + description: 'Bump version by semver keyword.' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | + # Inputs for `actions-rust-lang/setup-rust-toolchain`. |
| 12 | + # https://github.com/actions-rust-lang/setup-rust-toolchain/blob/main/action.yml |
| 13 | + toolchain: |
| 14 | + description: 'Comma-separated list of Rust toolchain specifications. Last version becomes the default. -- see https://rust-lang.github.io/rustup/concepts/toolchains.html#toolchain-specification' |
| 15 | + type: string |
| 16 | + required: false |
| 17 | + target: |
| 18 | + description: 'Target triple to install for this toolchain' |
| 19 | + type: string |
| 20 | + required: false |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: write |
| 24 | + |
| 25 | +jobs: |
| 26 | + release: |
| 27 | + name: Release |
| 28 | + runs-on: ubuntu-latest |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Generate GitHub App token |
| 32 | + id: app-token |
| 33 | + uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1 |
| 34 | + with: |
| 35 | + client-id: ${{ secrets.APP_ID }} |
| 36 | + private-key: ${{ secrets.APP_PRIVATE_KEY }} |
| 37 | + |
| 38 | + - name: Checkout |
| 39 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 40 | + |
| 41 | + - name: Set up Rust toolchain |
| 42 | + uses: actions-rust-lang/setup-rust-toolchain@2b1f5e9b395427c92ee4e3331786ca3c37afe2d7 # v1.16.0 |
| 43 | + with: |
| 44 | + toolchain: ${{ inputs.toolchain }} |
| 45 | + target: ${{ inputs.target }} |
| 46 | + |
| 47 | + - name: Install Cargo Binary Install |
| 48 | + uses: cargo-bins/cargo-binstall@dc19f1e48450eefe5a29b8da6c6b00a87d730b37 # v1.18.1 |
| 49 | + |
| 50 | + - name: Install crates |
| 51 | + run: cargo binstall --force -y cargo-workspaces toml-cli |
| 52 | + |
| 53 | + - name: Bump version |
| 54 | + run: cargo workspaces version --all --no-git-commit --yes ${{ inputs.bump }} |
| 55 | + |
| 56 | + - name: Extract version |
| 57 | + id: extract-version |
| 58 | + run: echo "VERSION=v$(toml get Cargo.toml workspace.package.version --raw)" >> "$GITHUB_OUTPUT" |
| 59 | + |
| 60 | + - name: Add changes |
| 61 | + run: git add . |
| 62 | + |
| 63 | + - name: Commit |
| 64 | + id: commit |
| 65 | + uses: dsanders11/github-app-commit-action@2bbcd331016d8c950b05a24b56e7eb9cb50d545e # v2.1.0 |
| 66 | + with: |
| 67 | + message: ${{ steps.extract-version.outputs.VERSION }} |
| 68 | + token: ${{ steps.app-token.outputs.token }} |
| 69 | + |
| 70 | + - name: Reset and pull |
| 71 | + run: git reset --hard && git pull |
| 72 | + |
| 73 | + - name: Tag |
| 74 | + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 |
| 75 | + env: |
| 76 | + GIT_TAG: ${{ steps.extract-version.outputs.VERSION }} |
| 77 | + GIT_SHA: ${{ steps.commit.outputs.sha }} |
| 78 | + with: |
| 79 | + script: | |
| 80 | + github.rest.git.createRef({ |
| 81 | + owner: context.repo.owner, |
| 82 | + repo: context.repo.repo, |
| 83 | + ref: `refs/tags/${process.env.GIT_TAG}`, |
| 84 | + sha: process.env.GIT_SHA |
| 85 | + }) |
| 86 | +
|
| 87 | + - name: Release |
| 88 | + uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0 |
| 89 | + with: |
| 90 | + generate_release_notes: true |
| 91 | + make_latest: true |
| 92 | + tag_name: ${{ steps.extract-version.outputs.VERSION }} |
| 93 | + token: ${{ steps.app-token.outputs.token }} |
0 commit comments