-
Notifications
You must be signed in to change notification settings - Fork 0
Add release workflow to bump Claude plugin version #50
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
Merged
Changes from all commits
Commits
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
There are no files selected for viewing
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,74 @@ | ||
| name: Release Claude Plugin | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| bump: | ||
| description: "Version bump type" | ||
| type: choice | ||
| required: true | ||
| default: patch | ||
| options: | ||
| - patch | ||
| - minor | ||
| - major | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| release: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ssh-key: ${{ secrets.RELEASE_SSH_KEY }} | ||
|
|
||
| - name: Bump plugin version | ||
| id: bump | ||
| env: | ||
| BUMP: ${{ inputs.bump }} | ||
| run: | | ||
| set -euo pipefail | ||
| PLUGIN_FILE=".claude-plugin/plugin.json" | ||
|
|
||
| OLD_VERSION=$(jq -r '.version' "$PLUGIN_FILE") | ||
| if [ -z "$OLD_VERSION" ] || [ "$OLD_VERSION" = "null" ]; then | ||
| echo "Could not read version from $PLUGIN_FILE" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| IFS='.' read -r MAJOR MINOR PATCH <<< "$OLD_VERSION" | ||
|
|
||
| case "$BUMP" in | ||
| major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;; | ||
| minor) MINOR=$((MINOR + 1)); PATCH=0 ;; | ||
| patch) PATCH=$((PATCH + 1)) ;; | ||
| esac | ||
|
|
||
| NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}" | ||
|
|
||
| tmp=$(mktemp) | ||
| jq --arg v "$NEW_VERSION" '.version = $v' "$PLUGIN_FILE" > "$tmp" | ||
| mv "$tmp" "$PLUGIN_FILE" | ||
|
|
||
| echo "old_version=$OLD_VERSION" >> "$GITHUB_OUTPUT" | ||
| echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT" | ||
| echo "Bumped $OLD_VERSION -> $NEW_VERSION" | ||
|
|
||
| - name: Commit and tag | ||
| env: | ||
| NEW_VERSION: ${{ steps.bump.outputs.new_version }} | ||
| OLD_VERSION: ${{ steps.bump.outputs.old_version }} | ||
| run: | | ||
| set -euo pipefail | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| git add .claude-plugin/plugin.json | ||
| git commit -m "Bump version from ${OLD_VERSION} to ${NEW_VERSION}" | ||
| git tag "v${NEW_VERSION}" | ||
|
|
||
| git push origin HEAD:main | ||
| git push origin "v${NEW_VERSION}" | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opengrep —
security.gha.run-shell-injection-inputs(WARNING)A composite-action / reusable-workflow /
workflow_dispatchinputs.*value is interpolated directly into thisrun/scriptblock. Inputs are supplied by the caller, who may pass attacker-controlled data into them — e.g. a caller invoking this withversion: ${{ github.event.pull_request.head.ref }}(a fork branch name). Because the input value is substituted before the shell runs, the callee cannot trust it. Defensive fix: copy the input into a step-levelenv:entry (e.g.VERSION: ${{ inputs.version }}) and reference the quoted environment variable in the script instead (echo "$VERSION"). This is advisory (WARNING): not every input carries untrusted data, but routing inputs throughenv:makes the component safe regardless of how callers use it. If an input appears only as a condition selecting between hard-coded string literals (e.g.${{ inputs.flag && 'a' || 'b' }}), the emitted value is constant and that specific use is not exploitable — but hoist the condition into bash (set a booleanenv:var and branch withif) so therunline carries no${{ }}and the safety stays local and stable. Directly-untrustedgithub.*contexts are covered separately bysecurity.gha.run-shell-injection.Fixed in
502b127