-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (61 loc) · 2.05 KB
/
Copy pathrelease.yml
File metadata and controls
74 lines (61 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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}"