3
3
on :
4
4
push :
5
5
branches : [ master ]
6
+ tags : " *.*.*"
6
7
pull_request :
7
8
branches : [ master ]
8
9
@@ -137,28 +138,30 @@ jobs:
137
138
COMMIT_SHA : ${{ github.event.pull_request.head.sha || github.sha }}
138
139
run : echo "::set-output name=sha_short::${COMMIT_SHA:0:7}"
139
140
140
- - name : Get current pre-release version
141
- if : github.ref == 'refs/heads/master'
142
- id : get_pre_release
143
- run : |
144
- JSON=$(npx vsce show chenglou92.rescript-vscode --json)
145
- VERSION=$(echo $JSON | jq '.versions | .[0] | .["version"]')
146
- echo "::set-output name=current_version::${VERSION}"
141
+ - name : Store tag name
142
+ id : tag_name
143
+ if : startsWith(github.ref, 'refs/tags/')
144
+ run : echo ::set-output name=tag::${GITHUB_REF#refs/*/}
147
145
148
146
- name : Increment pre-release version
149
147
if : github.ref == 'refs/heads/master'
150
148
id : increment_pre_release
151
149
run : |
152
- NEW_VERSION=$(echo ${{ steps.get_pre_release.outputs.current_version }})
150
+ JSON=$(npx vsce show chenglou92.rescript-vscode --json)
151
+ NEW_VERSION=$(echo $JSON | jq '.versions | .[0] | .["version"]')
153
152
node .github/workflows/bump-version.js ${NEW_VERSION}
154
153
155
154
- name : Package Extension
156
155
if : github.ref != 'refs/heads/master'
157
- run : npx vsce package -o rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix
156
+ run : npx vsce package -o rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix
158
157
159
- - name : Package Extension
158
+ - name : Package Extension pre-release version
160
159
if : github.ref == 'refs/heads/master'
161
- run : npx vsce package -o rescript-vscode-${{ steps.increment_pre_release.outputs.new_version }}.vsix ${{ steps.increment_pre_release.outputs.new_version }} --no-git-tag-version
160
+ run : npx vsce package -o rescript-vscode-${{ steps.increment_pre_release.outputs.new_version }}.vsix ${{ steps.increment_pre_release.outputs.new_version }} --no-git-tag-version
161
+
162
+ - name : Package Extension release version
163
+ if : startsWith(github.ref, 'refs/tags/')
164
+ run : npx vsce package -o rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix ${{ steps.tag_name.outputs.tag }} --no-git-tag-version
162
165
163
166
- uses : actions/upload-artifact@v2
164
167
if : github.ref != 'refs/heads/master'
@@ -171,6 +174,12 @@ jobs:
171
174
with :
172
175
name : rescript-vscode-${{ steps.increment_pre_release.outputs.new_version }}.vsix
173
176
path : rescript-vscode-${{ steps.increment_pre_release.outputs.new_version }}.vsix
177
+
178
+ - uses : actions/upload-artifact@v2
179
+ if : startsWith(github.ref, 'refs/tags/')
180
+ with :
181
+ name : rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix
182
+ path : rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix
174
183
175
184
- name : Publish latest master to GitHub
176
185
if : github.ref == 'refs/heads/master'
@@ -182,6 +191,19 @@ jobs:
182
191
title : " Latest master"
183
192
files : rescript-vscode-${{ steps.increment_pre_release.outputs.new_version }}.vsix
184
193
194
+ - name : Publish release version to GitHub
195
+ if : startsWith(github.ref, 'refs/tags/')
196
+ uses : marvinpinto/action-automatic-releases@latest
197
+ with :
198
+ repo_token : " ${{ secrets.GITHUB_TOKEN }}"
199
+ prerelease : false
200
+ title : ${{ steps.tag_name.outputs.tag }}
201
+ files : rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix
202
+
185
203
- name : Publish extension as pre-release
186
204
if : github.ref == 'refs/heads/master'
187
205
run : npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --pre-release ${{ steps.increment_pre_release.outputs.new_version }} --no-git-tag-version
206
+
207
+ - name : Publish extension as release
208
+ if : startsWith(github.ref, 'refs/tags/')
209
+ run : npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} ${{ steps.tag_name.outputs.tag }} --no-git-tag-version
0 commit comments