-
Notifications
You must be signed in to change notification settings - Fork 8
feat: update release flow to make sure only runner releases are marked as latest #180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
art049
merged 2 commits into
main
from
cod-1894-ensure-only-runner-releases-can-be-marked-as-latest-release
Dec 23, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| name: Create draft release | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| plan: | ||
| required: true | ||
| type: string | ||
|
|
||
| jobs: | ||
| main: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| PLAN: ${{ inputs.plan }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| steps: | ||
| - name: Plan details | ||
| run: | | ||
| echo "Plan details: $PLAN" | ||
|
|
||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Create draft release | ||
| run: | | ||
| RELEASE_TAG=$(echo ${PLAN} | jq -r '.announcement_tag') | ||
| ANNOUNCEMENT_TITLE=$(echo ${PLAN} | jq -r '.announcement_title') | ||
| ANNOUNCEMENT_BODY=$(echo ${PLAN} | jq -r '.announcement_github_body') | ||
|
|
||
| # Write body to file to avoid quoting issues | ||
| echo "$ANNOUNCEMENT_BODY" > /tmp/release-notes.txt | ||
|
|
||
| echo "Creating draft release ${RELEASE_TAG}" | ||
| # The release will be undrafted by cargo-dist after it has uploaded the artifacts | ||
| gh release create "${RELEASE_TAG}" \ | ||
| --draft \ | ||
| --title "${ANNOUNCEMENT_TITLE}" \ | ||
| --notes-file /tmp/release-notes.txt | ||
|
|
||
| echo "Release created successfully" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| name: Bump action runner version | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| plan: | ||
| required: true | ||
| type: string | ||
|
|
||
| jobs: | ||
| main: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| PLAN: ${{ inputs.plan }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| steps: | ||
| - name: Plan details | ||
| run: | | ||
| echo "Plan details: $PLAN" | ||
|
|
||
| - name: Check if runner was released | ||
| id: check_runner | ||
| run: | | ||
| IS_PRE_RELEASE=$(echo ${PLAN} | jq '.announcement_is_prerelease') | ||
| NEW_VERSION=$(echo ${PLAN} | jq -r '.releases[] | select(.app_name == "codspeed-runner") | .app_version') | ||
| RELEASE_TAG=$(echo ${PLAN} | jq -r '.announcement_tag') | ||
|
|
||
| echo "is_pre_release=${IS_PRE_RELEASE}" >> "$GITHUB_OUTPUT" | ||
| echo "new_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT" | ||
| echo "release_tag=${RELEASE_TAG}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| if [ "${IS_PRE_RELEASE}" == "true" ]; then | ||
| echo "runner_released=false" >> "$GITHUB_OUTPUT" | ||
| echo "Pre-release detected, cargo-dist has already undrafted this release, nothing more to do" | ||
| elif [ -z "${NEW_VERSION}" ] || [ "${NEW_VERSION}" == "null" ]; then | ||
| echo "runner_released=false" >> "$GITHUB_OUTPUT" | ||
| echo "A package other than the runner has been released, cargo-dist has already undrafted this release, nothing more to do" | ||
| else | ||
art049 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| echo "runner_released=true" >> "$GITHUB_OUTPUT" | ||
| echo "Runner version ${NEW_VERSION} was released" | ||
| fi | ||
|
|
||
| - name: Mark release as latest | ||
| if: steps.check_runner.outputs.runner_released == 'true' | ||
| run: | | ||
| RELEASE_TAG="${{ steps.check_runner.outputs.release_tag }}" | ||
| REPO_OWNER=$(echo ${PLAN} | jq -r '.releases[0].hosting.github.owner') | ||
| REPO_NAME=$(echo ${PLAN} | jq -r '.releases[0].hosting.github.repo') | ||
| echo "Marking release ${RELEASE_TAG} as latest" | ||
| gh release edit "${RELEASE_TAG}" -R "${REPO_OWNER}/${REPO_NAME}" --latest | ||
|
|
||
| - name: Trigger action runner version bump workflow | ||
| if: steps.check_runner.outputs.runner_released == 'true' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.PAT_CODSPEED_ACTION }} | ||
| run: | | ||
| NEW_VERSION="${{ steps.check_runner.outputs.new_version }}" | ||
| echo "Triggering action runner version bump for version ${NEW_VERSION}" | ||
| # Trigger the bump-runner-version workflow in the CodSpeedHQ/action repository | ||
| gh workflow run bump-runner-version.yml -R CodSpeedHQ/action -f version=${NEW_VERSION} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| echo "=== Alpha Release Cleanup Script ===" | ||
| echo "" | ||
|
|
||
| # Fetch all alpha releases | ||
| echo "Fetching alpha releases..." | ||
| RELEASES=$(gh release list --limit 1000 | grep "alpha" | awk -F'\t' '{print $3}' || true) | ||
|
|
||
| # Fetch all alpha tags | ||
| echo "Fetching alpha tags..." | ||
| git fetch --tags 2>/dev/null || true | ||
| TAGS=$(git tag -l "*alpha*" || true) | ||
|
|
||
| # Combine and get unique names | ||
| ALL_ITEMS=$(echo -e "$RELEASES\n$TAGS" | sort -u | grep -v '^$' || true) | ||
|
|
||
| echo "" | ||
| echo "=========================================" | ||
| echo "FOUND ITEMS:" | ||
| echo "=========================================" | ||
| echo "" | ||
|
|
||
| if [ -z "$ALL_ITEMS" ]; then | ||
| echo "No alpha releases or tags found." | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Display each item with its status | ||
| for ITEM in $ALL_ITEMS; do | ||
| HAS_RELEASE="" | ||
| HAS_TAG="" | ||
|
|
||
| if echo "$RELEASES" | grep -q "^${ITEM}$"; then | ||
| HAS_RELEASE="✓" | ||
| else | ||
| HAS_RELEASE="✗" | ||
| fi | ||
|
|
||
| if echo "$TAGS" | grep -q "^${ITEM}$"; then | ||
| HAS_TAG="✓" | ||
| else | ||
| HAS_TAG="✗" | ||
| fi | ||
|
|
||
| echo " - $ITEM [Release: $HAS_RELEASE | Tag: $HAS_TAG]" | ||
| done | ||
|
|
||
| echo "" | ||
| echo "=========================================" | ||
| echo "" | ||
|
|
||
| # Process each item | ||
| for ITEM in $ALL_ITEMS; do | ||
| HAS_RELEASE=false | ||
| HAS_TAG=false | ||
|
|
||
| if echo "$RELEASES" | grep -q "^${ITEM}$"; then | ||
| HAS_RELEASE=true | ||
| fi | ||
|
|
||
| if echo "$TAGS" | grep -q "^${ITEM}$"; then | ||
| HAS_TAG=true | ||
| fi | ||
|
|
||
| read -p "Delete '$ITEM'? (y/N) " -n 1 -r | ||
| echo "" | ||
|
|
||
| if [[ $REPLY =~ ^[Yy]$ ]]; then | ||
| # Delete release if it exists | ||
| if [ "$HAS_RELEASE" = true ]; then | ||
| echo -n " Deleting release... " | ||
| if gh release delete "$ITEM" --yes 2>/dev/null; then | ||
| echo "✓ deleted" | ||
| else | ||
| echo "✗ failed" | ||
| fi | ||
| fi | ||
|
|
||
| # Delete remote tag if it exists | ||
| if [ "$HAS_TAG" = true ]; then | ||
| echo -n " Deleting remote tag... " | ||
| if git push origin ":refs/tags/$ITEM" 2>/dev/null; then | ||
| echo "✓ deleted" | ||
| else | ||
| echo "✗ failed (may not exist on remote)" | ||
| fi | ||
|
|
||
| # Delete local tag | ||
| echo -n " Deleting local tag... " | ||
| if git tag -d "$ITEM" 2>/dev/null; then | ||
| echo "✓ deleted" | ||
| else | ||
| echo "✗ failed" | ||
| fi | ||
| fi | ||
| else | ||
| echo " Skipped." | ||
| fi | ||
| echo "" | ||
| done | ||
|
|
||
| echo "=========================================" | ||
| echo "✓ Cleanup complete!" | ||
| echo "=========================================" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.