|
13 | 13 | types: [ published ] |
14 | 14 | workflow_dispatch: |
15 | 15 |
|
| 16 | +permissions: |
| 17 | + pull-requests: write |
| 18 | + contents: write |
| 19 | + |
16 | 20 | defaults: |
17 | 21 | run: |
18 | 22 | shell: bash |
|
68 | 72 | # This job checks if any of the previous jobs failed or were canceled. |
69 | 73 | # This approach also allows some jobs to be skipped if they are not needed. |
70 | 74 | ci-passed: |
71 | | - if: always() |
72 | 75 | needs: [ test, test-msrv ] |
| 76 | + if: always() |
73 | 77 | runs-on: ubuntu-latest |
74 | 78 | steps: |
75 | 79 | - if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} |
76 | 80 | run: exit 1 |
| 81 | + |
| 82 | + # Release unpublished packages or create a PR with changes |
| 83 | + release-plz: |
| 84 | + needs: [ ci-passed ] |
| 85 | + if: | |
| 86 | + always() |
| 87 | + && needs.ci-passed.result == 'success' |
| 88 | + && github.event_name == 'push' |
| 89 | + && github.ref == 'refs/heads/main' |
| 90 | + && github.repository_owner == 'georust' |
| 91 | + runs-on: ubuntu-latest |
| 92 | + permissions: |
| 93 | + contents: write |
| 94 | + pull-requests: write |
| 95 | + concurrency: |
| 96 | + group: release-plz-${{ github.ref }} |
| 97 | + cancel-in-progress: false |
| 98 | + steps: |
| 99 | + - uses: actions/checkout@v4 |
| 100 | + with: { fetch-depth: 0 } |
| 101 | + - uses: dtolnay/rust-toolchain@stable |
| 102 | + - name: Publish to crates.io if crate's version is newer |
| 103 | + uses: release-plz/action@v0.5 |
| 104 | + id: release |
| 105 | + with: { command: release } |
| 106 | + env: |
| 107 | + GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }} |
| 108 | + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
| 109 | + - name: If version is the same, create a PR proposing new version and changelog for the next release |
| 110 | + uses: release-plz/action@v0.5 |
| 111 | + if: ${{ steps.release.outputs.releases_created == 'false' }} |
| 112 | + with: { command: release-pr } |
| 113 | + env: |
| 114 | + GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }} |
0 commit comments