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