ci: migrate from release events to tag push triggers - #24
Conversation
- 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
Reviewer's GuideMigrates 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 retrysequenceDiagram
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
Sequence diagram for rename-release-assets job waiting for cargo-dist artifacts and renaming assetssequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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 withv(e.g.v1.2.3), which you still support elsewhere by stripping the leadingv; if you intend to keepv-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 withfor asset in $ASSETS; dowill break if any asset names contain spaces or newlines; usingjq -rwith awhile IFS= read -r assetloop 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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| push: | ||
| tags: |
There was a problem hiding this comment.
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.
Summary by Sourcery
Migrate the packaging workflow from GitHub release events to tag-based triggers and improve robustness of release asset handling.
Build:
CI: