Skip to content

ci: migrate from release events to tag push triggers - #24

Merged
sturdy-robot merged 1 commit into
mainfrom
egui
Mar 3, 2026
Merged

ci: migrate from release events to tag push triggers#24
sturdy-robot merged 1 commit into
mainfrom
egui

Conversation

@sturdy-robot

@sturdy-robot sturdy-robot commented Mar 3, 2026

Copy link
Copy Markdown
Owner
  • Change workflow trigger from release events to tag pushes matching version pattern
  • Replace github.event.release.tag_name with github.ref_name throughout
  • Add retry logic with 30-minute timeout for release uploads to handle race conditions
  • Add rename-release-assets job to append version tags to cargo-dist archives
  • Wait for dist-manifest.json before renaming to ensure cargo-dist completion
  • Skip renaming metadata files and assets that already contain

Summary by Sourcery

Migrate the packaging workflow from GitHub release events to tag-based triggers and improve robustness of release asset handling.

Build:

  • Trigger the packaging workflow on version-like tag pushes instead of release published events.
  • Introduce a dedicated job to rename release assets produced by cargo-dist to include the version in their filenames while skipping metadata and already-versioned assets.

CI:

  • Replace usage of release event payload with tag-based refs for determining versions and conditional release uploads, adding retry logic and timeouts to wait for GitHub releases and dist artifacts before uploading or renaming assets.

- Change workflow trigger from release events to tag pushes matching version pattern
- Replace github.event.release.tag_name with github.ref_name throughout
- Add retry logic with 30-minute timeout for release uploads to handle race conditions
- Add rename-release-assets job to append version tags to cargo-dist archives
- Wait for dist-manifest.json before renaming to ensure cargo-dist completion
- Skip renaming metadata files and assets that already contain
@sturdy-robot
sturdy-robot merged commit 948c816 into main Mar 3, 2026
4 checks passed
@sourcery-ai

sourcery-ai Bot commented Mar 3, 2026

Copy link
Copy Markdown

Reviewer's Guide

Migrates the packaging workflow from release-based triggers to semantic-version tag pushes, updates version/ref handling accordingly, introduces robust retry logic for GitHub release uploads, and adds a new job to wait for cargo-dist artifacts and rename release assets to include the version tag while avoiding metadata and already-versioned files.

Sequence diagram for tag push triggering package and linux-appimage uploads with retry

sequenceDiagram
  actor Dev
  participant GitHubRepo
  participant WorkflowPackage
  participant JobPackage
  participant JobLinuxAppImage
  participant GitHubReleases
  participant GhCli as gh_cli

  Dev->>GitHubRepo: push tag refs/tags/vX.Y.Z
  GitHubRepo-->>WorkflowPackage: trigger on push tags **[0-9]+.[0-9]+.[0-9]+*

  rect rgb(235,235,235)
    WorkflowPackage->>JobPackage: start job package
    JobPackage->>JobPackage: Determine version from github.ref_name
    JobPackage->>JobPackage: Build and create ZIP artifact
    loop up to 30 attempts (every 60s)
      JobPackage->>GhCli: gh release view TAG
      alt release exists
        GhCli-->>JobPackage: success
        JobPackage->>GhCli: gh release upload TAG ZIP_NAME --clobber
        GhCli-->>GitHubReleases: attach ZIP asset
        note over JobPackage: break
      else release not found
        GhCli-->>JobPackage: not found
        JobPackage->>JobPackage: sleep 60s
      end
    end
  end

  rect rgb(235,235,235)
    WorkflowPackage->>JobLinuxAppImage: start job linux-appimage
    JobLinuxAppImage->>JobLinuxAppImage: Determine version from github.ref_name
    JobLinuxAppImage->>JobLinuxAppImage: Build and create AppImage artifact
    loop up to 30 attempts (every 60s)
      JobLinuxAppImage->>GhCli: gh release view TAG
      alt release exists
        GhCli-->>JobLinuxAppImage: success
        JobLinuxAppImage->>GhCli: gh release upload TAG APPIMAGE_NAME --clobber
        GhCli-->>GitHubReleases: attach AppImage asset
        note over JobLinuxAppImage: break
      else release not found
        GhCli-->>JobLinuxAppImage: not found
        JobLinuxAppImage->>JobLinuxAppImage: sleep 60s
      end
    end
  end
Loading

Sequence diagram for rename-release-assets job waiting for cargo-dist artifacts and renaming assets

