|
9 | 9 | types: [ published ] |
10 | 10 | workflow_dispatch: |
11 | 11 |
|
| 12 | +permissions: |
| 13 | + pull-requests: write |
| 14 | + contents: write |
| 15 | + |
12 | 16 | defaults: |
13 | 17 | run: |
14 | 18 | shell: bash |
@@ -189,9 +193,43 @@ jobs: |
189 | 193 | # This job checks if any of the previous jobs failed or were canceled. |
190 | 194 | # This approach also allows some jobs to be skipped if they are not needed. |
191 | 195 | ci-passed: |
192 | | - if: always() |
193 | 196 | needs: [ test, test-msrv, build, cross-build ] |
| 197 | + if: always() |
194 | 198 | runs-on: ubuntu-latest |
195 | 199 | steps: |
196 | 200 | - if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} |
197 | 201 | run: exit 1 |
| 202 | + |
| 203 | + # Release unpublished packages or create a PR with changes |
| 204 | + release-plz: |
| 205 | + needs: [ ci-passed ] |
| 206 | + if: | |
| 207 | + always() |
| 208 | + && needs.ci-passed.result == 'success' |
| 209 | + && github.event_name == 'push' |
| 210 | + && github.ref == 'refs/heads/main' |
| 211 | + && github.repository_owner == 'nyurik' |
| 212 | + runs-on: ubuntu-latest |
| 213 | + permissions: |
| 214 | + contents: write |
| 215 | + pull-requests: write |
| 216 | + concurrency: |
| 217 | + group: release-plz-${{ github.ref }} |
| 218 | + cancel-in-progress: false |
| 219 | + steps: |
| 220 | + - uses: actions/checkout@v4 |
| 221 | + with: { fetch-depth: 0 } |
| 222 | + - uses: dtolnay/rust-toolchain@stable |
| 223 | + - name: Publish to crates.io if crate's version is newer |
| 224 | + uses: release-plz/[email protected] |
| 225 | + id: release |
| 226 | + with: { command: release } |
| 227 | + env: |
| 228 | + GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }} |
| 229 | + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
| 230 | + - name: If version is the same, create a PR proposing new version and changelog for the next release |
| 231 | + uses: release-plz/[email protected] |
| 232 | + if: ${{ steps.release.outputs.releases_created == 'false' }} |
| 233 | + with: { command: release-pr } |
| 234 | + env: |
| 235 | + GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }} |
0 commit comments