Skip to content

Commit 1674076

Browse files
feat: update release flow
1 parent df1e6f1 commit 1674076

5 files changed

Lines changed: 110 additions & 43 deletions

File tree

.github/workflows/bump-action.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Bump action runner version
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
plan:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
main:
12+
runs-on: ubuntu-latest
13+
env:
14+
PLAN: ${{ inputs.plan }}
15+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
steps:
17+
- name: Plan details
18+
run: |
19+
echo "Plan details: $PLAN"
20+
21+
- name: Update release title and body
22+
run: |
23+
RELEASE_TAG=$(echo ${PLAN} | jq -r '.announcement_tag')
24+
ANNOUNCEMENT_TITLE=$(echo ${PLAN} | jq -r '.announcement_title')
25+
ANNOUNCEMENT_BODY=$(echo ${PLAN} | jq -r '.announcement_github_body')
26+
REPO_OWNER=$(echo ${PLAN} | jq -r '.releases[0].hosting.github.owner')
27+
REPO_NAME=$(echo ${PLAN} | jq -r '.releases[0].hosting.github.repo')
28+
29+
echo "Updating release ${RELEASE_TAG} with title and body from dist plan"
30+
31+
# Write body to file to avoid quoting issues
32+
echo "$ANNOUNCEMENT_BODY" > /tmp/release-notes.txt
33+
34+
# Update the release with title and body
35+
gh release edit "${RELEASE_TAG}" \
36+
-R "${REPO_OWNER}/${REPO_NAME}" \
37+
--title "${ANNOUNCEMENT_TITLE}" \
38+
--notes-file /tmp/release-notes.txt
39+
40+
echo "Release metadata updated successfully"
41+
42+
- name: Check if runner was released
43+
id: check_runner
44+
run: |
45+
IS_PRE_RELEASE=$(echo ${PLAN} | jq '.announcement_is_prerelease')
46+
NEW_VERSION=$(echo ${PLAN} | jq -r '.releases[] | select(.app_name == "codspeed-runner") | .app_version')
47+
RELEASE_TAG=$(echo ${PLAN} | jq -r '.announcement_tag')
48+
49+
echo "is_pre_release=${IS_PRE_RELEASE}" >> "$GITHUB_OUTPUT"
50+
echo "new_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
51+
echo "release_tag=${RELEASE_TAG}" >> "$GITHUB_OUTPUT"
52+
53+
if [ "${IS_PRE_RELEASE}" == "true" ]; then
54+
echo "runner_released=false" >> "$GITHUB_OUTPUT"
55+
echo "Pre-release detected, will not mark as latest or bump action"
56+
elif [ -z "${NEW_VERSION}" ] || [ "${NEW_VERSION}" == "null" ]; then
57+
echo "runner_released=false" >> "$GITHUB_OUTPUT"
58+
echo "No codspeed-runner release found in plan"
59+
else
60+
echo "runner_released=true" >> "$GITHUB_OUTPUT"
61+
echo "Runner version ${NEW_VERSION} was released"
62+
fi
63+
64+
- name: Mark release as latest
65+
if: steps.check_runner.outputs.runner_released == 'true'
66+
run: |
67+
RELEASE_TAG="${{ steps.check_runner.outputs.release_tag }}"
68+
REPO_OWNER=$(echo ${PLAN} | jq -r '.releases[0].hosting.github.owner')
69+
REPO_NAME=$(echo ${PLAN} | jq -r '.releases[0].hosting.github.repo')
70+
echo "Marking release ${RELEASE_TAG} as latest"
71+
gh release edit "${RELEASE_TAG}" -R "${REPO_OWNER}/${REPO_NAME}" --latest
72+
73+
- name: Trigger action runner version bump workflow
74+
if: steps.check_runner.outputs.runner_released == 'true'
75+
env:
76+
GH_TOKEN: ${{ secrets.PAT_CODSPEED_ACTION }}
77+
run: |
78+
NEW_VERSION="${{ steps.check_runner.outputs.new_version }}"
79+
echo "Triggering action runner version bump for version ${NEW_VERSION}"
80+
# Trigger the bump-runner-version workflow in the CodSpeedHQ/actions repository
81+
gh workflow run bump-runner-version.yml -R CodSpeedHQ/action -f version=${NEW_VERSION}

