Skip to content

Commit 8f5d9c6

Browse files
committed
feat: consolidate release CI, dedup release and PR
1 parent 1b0c9fb commit 8f5d9c6

File tree

2 files changed

+39
-49
lines changed

2 files changed

+39
-49
lines changed

.github/workflows/ci.yml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
types: [ published ]
1010
workflow_dispatch:
1111

12+
permissions:
13+
pull-requests: write
14+
contents: write
15+
1216
defaults:
1317
run:
1418
shell: bash
@@ -189,9 +193,43 @@ jobs:
189193
# This job checks if any of the previous jobs failed or were canceled.
190194
# This approach also allows some jobs to be skipped if they are not needed.
191195
ci-passed:
192-
if: always()
193196
needs: [ test, test-msrv, build, cross-build ]
197+
if: always()
194198
runs-on: ubuntu-latest
195199
steps:
196200
- if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
197201
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 }}

.github/workflows/release-plz.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)