|
| 1 | +name: Release Claude artifacts |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: release-claude-artifacts |
| 10 | + cancel-in-progress: false |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + release: |
| 17 | + name: Tag and release on version bump |
| 18 | + runs-on: ubuntu-24.04 |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v5 |
| 21 | + |
| 22 | + - name: Read plugin version |
| 23 | + id: version |
| 24 | + shell: bash |
| 25 | + run: | |
| 26 | + set -euo pipefail |
| 27 | + VERSION=$(jq -r .version claude/plugins/pywry/.claude-plugin/plugin.json) |
| 28 | + echo "value=$VERSION" >> "$GITHUB_OUTPUT" |
| 29 | + echo "tag=claude-pywry-v$VERSION" >> "$GITHUB_OUTPUT" |
| 30 | + echo "Plugin version: $VERSION" |
| 31 | +
|
| 32 | + - name: Skip if tag already exists |
| 33 | + id: tag_check |
| 34 | + env: |
| 35 | + TAG: ${{ steps.version.outputs.tag }} |
| 36 | + shell: bash |
| 37 | + run: | |
| 38 | + set -euo pipefail |
| 39 | + if git ls-remote --tags origin "refs/tags/$TAG" | grep -q "refs/tags/$TAG"; then |
| 40 | + echo "Tag $TAG already published — nothing to release." |
| 41 | + echo "exists=true" >> "$GITHUB_OUTPUT" |
| 42 | + else |
| 43 | + echo "Tag $TAG missing — will build and release." |
| 44 | + echo "exists=false" >> "$GITHUB_OUTPUT" |
| 45 | + fi |
| 46 | +
|
| 47 | + - name: Set up Python |
| 48 | + if: steps.tag_check.outputs.exists == 'false' |
| 49 | + uses: actions/setup-python@v6 |
| 50 | + with: |
| 51 | + python-version: '3.12' |
| 52 | + |
| 53 | + - name: Build distributions (enforces version sync across all three manifests) |
| 54 | + if: steps.tag_check.outputs.exists == 'false' |
| 55 | + run: python claude/scripts/build_distributions.py |
| 56 | + |
| 57 | + - name: Extract changelog section |
| 58 | + id: notes |
| 59 | + if: steps.tag_check.outputs.exists == 'false' |
| 60 | + env: |
| 61 | + VERSION: ${{ steps.version.outputs.value }} |
| 62 | + shell: bash |
| 63 | + run: | |
| 64 | + set -euo pipefail |
| 65 | + NOTES_FILE="$RUNNER_TEMP/release-notes.md" |
| 66 | + python3 - "$VERSION" > "$NOTES_FILE" <<'PY' |
| 67 | + import re |
| 68 | + import sys |
| 69 | +
|
| 70 | + version = sys.argv[1] |
| 71 | + text = open("claude/plugins/pywry/CHANGELOG.md", encoding="utf-8").read() |
| 72 | + # Match either "## 1.2.3" or "## [1.2.3]" headings |
| 73 | + pattern = re.compile( |
| 74 | + rf"^## \[?{re.escape(version)}\]?[^\n]*\n(.*?)(?=^## |\Z)", |
| 75 | + re.MULTILINE | re.DOTALL, |
| 76 | + ) |
| 77 | + m = pattern.search(text) |
| 78 | + if m: |
| 79 | + print(m.group(1).strip()) |
| 80 | + else: |
| 81 | + print("See [CHANGELOG.md](claude/plugins/pywry/CHANGELOG.md) for details.") |
| 82 | + PY |
| 83 | + echo "file=$NOTES_FILE" >> "$GITHUB_OUTPUT" |
| 84 | +
|
| 85 | + - name: Configure git identity |
| 86 | + if: steps.tag_check.outputs.exists == 'false' |
| 87 | + shell: bash |
| 88 | + run: | |
| 89 | + git config user.name "github-actions[bot]" |
| 90 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 91 | +
|
| 92 | + - name: Tag and create GitHub release |
| 93 | + if: steps.tag_check.outputs.exists == 'false' |
| 94 | + env: |
| 95 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 96 | + TAG: ${{ steps.version.outputs.tag }} |
| 97 | + VERSION: ${{ steps.version.outputs.value }} |
| 98 | + NOTES_FILE: ${{ steps.notes.outputs.file }} |
| 99 | + shell: bash |
| 100 | + run: | |
| 101 | + set -euo pipefail |
| 102 | + git tag -a "$TAG" -m "pywry plugin v$VERSION" "$GITHUB_SHA" |
| 103 | + git push origin "$TAG" |
| 104 | + gh release create "$TAG" \ |
| 105 | + --title "pywry plugin v$VERSION" \ |
| 106 | + --notes-file "$NOTES_FILE" \ |
| 107 | + claude/dist/pywry-cowork.plugin \ |
| 108 | + claude/dist/pywry.mcpb |
0 commit comments