-
Notifications
You must be signed in to change notification settings - Fork 2
178 lines (157 loc) · 6.37 KB
/
Copy pathrelease.yml
File metadata and controls
178 lines (157 loc) · 6.37 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
name: Release
on:
release:
types:
- published
permissions:
contents: write
jobs:
build:
name: Build Binaries
uses: bennypowers/go-release-workflows/.github/workflows/build-binaries.yml@main
with:
binary-name: asimonim
release-tag: ${{ github.event.release.tag_name }}
npm:
needs: build
uses: bennypowers/go-release-workflows/.github/workflows/npm-publish.yml@main
with:
binary-name: asimonim
npm-package-name: "@pwrs/asimonim"
release-tag: ${{ github.event.release.tag_name }}
pre-main-publish-script: 'cp ../README.md . && node ../scripts/update-platform-package-versions.js'
secrets:
npm-token: ${{ secrets.NPM_TOKEN }}
build-vscode:
name: Build VSCode Extension
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Download binaries from release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p extensions/vscode/dist/bin
gh release download ${{ github.event.release.tag_name }} \
--pattern "asimonim-*" \
--dir extensions/vscode/dist/bin
- name: Make binaries executable
run: chmod +x extensions/vscode/dist/bin/asimonim-*
- name: List downloaded binaries
run: ls -lh extensions/vscode/dist/bin/
- name: Build VSCode extension
working-directory: extensions/vscode
run: |
npm install
npm run build
- name: Upload VSCode extension to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for vsix in extensions/vscode/*.vsix; do
name=$(basename "$vsix")
if gh release view ${{ github.event.release.tag_name }} --json assets --jq ".assets[].name" | grep -qx "$name"; then
echo "Asset $name already exists, skipping"
else
gh release upload ${{ github.event.release.tag_name }} "$vsix"
fi
done
publish-vscode:
name: Publish to VSCode Marketplace
runs-on: ubuntu-latest
needs: [build-vscode]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Download VSCode extension from release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release download ${{ github.event.release.tag_name }} \
--pattern "*.vsix" \
--dir .
- name: Publish to VSCode Marketplace
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: |
npx @vscode/vsce publish --skip-duplicate --packagePath ./*.vsix
publish-zed:
name: Publish to Zed Extensions
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get extension version
id: version
run: |
VERSION=$(grep '^version = ' extensions/zed/extension.toml | cut -d'"' -f2)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Extension version: $VERSION"
- name: Checkout zed-extensions fork
uses: actions/checkout@v4
with:
repository: bennypowers/zed-extensions
path: zed-extensions
token: ${{ secrets.ZED_COMMITTER_TOKEN }}
- name: Sync fork with upstream
working-directory: zed-extensions
run: |
git config user.name "Benny Powers"
git config user.email "web@bennypowers.com"
# Add upstream remote and sync
git remote set-url upstream https://github.com/zed-industries/extensions.git 2>/dev/null || \
git remote add upstream https://github.com/zed-industries/extensions.git
git fetch upstream
git checkout main
git reset --hard upstream/main
git push origin main --force
- name: Update Zed Extension
id: update-zed
working-directory: zed-extensions
run: |
# Point submodule to asimonim. The upstream submodule index may have a
# commit SHA from the old dtls repo, which can't be fetched from
# asimonim. Work around by removing the submodule dir and cloning fresh.
git config --file .gitmodules submodule.extensions/design-tokens.url https://github.com/${{ github.repository }}.git
git submodule sync extensions/design-tokens
rm -rf extensions/design-tokens
git clone https://github.com/${{ github.repository }}.git extensions/design-tokens
cd extensions/design-tokens
git checkout ${{ github.event.release.tag_name }}
cd ../..
# Update version in extensions.toml for design-tokens section only
sed -i '/^\[design-tokens\]/,/^\[/ s/^version = .*/version = "${{ steps.version.outputs.version }}"/' extensions.toml
git add extensions/design-tokens extensions.toml .gitmodules
if git diff --staged --quiet; then
echo "No changes to commit — submodule already at this version"
echo "has_changes=false" >> "$GITHUB_OUTPUT"
else
echo "has_changes=true" >> "$GITHUB_OUTPUT"
BRANCH="update-design-tokens-${{ steps.version.outputs.version }}"
git checkout -B "$BRANCH"
git commit -m "Update design-tokens to v${{ steps.version.outputs.version }}"
git push -f -u origin "$BRANCH"
fi
- name: Create Pull Request
if: steps.update-zed.outputs.has_changes == 'true'
working-directory: zed-extensions
env:
GH_TOKEN: ${{ secrets.ZED_COMMITTER_TOKEN }}
run: |
BRANCH="update-design-tokens-${{ steps.version.outputs.version }}"
# Check if PR already exists
existing_pr=$(gh pr list --repo zed-industries/extensions --head "bennypowers:$BRANCH" --json number --jq '.[0].number')
if [ -n "$existing_pr" ]; then
echo "PR #$existing_pr already exists for branch $BRANCH"
exit 0
fi
gh pr create \
--repo zed-industries/extensions \
--title "Update design-tokens to v${{ steps.version.outputs.version }}" \
--body "Updates design-tokens extension to [version ${{ steps.version.outputs.version }}](https://github.com/${{ github.repository }}/releases/tag/v${{ steps.version.outputs.version }})."