-
-
Notifications
You must be signed in to change notification settings - Fork 0
219 lines (188 loc) · 6.59 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
name: CI
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
branches:
- master
jobs:
checkout:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '17'
- name: Install dependencies
run: npm install
- name: Cache Clojure dependencies
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-clojure-${{ hashFiles('**/deps.edn') }}
restore-keys: |
${{ runner.os }}-clojure-
- name: Install Clojure
uses: DeLaGuardo/setup-clojure@12.1
with:
tools-deps: '1.10.3.943'
- name: Install CLJS dependencies
run: npx shadow-cljs classpath
- name: Create build workspace
run: mkdir -p /tmp/build
- name: Copy build
run: cp -r . /tmp/build
build:
runs-on: ubuntu-latest
needs: checkout
steps:
- name: Attach workspace
run: cp -r /tmp/build $GITHUB_WORKSPACE
- name: Tamper 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: Store artifacts
uses: actions/upload-artifact@v3
with:
name: artifacts
path: /tmp/artifacts
github-release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Restore build
run: cp -r /tmp/build $GITHUB_WORKSPACE
- name: Publish Release on GitHub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
EXTRA_RELEASE_OPTIONS=""
if [[ "${GITHUB_REF}" =~ ^refs/tags/v([0-9]+\.[0-9]+\.[0-9]+)$ ]]
then
echo "Publishing GitHub Release: ${GITHUB_REF}"
else
echo "Publishing GitHub Prerelease: ${GITHUB_REF}"
EXTRA_RELEASE_OPTIONS=-prerelease
fi
[[ "${GITHUB_REF}" =~ ^refs/tags/v([0-9]+\.[0-9]+\.[0-9]+) ]]
TAG_VERSION=${BASH_REMATCH[1]}
BODY=$(awk '/^## \['${TAG_VERSION}'\]/, started && /^##/ { started=1; if ($0 !~ /(^#|^\s*$)/) { gsub(/["$]/, "\\\\&"); print } }' CHANGELOG.md)
echo Changes: "\n" $BODY
gh release create ${GITHUB_REF} /tmp/artifacts/*.vsix --notes "${BODY}" ${EXTRA_RELEASE_OPTIONS}
marketplace-publish:
runs-on: ubuntu-latest
needs: github-release
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Restore build
run: cp -r /tmp/build $GITHUB_WORKSPACE
- name: Publish to the marketplace
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
run: |
VSCE_CMD="vsce publish --packagePath /tmp/artifacts/paste-replaced-$(node -p 'require("./package.json").version').vsix -p ${PUBLISH_TOKEN}"
npx ${VSCE_CMD}
marketplace-preview-publish:
runs-on: ubuntu-latest
needs: github-release
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Restore build
run: cp -r /tmp/build $GITHUB_WORKSPACE
- name: Publish to the marketplace
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
run: |
VSCE_CMD="vsce publish --pre-release --packagePath /tmp/artifacts/paste-replaced-$(node -p 'require("./package.json").version').vsix -p ${PUBLISH_TOKEN}"
npx ${VSCE_CMD}
open-vsx-publish:
runs-on: ubuntu-latest
needs: github-release
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Restore build
run: cp -r /tmp/build $GITHUB_WORKSPACE
- name: Publish to Open VSX
env:
OVSX_PUBLISH_TOKEN: ${{ secrets.OVSX_PUBLISH_TOKEN }}
run: |
OVSX_CMD="ovsx publish /tmp/artifacts/paste-replaced-$(node -p 'require("./package.json").version').vsix --pat ${OVSX_PUBLISH_TOKEN}"
npx ${OVSX_CMD}
bump-version:
runs-on: ubuntu-latest
needs: marketplace-publish
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Configure git
run: |
git config --global user.email ${{ secrets.GITHUB_USER_EMAIL }}
git config --global user.name ${{ secrets.GITHUB_USER_NAME }}
- name: Bump dev version
run: |
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