|
1 | | -name: Release-plz |
| 1 | +# 1. Populate the release object when a new release is created |
| 2 | +# in GitHub. |
| 3 | +# <https://github.com/taiki-e/create-gh-release-action> |
| 4 | +# 2. Attach binaries to releases |
| 5 | +# <https://github.com/taiki-e/upload-rust-binary-action> |
| 6 | +# 3. Publish to crates.io. |
2 | 7 |
|
3 | | -on: |
4 | | - push: |
5 | | - branches: |
6 | | - - main |
| 8 | +name: Release |
7 | 9 |
|
8 | 10 | permissions: |
9 | | - id-token: write |
| 11 | + contents: write |
| 12 | + |
| 13 | +# TODO: Use "environment:release" for some security benefits? |
| 14 | + |
| 15 | +on: |
| 16 | + # release: |
| 17 | + # types: |
| 18 | + # - created |
| 19 | + push: |
| 20 | + tags: |
| 21 | + - v[0-9]+.* |
10 | 22 |
|
11 | 23 | jobs: |
12 | | - # Release unpublished packages. |
13 | | - release-plz-release: |
14 | | - name: Release-plz release |
| 24 | + test: |
15 | 25 | runs-on: ubuntu-latest |
16 | | - if: ${{ github.repository_owner == 'sourcefrog' }} |
17 | | - permissions: |
18 | | - contents: write |
19 | | - id-token: write |
20 | 26 | steps: |
21 | | - - &checkout |
22 | | - name: Checkout repository |
23 | | - uses: actions/checkout@v6 |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + - uses: taiki-e/install-action@v2 |
| 29 | + name: Install nextest using install-action |
24 | 30 | with: |
25 | | - fetch-depth: 0 |
26 | | - persist-credentials: false |
27 | | - - &install-rust |
28 | | - name: Install Rust toolchain |
29 | | - uses: dtolnay/rust-toolchain@stable |
30 | | - - name: Run release-plz |
31 | | - uses: release-plz/action@v0.5 |
| 31 | + tool: nextest |
| 32 | + - run: cargo test --all-features |
| 33 | + create-release: |
| 34 | + needs: test |
| 35 | + runs-on: ubuntu-latest |
| 36 | + environment: release |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v4 |
| 39 | + - uses: taiki-e/create-gh-release-action@v1 |
32 | 40 | with: |
33 | | - command: release |
34 | | - # dry_run: true |
35 | | - env: |
36 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
37 | | - # CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
38 | | - |
39 | | - # Create a PR with the new versions and changelog, preparing the next release. |
40 | | - release-plz-pr: |
41 | | - name: Release-plz PR |
| 41 | + changelog: NEWS.md |
| 42 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + # TODO: maybe also `branch: main` as in general we |
| 44 | + # should not release from other branches |
| 45 | + upload-assets: |
| 46 | + needs: [test, create-release] |
| 47 | + environment: release |
| 48 | + strategy: |
| 49 | + matrix: |
| 50 | + include: |
| 51 | + - target: x86_64-unknown-linux-gnu |
| 52 | + os: ubuntu-latest |
| 53 | + - target: x86_64-apple-darwin |
| 54 | + os: macos-latest |
| 55 | + - target: x86_64-pc-windows-msvc |
| 56 | + os: windows-latest |
| 57 | + runs-on: ${{ matrix.os }} |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v4 |
| 60 | + - uses: taiki-e/upload-rust-binary-action@v1 |
| 61 | + with: |
| 62 | + # (required) Comma-separated list of binary names (non-extension portion of filename) to build and upload. |
| 63 | + # Note that glob pattern is not supported yet. |
| 64 | + bin: cargo-mutants |
| 65 | + # (required) GitHub token for uploading assets to GitHub Releases. |
| 66 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + target: ${{ matrix.target }} |
| 68 | + publish-crate: |
42 | 69 | runs-on: ubuntu-latest |
43 | | - if: ${{ github.repository_owner == 'sourcefrog' }} |
| 70 | + needs: [test, create-release] |
44 | 71 | permissions: |
45 | | - contents: write |
46 | | - pull-requests: write |
47 | | - id-token: write |
48 | | - concurrency: |
49 | | - group: release-plz-${{ github.ref }} |
50 | | - cancel-in-progress: false |
| 72 | + id-token: write # Required for OIDC token exchange |
51 | 73 | steps: |
52 | | - - *checkout |
53 | | - - *install-rust |
54 | | - - name: Run release-plz |
55 | | - uses: release-plz/action@v0.5 |
56 | | - with: |
57 | | - command: release-pr |
58 | | - # dry_run: true |
| 74 | + - uses: actions/checkout@v4 |
| 75 | + - uses: rust-lang/crates-io-auth-action@v1 |
| 76 | + id: auth |
| 77 | + - run: cargo publish |
59 | 78 | env: |
60 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
61 | | - # CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
| 79 | + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} |
0 commit comments