-
-
Notifications
You must be signed in to change notification settings - Fork 0
238 lines (205 loc) · 7.03 KB
/
main.yml
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
name: build-test
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
branches:
- master
jobs:
checkout:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
- name: Restore dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Install dependencies
run: npm install
- name: Create build workspace
run: mkdir -p /tmp/build
- name: Copy build
run: cp -r . /tmp/build
- name: Save dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
build:
runs-on: ubuntu-latest
needs: checkout
steps:
- name: Attach workspace
run: cp -r /tmp/build .
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
- name: Install clojure tools
uses: DeLaGuardo/setup-clojure@12.1
with:
cli: latest
bb: latest
- name: Install CLJS dependencies
run: npx shadow-cljs classpath
- name: Create artifacts workspace
run: mkdir -p /tmp/artifacts
- name: Tamper paste-replaced version if not release versioned
run: |
VERSION=$(node -p 'require("./package.json").version')
TAG_VERSION=NO-TAG
if [[ "${GITHUB_REF}" =~ ^refs/tags/v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
TAG_VERSION=${BASH_REMATCH[1]}
echo 'No version tampering because this is a release tag'
else
COMMIT=${GITHUB_SHA:0:8}
if [[ "${GITHUB_REF}" =~ ^refs/tags/v([0-9]+\.[0-9]+\.[0-9]+)-(.*) ]]; then
TAG_VERSION=${BASH_REMATCH[1]}
TAG_TITLE=${BASH_REMATCH[2]}
PRERELEASE=${TAG_TITLE}-${COMMIT}
else
BRANCH=${GITHUB_REF_NAME//[^[:alnum:]]/-}
PRERELEASE=${BRANCH}-${COMMIT}
fi
echo "Append prerelease to version: -${PRERELEASE}"
npx json -I -f package.json -e 'this.version=this.version.replace(/$/,"-'${PRERELEASE}'")'
fi
if [ ${TAG_VERSION} = NO-TAG -o "${TAG_VERSION}" = "${VERSION}" ]; then
VERSION=$(node -p 'require("./package.json").version')
echo "Using version: ${VERSION}"
else
echo >&2 "FATAL! Version mismatch between package.json and tag. Aborting."
exit 1
fi
- name: Package vsix
run: |
if [[ "${GITHUB_REF}" =~ ^refs/tags/v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
echo "Packaging as release"
PACKAGE_CMD="vsce package --allow-star-activation --githubBranch master"
else
echo "Packaging as pre-release"
PACKAGE_CMD="vsce package --allow-star-activation --pre-release"
fi
npx ${PACKAGE_CMD}
- name: Copy vsix
run: cp *.vsix /tmp/artifacts/
- name: Copy build
run: |
cp -r out /tmp/build
cp package.json /tmp/build
- name: Save dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Store artifacts
uses: actions/upload-artifact@v2
with:
name: artifacts
path: /tmp/artifacts
github-release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Attach workspace
run: cp -r /tmp/build .
- name: Determine if prerelease
id: prerelease_check
run: |
if [[ "${GITHUB_REF}" =~ ^refs/tags/v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
echo "::set-output name=prerelease::false"
else
echo "::set-output name=prerelease::true"
fi
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Changes:
$(awk '/^## \['${{ github.ref }}'\]/, started && /^##/ { started=1; if ($0 !~ /(^#|^\s*$)/) { gsub(/["$]/, "\\\\&"); print } }' CHANGELOG.md)
draft: false
prerelease: ${{ steps.prerelease_check.outputs.prerelease }}
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: /tmp/artifacts/paste-replaced-$(node -p 'require("./package.json").version').vsix
asset_name: paste-replaced-$(node -p 'require("./package.json").version').vsix
asset_content_type: application/octet-stream
marketplace-publish:
runs-on: ubuntu-latest
needs: github-release
steps:
- name: Attach workspace
run: cp -r /tmp/build .
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
- name: Publish to the marketplace
run: |
VSCE_CMD="vsce publish --packagePath /tmp/artifacts/paste-replaced-$(node -p 'require("./package.json").version').vsix -p ${PUBLISH_TOKEN}"
if [ "${IS_LOCAL}" = YES ]; then
echo "Dry npx ${VSCE_CMD}"
else
npx ${VSCE_CMD}
open-vsx-publish:
runs-on: ubuntu-latest
needs: github-release
steps:
- name: Attach workspace
run: cp -r /tmp/build .
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
- name: Publish to Open VSX
run: |
OVSX_CMD="ovsx publish /tmp/artifacts/paste-replaced-$(node -p 'require("./package.json").version').vsix --pat ${OVSX_PUBLISH_TOKEN}"
if [ "${IS_LOCAL}" = YES ]; then
echo "Dry npx ${OVSX_CMD}"
else
npx ${OVSX_CMD}
bump-version:
runs-on: ubuntu-latest
needs: marketplace-publish
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
- name: Bump dev version
run: |
git config --global user.email $GITHUB_USER_EMAIL
git config --global user.name $GITHUB_USER_NAME
git checkout master
npm set git-tag-version false && npm version patch
git add .
git commit -m "Bring on version $(node -p 'require('./package').version')!"
git push origin HEAD