Skip to content

Source Tag Fixes

Source Tag Fixes #7

Workflow file for this run

name: Release
on:
pull_request:
types: [closed]
branches: [main]
jobs:
release:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Determine bump type
id: bump
run: |
LABELS='${{ toJSON(github.event.pull_request.labels.*.name) }}'
if echo "$LABELS" | grep -q 'bump:major'; then
echo "type=major" >> $GITHUB_OUTPUT
elif echo "$LABELS" | grep -q 'bump:minor'; then
echo "type=minor" >> $GITHUB_OUTPUT
else
echo "type=patch" >> $GITHUB_OUTPUT
fi
- name: Bump version
id: version
run: |
CURRENT=$(jq -r '.version' .claude-plugin/plugin.json)
MAJOR=$(echo $CURRENT | cut -d. -f1)
MINOR=$(echo $CURRENT | cut -d. -f2)
PATCH=$(echo $CURRENT | cut -d. -f3)
BUMP_TYPE="${{ steps.bump.outputs.type }}"
if [ "$BUMP_TYPE" = "major" ]; then
NEW_VERSION="$((MAJOR+1)).0.0"
elif [ "$BUMP_TYPE" = "minor" ]; then
NEW_VERSION="${MAJOR}.$((MINOR+1)).0"
else
NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH+1))"
fi
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
jq --arg v "$NEW_VERSION" '.version = $v' .claude-plugin/plugin.json > tmp.json && mv tmp.json .claude-plugin/plugin.json
- name: Update changelog
env:
NEW_VERSION: ${{ steps.version.outputs.new_version }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GH_TOKEN: ${{ github.token }}
run: |
DATE=$(date +%Y-%m-%d)
HEADER="## [$NEW_VERSION] - $DATE"
# Generate changelog bullets from commit messages in the PR
BULLETS=$(gh pr view "$PR_NUMBER" --json commits --jq '.commits[].messageHeadline' | grep -v '^chore:' | grep -v '^\[create-pull-request\]' | sed 's/^/- /')
if [ -z "$BULLETS" ]; then
BULLETS="- ${{ github.event.pull_request.title }}"
fi
# Build the new changelog entry
ENTRY=$(printf '%s\n%s\n' "$HEADER" "$BULLETS")
# Insert after the "# Changelog" header line
if grep -q '^# Changelog' CHANGELOG.md; then
awk -v entry="$ENTRY" '/^# Changelog/{print; print ""; print entry; next}1' CHANGELOG.md > tmp_changelog.md && mv tmp_changelog.md CHANGELOG.md
else
# No header found — prepend entry to file
printf '%s\n\n%s' "$ENTRY" "$(cat CHANGELOG.md)" > CHANGELOG.md
fi
- name: Commit and tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git rm -r --ignore-unmatch test-marketplace
git add .claude-plugin/plugin.json CHANGELOG.md
git commit -m "release: bump version to v${{ steps.version.outputs.new_version }}"
git tag "v${{ steps.version.outputs.new_version }}"
git push origin main
git push origin "v${{ steps.version.outputs.new_version }}"
- name: Create GitHub release
run: |
gh release create "v${{ steps.version.outputs.new_version }}" \
--title "Release v${{ steps.version.outputs.new_version }}" \
--generate-notes
env:
GH_TOKEN: ${{ github.token }}