-
Notifications
You must be signed in to change notification settings - Fork 17
222 lines (194 loc) · 8.8 KB
/
package-skill.yml
File metadata and controls
222 lines (194 loc) · 8.8 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# ABOUTME: Packages the skill on every push to main (as a ZIP artifact) and, if the version in SKILL.md
# ABOUTME: has been bumped, creates a GitHub Release and syncs the skill contents to three plugin repos
# ABOUTME: (cursor-temporal-plugin, codex-temporal-plugin, claude-temporal-plugin) via PRs.
# ABOUTME: Required secrets (used only by the sync job for cross-repo PRs):
# ABOUTME: SKILL_T_DEV_APP_ID — the GitHub App's ID
# ABOUTME: SKILL_T_DEV_KEY — the GitHub App's private key
# ABOUTME: The app must be installed on the three plugin repos with Contents (write) and Pull Requests (write).
name: Package and Sync Skill
on:
push:
branches: [main]
workflow_dispatch:
jobs:
package:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
released: ${{ steps.tag_check.outputs.exists == 'false' }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Read version from SKILL.md
id: version
run: |
version=$(grep '^version:' SKILL.md | sed 's/version:[[:space:]]*//')
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "tag=v$version" >> "$GITHUB_OUTPUT"
- name: Check if tag exists
id: tag_check
run: |
if git rev-parse "refs/tags/${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Package skill
run: |
zip -r temporal-developer-skill.zip \
SKILL.md \
references/ \
-x '*.DS_Store'
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: temporal-developer-skill
path: temporal-developer-skill.zip
- name: Create release
if: steps.tag_check.outputs.exists == 'false'
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.tag }}
files: temporal-developer-skill.zip
generate_release_notes: true
sync:
needs: package
if: needs.package.outputs.released == 'true' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
# contents: write is required by the POST /releases/generate-notes endpoint,
# even though it only returns text and doesn't actually write anything.
contents: write
strategy:
fail-fast: false
matrix:
include:
- repo: temporalio/cursor-temporal-plugin
target_path: skills/temporal-developer
- repo: temporalio/codex-temporal-plugin
target_path: plugins/temporal-developer/skills/temporal-developer
- repo: temporalio/claude-temporal-plugin
target_path: skills/temporal-developer
steps:
- name: Generate token from GitHub App
id: app-token
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.SKILL_T_DEV_APP_ID }}
private-key: ${{ secrets.SKILL_T_DEV_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout source
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Checkout target repo
uses: actions/checkout@v6
with:
repository: ${{ matrix.repo }}
token: ${{ steps.app-token.outputs.token }}
path: target-repo
- name: Sync skill contents
working-directory: target-repo
run: |
BRANCH="sync/temporal-developer-skill"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Create or reset the sync branch based on current main.
# -B ensures the branch always starts from main's tip, even if a
# stale remote branch exists from a previously merged PR.
git checkout -B "$BRANCH" origin/main
# Remove old contents and copy current
rm -rf "${{ matrix.target_path }}/SKILL.md" \
"${{ matrix.target_path }}/references"
cp ../SKILL.md "${{ matrix.target_path }}/"
cp -r ../references "${{ matrix.target_path }}/"
# Check for changes against main
git add "${{ matrix.target_path }}"
if git diff --cached --quiet; then
echo "no_changes=true" >> "$GITHUB_ENV"
echo "No changes to sync"
else
echo "no_changes=false" >> "$GITHUB_ENV"
version="${{ needs.package.outputs.tag }}"
git commit -m "sync temporal-developer skill ${version} from source repo"
git push --force origin "$BRANCH"
fi
- name: Build changelog
if: env.no_changes == 'false'
env:
GH_TOKEN: ${{ github.token }}
run: |
current_tag="${{ needs.package.outputs.tag }}"
# Determine the base for the changelog: the version currently on the
# target repo's main branch. This represents what was last merged, so
# the changelog spans every release since then — correctly accumulating
# unmerged versions if a prior sync PR is still open.
#
# Read the old SKILL.md from git (it's been overwritten on disk by the
# sync step) via `git show origin/main:...`.
target_version=$(git -C target-repo show "origin/main:${{ matrix.target_path }}/SKILL.md" 2>/dev/null \
| grep '^version:' | sed 's/version:[[:space:]]*//' || echo "")
if [ -n "$target_version" ]; then
base_tag="v${target_version}"
else
base_tag=""
fi
# Prefer GitHub's auto-generated notes for the range (nicely formatted
# with PR links and contributors). Fall back to git log if unavailable.
echo "Base tag: ${base_tag:-<none>} / Current tag: ${current_tag}"
if [ -n "$base_tag" ]; then
if notes=$(gh api \
--method POST \
"/repos/${{ github.repository }}/releases/generate-notes" \
-f tag_name="${current_tag}" \
-f previous_tag_name="${base_tag}" \
--jq '.body') && [ -n "$notes" ]; then
echo "Using auto-generated release notes"
echo "$notes" > /tmp/changelog.md
else
echo "generate-notes API call failed or empty; falling back to git log"
git log --oneline "${base_tag}..HEAD" > /tmp/changelog.md
fi
else
echo "No base tag found; using last 20 commits"
git log --oneline -20 > /tmp/changelog.md
fi
- name: Create or update PR
if: env.no_changes == 'false'
working-directory: target-repo
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
BRANCH="sync/temporal-developer-skill"
version="${{ needs.package.outputs.tag }}"
changelog=$(cat /tmp/changelog.md)
# Check if a PR already exists from this branch
existing_pr=$(gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number')
if [ -n "$existing_pr" ]; then
echo "PR #${existing_pr} already exists — updated by the force-push"
gh pr edit "$existing_pr" \
--title "Sync temporal-developer skill ${version}" \
--body "Automated sync of the temporal-developer skill ${version} from [skill-temporal-developer](https://github.com/${{ github.repository }}).
This PR was updated automatically by the [sync workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).
## Changelog
${changelog}"
gh pr comment "$existing_pr" --body "Updated to ${version} from [skill-temporal-developer](https://github.com/${{ github.repository }})."
pr_url=$(gh pr view "$existing_pr" --json url --jq '.url')
echo "### ${{ matrix.repo }}" >> "$GITHUB_STEP_SUMMARY"
echo "Updated [PR #${existing_pr}](${pr_url})" >> "$GITHUB_STEP_SUMMARY"
else
pr_url=$(gh pr create \
--title "Sync temporal-developer skill ${version}" \
--body "Automated sync of the temporal-developer skill ${version} from [skill-temporal-developer](https://github.com/${{ github.repository }}).
This PR was created automatically by the [sync workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).
## Changelog
${changelog}")
echo "### ${{ matrix.repo }}" >> "$GITHUB_STEP_SUMMARY"
echo "Created ${pr_url}" >> "$GITHUB_STEP_SUMMARY"
fi