@@ -81,18 +81,18 @@ jobs:
8181 package :
8282 needs : test
8383 runs-on : ubuntu-18.04
84-
84+
8585 steps :
8686 - uses : actions/checkout@v2.3.4
87-
87+
8888 - name : Use Node.js
8989 uses : actions/setup-node@v2.1.5
9090 with :
9191 node-version : 14.4.0
9292
9393 - run : npm ci
9494 - run : npm run compile
95-
95+
9696 - name : Download MacOS binary
9797 uses : actions/download-artifact@v3.0.0
9898 with :
@@ -126,11 +126,52 @@ jobs:
126126 env :
127127 COMMIT_SHA : ${{ github.event.pull_request.head.sha || github.sha }}
128128 run : echo "::set-output name=sha_short::${COMMIT_SHA:0:7}"
129-
129+
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}"
137+
138+ - name : Increment pre-release version
139+ if : github.ref == 'refs/heads/master'
140+ id : increment_pre_release
141+ run : |
142+ NEW_VERSION=$(echo ${{ steps.get_pre_release.outputs.current_version }})
143+ node .github/workflows/bump-version.js ${NEW_VERSION}
144+
130145 - name : Package Extension
131- run : npx vsce package -o rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix
132-
146+ if : github.ref != 'refs/heads/master'
147+ run : npx vsce package -o rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix
148+
149+ - name : Package Extension
150+ 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
152+
133153 - uses : actions/upload-artifact@v2
154+ if : github.ref != 'refs/heads/master'
134155 with :
135156 name : rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix
136157 path : rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix
158+
159+ - uses : actions/upload-artifact@v2
160+ if : github.ref == 'refs/heads/master'
161+ with :
162+ name : rescript-vscode-${{ steps.increment_pre_release.outputs.new_version }}.vsix
163+ path : rescript-vscode-${{ steps.increment_pre_release.outputs.new_version }}.vsix
164+
165+ - name : Publish latest master to GitHub
166+ if : github.ref == 'refs/heads/master'
167+ uses : marvinpinto/action-automatic-releases@latest
168+ with :
169+ repo_token : " ${{ secrets.GITHUB_TOKEN }}"
170+ automatic_release_tag : " latest-master"
171+ prerelease : true
172+ title : " Latest master"
173+ files : rescript-vscode-${{ steps.increment_pre_release.outputs.new_version }}.vsix
174+
175+ - name : Publish extension as pre-release
176+ if : github.ref == 'refs/heads/master'
177+ run : npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --pre-release ${{ steps.increment_pre_release.outputs.new_version }} --no-git-tag-version
0 commit comments