-
Notifications
You must be signed in to change notification settings - Fork 0
192 lines (169 loc) · 6.35 KB
/
Copy pathrelease.yml
File metadata and controls
192 lines (169 loc) · 6.35 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
name: Release
on:
push:
branches: [main]
jobs:
tag-and-release:
name: Tag and create GitHub release
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
is_release: ${{ steps.tag-check.outputs.is_release }}
tag: ${{ steps.version.outputs.tag }}
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Read version from package.json
id: version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
echo "Version on main: $VERSION"
- name: Check if tag already exists (idempotency)
id: tag-check
run: |
if git rev-parse "${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then
echo "Tag ${{ steps.version.outputs.tag }} already exists — skipping release."
echo "is_release=false" >> "$GITHUB_OUTPUT"
else
echo "is_release=true" >> "$GITHUB_OUTPUT"
fi
- name: Build release notes
if: steps.tag-check.outputs.is_release == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_BODY=$(gh pr list \
--state merged \
--base main \
--limit 1 \
--json body \
--jq '.[0].body // ""')
if [ -n "$PR_BODY" ] && ! echo "$PR_BODY" | grep -q "Replace this paragraph"; then
echo "Using release PR body for notes."
printf '%s\n' "$PR_BODY" > /tmp/release-notes.md
else
echo "Falling back to auto-generated notes."
PREVIOUS_TAG=$(git tag --sort=-creatordate \
| grep -v "^${{ steps.version.outputs.tag }}$" \
| head -n1)
if [ -n "$PREVIOUS_TAG" ]; then
gh api "repos/${{ github.repository }}/releases/generate-notes" \
-f tag_name="${{ steps.version.outputs.tag }}" \
-f previous_tag_name="$PREVIOUS_TAG" \
--jq '.body' > /tmp/release-notes.md
else
gh api "repos/${{ github.repository }}/releases/generate-notes" \
-f tag_name="${{ steps.version.outputs.tag }}" \
--jq '.body' > /tmp/release-notes.md
fi
fi
echo "--- Release notes preview ---"
cat /tmp/release-notes.md
echo "--- end preview ---"
- name: Create GitHub release
if: steps.tag-check.outputs.is_release == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ steps.version.outputs.tag }}" \
--title "Synthpunk ${{ steps.version.outputs.tag }}" \
--notes-file /tmp/release-notes.md
build-artifacts:
name: Build and upload release artifacts
needs: tag-and-release
if: needs.tag-and-release.outputs.is_release == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.tag-and-release.outputs.tag }}
- uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build themes
run: bun run build
- name: Run tests
run: bun test --pass-with-no-tests
- name: Upload Group 2 files to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ needs.tag-and-release.outputs.tag }}
run: |
gh release upload "$TAG" \
themes/starship/starship.toml \
themes/wezterm/synthpunk-pastel-dark.toml \
themes/wezterm/synthpunk-pastel-light.toml \
themes/wezterm/synthpunk-neon-dark.toml \
themes/wezterm/synthpunk-neon-light.toml
- name: Build VS Code VSIX
run: |
cd themes/vscode
npx --yes @vscode/vsce package -o "../../synthpunk-${{ needs.tag-and-release.outputs.tag }}.vsix"
- name: Upload VSIX as workflow artifact
uses: actions/upload-artifact@v4
with:
name: synthpunk-vsix
path: synthpunk-${{ needs.tag-and-release.outputs.tag }}.vsix
publish-vscode:
name: Publish to VS Code Marketplace
needs: build-artifacts
if: vars.PUBLISH_VSCODE == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: synthpunk-vsix
- name: Publish to VS Code Marketplace
run: npx --yes @vscode/vsce publish --package-path synthpunk-*.vsix -p ${{ secrets.VS_MARKETPLACE_TOKEN }}
publish-openvsx:
name: Publish to OpenVSX
needs: build-artifacts
if: vars.PUBLISH_OPENVSX == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: synthpunk-vsix
- name: Publish to OpenVSX
run: npx --yes ovsx publish synthpunk-*.vsix -p ${{ secrets.OVSX_TOKEN }}
publish-neovim:
name: Publish to synthpunk.nvim repo
needs: [build-artifacts, tag-and-release]
if: vars.PUBLISH_NVIM == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.tag-and-release.outputs.tag }}
fetch-depth: 0
- name: Clone synthpunk.nvim
env:
SSH_DEPLOY_KEY: ${{ secrets.SYNTHPUNK_NVIM_DEPLOY_KEY }}
run: |
mkdir -p ~/.ssh
echo "$SSH_DEPLOY_KEY" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
ssh-keyscan github.com >> ~/.ssh/known_hosts
GIT_SSH_COMMAND="ssh -i ~/.ssh/deploy_key" git clone git@github.com:slowdini/synthpunk.nvim.git /tmp/synthpunk.nvim
- name: Copy neovim files and push
env:
TAG: ${{ needs.tag-and-release.outputs.tag }}
GIT_SSH_COMMAND: ssh -i ~/.ssh/deploy_key
run: |
cd /tmp/synthpunk.nvim
find . -maxdepth 1 -not -name '.git' -not -name '.' -exec rm -rf {} +
cp -r "$GITHUB_WORKSPACE/themes/neovim/"* .
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "chore: release $TAG"
git tag "$TAG"
git push origin main
git push origin "$TAG"