.github/workflows/release.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
# * uploads those artifacts to temporary workflow zip
1212
# * on success, uploads the artifacts to a GitHub Release
1313
#
14-
# Note that the GitHub Release will be created with a generated
15-
# title/body based on your changelogs.
14+
# Note that a GitHub Release with this tag is assumed to exist as a draft
15+
# with the appropriate title/body, and will be undrafted for you.
1616

1717
name: Release
1818
permissions:
@@ -270,14 +270,12 @@ jobs:
270270
- name: Create GitHub Release
271271
env:
272272
PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
273-
ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
274-
ANNOUNCEMENT_BODY: "${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
275273
RELEASE_COMMIT: "${{ github.sha }}"
276274
run: |
277-
# Write and read notes from a file to avoid quoting breaking things
278-
echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
275+
# If we're editing a release in place, we need to upload things ahead of time
276+
gh release upload "${{ needs.plan.outputs.tag }}" artifacts/*
279277
280-
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
278+
gh release edit "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --draft=false
281279
282280
announce:
283281
needs:
@@ -296,11 +294,11 @@ jobs:
296294
persist-credentials: false
297295
submodules: recursive
298296

299-
custom-bump-action:
297+
custom-post-announce:
300298
needs:
301299
- plan
302300
- announce
303-
uses: ./.github/workflows/bump-action.yml
301+
uses: ./.github/workflows/post-announce.yml
304302
with:
305303
plan: ${{ needs.plan.outputs.val }}
306304
secrets: inherit

CONTRIBUTING.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,21 @@ cargo release --execute patch
8080
cargo release --execute beta
8181
```
8282

83+
### Release Flow Details
84+
85+
When you run `cargo release --execute <version>`, the following happens:
86+
87+
1. **cargo-release** creates a git tag and pushes it to GitHub
88+
2. **GitHub Actions release workflow** triggers on the tag:
89+
- Custom cargo-dist workflow creates a draft GitHub release
90+
- cargo-dist builds artifacts for all platforms, uploads them to the draft release, and then publishes it
91+
3. **post-announce workflow** runs:
92+
- Updates the release title and body from the dist plan
93+
- If it's a runner release (not pre-release): marks it as "latest" and triggers action repo workflow
94+
- If it's a package release or pre-release: just updates the metadata
95+
96+
This ensures only stable runner releases are marked as "latest" in GitHub.
97+
8398
## Known issue
8499

85-
If one of the crates is currenlty in beta version, for example the runner is in beta version 4.4.2-beta.1, any alpha release will fail for the any crate, saying that only minor, major or patch releases is supported.
100+
- If one of the crates is currenlty in beta version, for example the runner is in beta version 4.4.2-beta.1, any alpha release will fail for the any crate, saying that only minor, major or patch releases is supported.

Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ strip = true
111111
[package.metadata.dist]
112112
targets = ["aarch64-unknown-linux-musl", "x86_64-unknown-linux-musl"]
113113

114-
# Config for 'dist' for all crates in the workspace
114+
# Config for 'dist'
115115
[workspace.metadata.dist]
116116
# Whether to consider the binaries in a package for distribution (defaults true)
117117
dist = true
@@ -126,13 +126,17 @@ unix-archive = ".tar.gz"
126126
# Which actions to run on pull requests
127127
pr-run-mode = "plan"
128128
# Post-announce jobs to run in CI
129-
post-announce-jobs = ["./bump-action"]
129+
post-announce-jobs = ["./post-announce"]
130130
# Path that installers should place binaries in
131131
install-path = "CARGO_HOME"
132132
# Whether to install an updater program
133133
install-updater = false
134134
# Build only the required packages, and individually
135135
precise-builds = true
136+
# Don't create GitHub releases, we handle that manually to manually control which release is marked as latest
137+
create-release = false
138+
# Use the stage just after plan because we need its output to create the draft release
139+
build-local-artifacts-jobs = ["./create-draft-release"]
136140

137141
[workspace.metadata.dist.github-custom-runners]
138142
aarch64-unknown-linux-musl = "buildjet-2vcpu-ubuntu-2204-arm"

0 commit comments

Comments
 (0)