Skip to content

Commit 8dffce1

Browse files
feat: update release flow
chore: Release memtrack version 1.0.0-alpha.10 🎉 --wip-- [skip ci]
1 parent cdf0396 commit 8dffce1

File tree

8 files changed

+152
-45
lines changed

8 files changed

+152
-45
lines changed

.github/workflows/bump-action.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Create draft release
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+
- uses: actions/checkout@v4
22+
23+
- name: Create draft release
24+
run: |
25+
RELEASE_TAG=$(echo ${PLAN} | jq -r '.announcement_tag')
26+
27+
echo "Creating draft release ${RELEASE_TAG}"
28+
gh release create "$RELEASE_TAG" --draft --notes "" --title "Release $RELEASE_TAG"
29+
echo "Release created successfully"
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: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
# * uploads those artifacts to temporary workflow zip
1111
# * on success, uploads the artifacts to a GitHub Release
1212
#
13-
# Note that the GitHub Release will be created with a generated
14-
# title/body based on your changelogs.
13+
# Note that a GitHub Release with this tag is assumed to exist as a draft
14+
# with the appropriate title/body, and will be undrafted for you.
1515

1616
name: Release
1717
permissions:
@@ -165,11 +165,21 @@ jobs:
165165
${{ steps.cargo-dist.outputs.paths }}
166166
${{ env.BUILD_MANIFEST_NAME }}
167167
168+
custom-create-draft-release:
169+
needs:
170+
- plan
171+
if: ${{ needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload' }}
172+
uses: ./.github/workflows/create-draft-release.yml
173+
with:
174+
plan: ${{ needs.plan.outputs.val }}
175+
secrets: inherit
176+
168177
# Build and package all the platform-agnostic(ish) things
169178
build-global-artifacts:
170179
needs:
171180
- plan
172181
- build-local-artifacts
182+
- custom-create-draft-release
173183
runs-on: "ubuntu-22.04"
174184
env:
175185
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -216,9 +226,10 @@ jobs:
216226
needs:
217227
- plan
218228
- build-local-artifacts
229+
- custom-create-draft-release
219230
- build-global-artifacts
220231
# Only run if we're "publishing", and only if plan, local and global didn't fail (skipped is fine)
221-
if: ${{ always() && needs.plan.result == 'success' && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }}
232+
if: ${{ always() && needs.plan.result == 'success' && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') && (needs.custom-create-draft-release.result == 'skipped' || needs.custom-create-draft-release.result == 'success') }}
222233
env:
223234
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
224235
runs-on: "ubuntu-22.04"
@@ -269,14 +280,12 @@ jobs:
269280
- name: Create GitHub Release
270281
env:
271282
PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
272-
ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
273-
ANNOUNCEMENT_BODY: "${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
274283
RELEASE_COMMIT: "${{ github.sha }}"
275284
run: |
276-
# Write and read notes from a file to avoid quoting breaking things
277-
echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
285+
# If we're editing a release in place, we need to upload things ahead of time
286+
gh release upload "${{ needs.plan.outputs.tag }}" artifacts/*
278287
279-
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
288+
gh release edit "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --draft=false
280289
281290
announce:
282291
needs:
@@ -295,11 +304,11 @@ jobs:
295304
persist-credentials: false
296305
submodules: recursive
297306

298-
custom-bump-action:
307+
custom-post-announce:
299308
needs:
300309
- plan
301310
- announce
302-
uses: ./.github/workflows/bump-action.yml
311+
uses: ./.github/workflows/post-announce.yml
303312
with:
304313
plan: ${{ needs.plan.outputs.val }}
305314
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.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/memtrack/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "memtrack"
3-
version = "1.0.0"
3+
version = "1.0.0-alpha.11"
44
edition = "2024"
55
repository = "https://github.com/CodSpeedHQ/runner"
66
publish = false

dist-workspace.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ unix-archive = ".tar.gz"
1616
# Which actions to run on pull requests
1717
pr-run-mode = "plan"
1818
# Post-announce jobs to run in CI
19-
post-announce-jobs = ["./bump-action"]
19+
post-announce-jobs = ["./post-announce"]
2020
# Path that installers should place binaries in
2121
install-path = "CARGO_HOME"
2222
# Whether to install an updater program
2323
install-updater = false
2424
# Build only the required packages, and individually
2525
precise-builds = true
26+
# Don't create GitHub releases, we handle that manually to manually control which release is marked as latest
27+
create-release = false
28+
# Use the stage just after plan because we need its output to create the draft release
29+
local-artifacts-jobs = ["./create-draft-release"]
2630

2731
[dist.github-custom-runners]
2832
aarch64-unknown-linux-musl = "buildjet-2vcpu-ubuntu-2204-arm"

0 commit comments

Comments
 (0)