Skip to content

Commit a8294ab

Browse files
CI: Enable automatic release on tag push
1 parent 85259ed commit a8294ab

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

@@ -127,28 +128,30 @@ jobs:
127128
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
128129
run: echo "::set-output name=sha_short::${COMMIT_SHA:0:7}"
129130

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

138136
- name: Increment pre-release version
139137
if: github.ref == 'refs/heads/master'
140138
id: increment_pre_release
141139
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"]')
143142
node .github/workflows/bump-version.js ${NEW_VERSION}
144143
145144
- name: Package Extension
146145
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
148147

149-
- name: Package Extension
148+
- name: Package Extension pre-release version
150149
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
152155

153156
- uses: actions/upload-artifact@v2
154157
if: github.ref != 'refs/heads/master'
@@ -161,6 +164,12 @@ jobs:
161164
with:
162165
name: rescript-vscode-${{ steps.increment_pre_release.outputs.new_version }}.vsix
163166
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
164173

165174
- name: Publish latest master to GitHub
166175
if: github.ref == 'refs/heads/master'
@@ -172,6 +181,19 @@ jobs:
172181
title: "Latest master"
173182
files: rescript-vscode-${{ steps.increment_pre_release.outputs.new_version }}.vsix
174183

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

Comments
 (0)