sequenceDiagram
  participant WorkflowPackage
  participant JobRenameAssets
  participant GhCli as gh_cli
  participant GitHubReleases

  WorkflowPackage->>JobRenameAssets: start on tag push (refs/tags/vX.Y.Z)

  rect rgb(235,235,235)
    JobRenameAssets->>JobRenameAssets: Read TAG and VERSION from github.ref_name
    loop up to 60 attempts (every 30s)
      JobRenameAssets->>GhCli: gh release view TAG --json assets --jq .assets[].name
      alt dist-manifest.json present
        GhCli-->>JobRenameAssets: asset list including dist-manifest.json
        JobRenameAssets->>JobRenameAssets: proceed to renaming and break loop
      else not present
        GhCli-->>JobRenameAssets: asset list without dist-manifest.json or error
        JobRenameAssets->>JobRenameAssets: sleep 30s
      end
    end
  end

  JobRenameAssets->>GhCli: gh release view TAG --json assets --jq .assets[].name
  GhCli-->>JobRenameAssets: ASSETS list

  loop for each asset in ASSETS
    alt asset is sturdygb-* archive and not *.json and not already containing VERSION
      JobRenameAssets->>JobRenameAssets: compute new_name sturdygb-TAG-*
      JobRenameAssets->>GhCli: gh release download TAG --pattern asset
      GhCli-->>JobRenameAssets: asset file downloaded
      JobRenameAssets->>JobRenameAssets: mv asset new_name
      JobRenameAssets->>GhCli: gh release delete-asset TAG asset --yes
      GhCli-->>GitHubReleases: remove old asset
      JobRenameAssets->>GhCli: gh release upload TAG new_name
      GhCli-->>GitHubReleases: attach renamed asset
    else skip metadata or already-versioned asset
      JobRenameAssets->>JobRenameAssets: log Skipping asset
    end
  end

  JobRenameAssets-->>WorkflowPackage: job complete with versioned asset names
Loading

File-Level Changes

Change Details Files
Switch workflow trigger from release events to semantic-version tag pushes and adjust version detection logic.
  • Replace the release event trigger with a push trigger on tags matching a semantic version pattern
  • Update version resolution steps to derive VERSION from github.ref_name when running on tag refs, stripping a leading 'v' and falling back to 'dev' otherwise
  • Update conditional execution of release-related steps to check for tag refs instead of release events
.github/workflows/package.yml
Add retry and timeout logic around GitHub release uploads to handle race conditions with release creation.
  • Wrap gh release upload calls in a loop that first checks for the existence of the release via gh release view
  • Retry the upload for up to 30 attempts with 60-second intervals, logging progress and failing with an explicit error if the release never appears
  • Standardize use of github.ref_name as the release tag when uploading assets
.github/workflows/package.yml
Introduce a dedicated job to wait for cargo-dist artifacts and rename release assets to include the version tag.
  • Add a rename-release-assets job that only runs on tag refs and checks out the repository
  • Poll the GitHub release until a dist-manifest.json asset appears, with a bounded retry loop and timeout
  • Enumerate release assets and selectively rename sturdygb-* archives to include the tag, skipping JSON metadata and assets that already include the version
  • Implement the rename by downloading the asset, renaming locally, deleting the old asset from the release, and uploading the new one
.github/workflows/package.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The new tag trigger pattern ('**[0-9]+.[0-9]+.[0-9]+*') will not fire for tags prefixed with v (e.g. v1.2.3), which you still support elsewhere by stripping the leading v; if you intend to keep v-prefixed tags, consider adjusting the pattern (or adding a second pattern) so those tags still trigger the workflow.
  • In the asset renaming step, ASSETS=$(gh release view ... --jq '.assets[].name') combined with for asset in $ASSETS; do will break if any asset names contain spaces or newlines; using jq -r with a while IFS= read -r asset loop would make this more robust.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new tag trigger pattern (`'**[0-9]+.[0-9]+.[0-9]+*'`) will not fire for tags prefixed with `v` (e.g. `v1.2.3`), which you still support elsewhere by stripping the leading `v`; if you intend to keep `v`-prefixed tags, consider adjusting the pattern (or adding a second pattern) so those tags still trigger the workflow.
- In the asset renaming step, `ASSETS=$(gh release view ... --jq '.assets[].name')` combined with `for asset in $ASSETS; do` will break if any asset names contain spaces or newlines; using `jq -r` with a `while IFS= read -r asset` loop would make this more robust.

## Individual Comments

### Comment 1
<location path=".github/workflows/package.yml" line_range="8-9" />
<code_context>
   pull_request:
-  release:
-    types: [published]
+  push:
+    tags:
+      - '**[0-9]+.[0-9]+.[0-9]+*'

</code_context>
<issue_to_address>
**issue (bug_risk):** Tag filter pattern is treated as a glob, not a regex, so `[0-9]+` will not behave as intended.

The pattern `**[0-9]+.[0-9]+.[0-9]+*` will match any tag containing the characters `0-9+`, not semantic versions like `1.2.3`. If you want to trigger on version-like tags, use something like `'*.*.*'`, or `'v*.*.*'` if tags are consistently prefixed with `v`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +8 to +9
push:
tags:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Tag filter pattern is treated as a glob, not a regex, so [0-9]+ will not behave as intended.

The pattern **[0-9]+.[0-9]+.[0-9]+* will match any tag containing the characters 0-9+, not semantic versions like 1.2.3. If you want to trigger on version-like tags, use something like '*.*.*', or 'v*.*.*' if tags are consistently prefixed with v.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant