11name : CI
22
3- on : [push,release]
4-
3+ on :
4+ push :
5+ branches :
6+ - master
7+ paths-ignore :
8+ - ' *.md'
9+ - ' **/*.md'
10+ pull_request :
11+ branches :
12+ - master
13+ release :
14+ types :
15+ - created
516jobs :
617 build :
718 runs-on : ${{ matrix.os }}
@@ -20,13 +31,17 @@ jobs:
2031 CHANGELOG=$(cat CHANGELOG.md | sed -n "/## \[${VERSION}\]/,/## /p" | sed '/^$/d;1d;$d')
2132 CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
2233 echo ::set-output name=changelog::$CHANGELOG
23- VERSION+=-beta
2434 git tag -l | cat
25- VERSION+=.$(($(git tag -l "v$VERSION.*" 2>/dev/null | tail -1 | cut -d. -f4)+1))
35+ [ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=-beta && VERSION+=.$(($(git tag -l "v$VERSION.*" 2>/dev/null | tail -1 | cut -d. -f4)+1))
36+ [ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev
2637 echo ::set-output name=version::$VERSION
27- echo ::set-output name=name::$(jq -r '.name' package.json)-$VERSION
38+ NAME=$(jq -r '.name' package.json)-$VERSION
39+ echo ::set-output name=name::$NAME
2840 tmp=$(mktemp)
2941 jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
42+ mkdir dist
43+ echo $VERSION > ./dist/.version
44+ echo $NAME > ./dist/.name
3045 - name : Use Node.js
3146 uses : actions/setup-node@master
3247 with :
4055 - name : Build package
4156 if : runner.os == 'Linux'
4257 run : |
43- mkdir dist
44- ./node_modules/.bin/vsce package -o ./dist/vscode-objectscript.vsix
58+ ./node_modules/.bin/vsce package -o ./dist/package.vsix
59+ - uses : actions/upload-artifact@master
60+ if : runner.os == 'Linux'
61+ with :
62+ name : vsix
63+ path : ./dist/
64+ release :
65+ if : (github.event_name == 'release') || (github.event_name == 'push')
66+ runs-on : ubuntu-latest
67+ needs : build
68+ steps :
69+ - uses : actions/download-artifact@master
70+ with :
71+ name : vsix
72+ path : ./dist/
73+ - name : Set an output
74+ id : set-version
75+ if : runner.os == 'Linux'
76+ run : |
77+ set -x
78+ echo ::set-output name=version::`cat ./dist/.version`
79+ echo ::set-output name=name::`cat ./dist/.name`
4580 - name : Create Release
4681 id : create_release
4782 uses : actions/create-release@master
5186 with :
5287 tag_name : v${{ steps.set-version.outputs.version }}
5388 release_name : v${{ steps.set-version.outputs.version }}
54- draft : false
55- prerelease : true
89+ prerelease : ${{ github.event_name != 'release' }}
5690 body : |
5791 Changes in this release
5892 ${{ steps.set-version.outputs.changelog }}
6498 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6599 with :
66100 upload_url : ${{ steps.create_release.outputs.upload_url }}
67- asset_path : ./dist/vscode-objectscript .vsix
101+ asset_path : ./dist/package .vsix
68102 asset_name : ${{ steps.set-version.outputs.name }}.vsix
69103 asset_content_type : application/zip
104+ publish :
105+ if : github.event_name == 'release'
106+ runs-on : ubuntu-latest
107+ steps :
108+ - uses : actions/checkout@master
109+ - uses : actions/download-artifact@master
110+ with :
111+ name : vsix
112+ path : ./dist/
113+ - name : Use Node.js
114+ uses : actions/setup-node@master
115+ with :
116+ node-version : 12.x
117+ - name : Prepare build
118+ run : |
119+ VERSION=`cat ./dist/.version`
120+ jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
121+ npm install
122+ npm i -g vsce
123+ - name : Publish to Marketplace
124+ run : vsce publish -p ${{ secrets.VSCE_TOKEN }}
125+
0 commit comments