Skip to content

Commit 29de5cb

Browse files
authored
fix(ci): run release publish after dev checks (#467)
* fix(ci): run release publish after dev checks * fix(ci): decouple release publish from container jobs
1 parent 06748bc commit 29de5cb

2 files changed

Lines changed: 59 additions & 84 deletions

File tree

.github/workflows/ci.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,3 +420,62 @@ jobs:
420420
permissions:
421421
contents: read
422422
packages: write
423+
424+
release_publish:
425+
name: Publish releases
426+
if: >-
427+
${{
428+
always()
429+
&& github.repository == 'rcore-os/tgoskits'
430+
&& github.event_name == 'push'
431+
&& github.ref_name == 'dev'
432+
&& needs.detect_changes.outputs.ci_checks == 'true'
433+
&& needs.fmt.result == 'success'
434+
&& needs.post_fmt_checks.result == 'success'
435+
}}
436+
needs:
437+
- detect_changes
438+
- fmt
439+
- post_fmt_checks
440+
runs-on: ubuntu-latest
441+
concurrency:
442+
group: release-plz-release-${{ github.ref_name }}
443+
cancel-in-progress: false
444+
permissions:
445+
contents: write
446+
pull-requests: read
447+
steps:
448+
- name: Checkout code
449+
uses: actions/checkout@v6
450+
with:
451+
fetch-depth: 0
452+
persist-credentials: false
453+
454+
- name: Attach checkout to dev branch
455+
shell: bash
456+
run: |
457+
set -euo pipefail
458+
459+
git fetch --prune origin +refs/heads/dev:refs/remotes/origin/dev
460+
origin_dev="$(git rev-parse origin/dev)"
461+
if [ "${origin_dev}" != "${GITHUB_SHA}" ]; then
462+
echo "origin/dev (${origin_dev}) does not match this CI commit (${GITHUB_SHA}); skipping release publish." >&2
463+
exit 1
464+
fi
465+
466+
git switch -C dev "${GITHUB_SHA}"
467+
git branch --set-upstream-to=origin/dev dev
468+
git status --short --branch
469+
470+
- name: Install Rust toolchain
471+
uses: dtolnay/rust-toolchain@stable
472+
473+
- name: Run release-plz release
474+
uses: release-plz/action@v0.5
475+
with:
476+
command: release
477+
config: release-plz.toml
478+
token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
479+
env:
480+
GITHUB_TOKEN: ${{ github.token }}
481+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.github/workflows/release-plz.yml

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
name: Release-plz
22

33
on:
4-
workflow_run:
5-
workflows:
6-
- CI
7-
types:
8-
- completed
9-
branches:
10-
- dev
114
push:
125
branches:
136
- main
@@ -51,80 +44,3 @@ jobs:
5144
config: release-plz.toml
5245
env:
5346
GITHUB_TOKEN: ${{ github.token }}
54-
55-
release-ci-gate:
56-
name: Confirm CI checks ran
57-
if: >-
58-
${{
59-
github.repository_owner == 'rcore-os'
60-
&& github.event_name == 'workflow_run'
61-
&& github.event.workflow_run.conclusion == 'success'
62-
&& github.event.workflow_run.event == 'push'
63-
&& github.event.workflow_run.head_branch == 'dev'
64-
}}
65-
runs-on: ubuntu-latest
66-
permissions:
67-
actions: read
68-
outputs:
69-
ready: ${{ steps.check.outputs.ready }}
70-
steps:
71-
- name: Check CI job results
72-
id: check
73-
uses: actions/github-script@v8
74-
with:
75-
script: |
76-
const owner = context.repo.owner;
77-
const repo = context.repo.repo;
78-
const run_id = context.payload.workflow_run.id;
79-
const jobs = await github.paginate(github.rest.actions.listJobsForWorkflowRun, {
80-
owner,
81-
repo,
82-
run_id,
83-
per_page: 100,
84-
});
85-
86-
const fmtJobs = jobs.filter((job) =>
87-
job.name === "Check formatting" || job.name.startsWith("Check formatting /")
88-
);
89-
const ready = fmtJobs.some((job) => job.conclusion === "success");
90-
91-
if (!ready) {
92-
core.notice("CI finished successfully without running Check formatting; release publishing will be skipped.");
93-
}
94-
95-
core.setOutput("ready", ready ? "true" : "false");
96-
97-
release-plz-release:
98-
name: Publish releases
99-
needs: release-ci-gate
100-
if: >-
101-
${{
102-
needs.release-ci-gate.outputs.ready == 'true'
103-
}}
104-
runs-on: ubuntu-latest
105-
concurrency:
106-
group: release-plz-release-${{ github.event.workflow_run.head_branch }}
107-
cancel-in-progress: false
108-
permissions:
109-
contents: write
110-
pull-requests: read
111-
steps:
112-
- name: Checkout code
113-
uses: actions/checkout@v6
114-
with:
115-
fetch-depth: 0
116-
ref: ${{ github.event.workflow_run.head_sha }}
117-
persist-credentials: false
118-
119-
- name: Install Rust toolchain
120-
uses: dtolnay/rust-toolchain@stable
121-
122-
- name: Run release-plz release
123-
uses: release-plz/action@v0.5
124-
with:
125-
command: release
126-
config: release-plz.toml
127-
token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
128-
env:
129-
GITHUB_TOKEN: ${{ github.token }}
130-
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

0 commit comments

Comments
 (0)