Skip to content

Commit d02b4cc

Browse files
fhammerschmidtzth
authored andcommitted
CI: Enable automatic release on tag push
1 parent 353dedb commit d02b4cc

File tree

1 file changed

+33
-11
lines changed

1 file changed

+33
-11
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: CI
33
on:
44
push:
55
branches: [ master ]
6+
tags: "*.*.*"
67
pull_request:
78
branches: [ master ]
89

@@ -137,28 +138,30 @@ jobs:
137138
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
138139
run: echo "::set-output name=sha_short::${COMMIT_SHA:0:7}"
139140

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/*/}
147145

148146
- name: Increment pre-release version
149147
if: github.ref == 'refs/heads/master'
150148
id: increment_pre_release
151149
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"]')
153152
node .github/workflows/bump-version.js ${NEW_VERSION}
154153
155154
- name: Package Extension
156155
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
158157

159-
- name: Package Extension
158+
- name: Package Extension pre-release version
160159
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
162165

163166
- uses: actions/upload-artifact@v2
164167
if: github.ref != 'refs/heads/master'
@@ -171,6 +174,12 @@ jobs:
171174
with:
172175
name: rescript-vscode-${{ steps.increment_pre_release.outputs.new_version }}.vsix
173176
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
174183

175184
- name: Publish latest master to GitHub
176185
if: github.ref == 'refs/heads/master'
@@ -182,6 +191,19 @@ jobs:
182191
title: "Latest master"
183192
files: rescript-vscode-${{ steps.increment_pre_release.outputs.new_version }}.vsix
184193

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+
185203
- name: Publish extension as pre-release
186204
if: github.ref == 'refs/heads/master'
187205
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

Comments
 (0)