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 }}
@@ -17,16 +28,21 @@ jobs:
1728 run : |
1829 set -x
1930 VERSION=$(jq -r '.version' package.json | cut -d- -f1)
31+ [ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
2032 CHANGELOG=$(cat CHANGELOG.md | sed -n "/## \[${VERSION}\]/,/## /p" | sed '/^$/d;1d;$d')
2133 CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
2234 echo ::set-output name=changelog::$CHANGELOG
23- VERSION+=-beta
2435 git tag -l | cat
25- VERSION+=.$(($(git tag -l "v$VERSION.*" 2>/dev/null | tail -1 | cut -d. -f4)+1))
36+ [ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=-beta && VERSION+=.$(($(git tag -l "v$VERSION.*" | sort -nt. -k4 2>/dev/null | tail -1 | cut -d. -f4)+1))
37+ [ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev
2638 echo ::set-output name=version::$VERSION
27- echo ::set-output name=name::$(jq -r '.name' package.json)-$VERSION
39+ NAME=$(jq -r '.name' package.json)-$VERSION
40+ echo ::set-output name=name::$NAME
2841 tmp=$(mktemp)
2942 jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
43+ mkdir dist
44+ echo $VERSION > ./dist/.version
45+ echo $NAME > ./dist/.name
3046 - name : Use Node.js
3147 uses : actions/setup-node@master
3248 with :
4056 - name : Build package
4157 if : runner.os == 'Linux'
4258 run : |
43- mkdir dist
44- ./node_modules/.bin/vsce package -o ./dist/vscode-objectscript.vsix
59+ ./node_modules/.bin/vsce package -o ./dist/package.vsix
60+ - uses : actions/upload-artifact@master
61+ if : runner.os == 'Linux'
62+ with :
63+ name : vsix
64+ path : ./dist/
65+ beta :
66+ if : (github.event_name == 'push')
67+ runs-on : ubuntu-latest
68+ needs : build
69+ steps :
70+ - uses : actions/download-artifact@master
71+ with :
72+ name : vsix
73+ path : ./dist/
74+ - name : Set an output
75+ id : set-version
76+ if : runner.os == 'Linux'
77+ run : |
78+ set -x
79+ echo ::set-output name=version::`cat ./dist/.version`
80+ echo ::set-output name=name::`cat ./dist/.name`
4581 - name : Create Release
4682 id : create_release
4783 uses : actions/create-release@master
5187 with :
5288 tag_name : v${{ steps.set-version.outputs.version }}
5389 release_name : v${{ steps.set-version.outputs.version }}
54- draft : false
55- prerelease : true
90+ prerelease : ${{ github.event_name != 'release' }}
5691 body : |
5792 Changes in this release
5893 ${{ steps.set-version.outputs.changelog }}
6499 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
65100 with :
66101 upload_url : ${{ steps.create_release.outputs.upload_url }}
67- asset_path : ./dist/vscode-objectscript .vsix
102+ asset_path : ./dist/package .vsix
68103 asset_name : ${{ steps.set-version.outputs.name }}.vsix
69104 asset_content_type : application/zip
105+ publish :
106+ if : github.event_name == 'release'
107+ runs-on : ubuntu-latest
108+ needs : build
109+ steps :
110+ - uses : actions/checkout@v2
111+ with :
112+ ref : master
113+ - uses : actions/download-artifact@master
114+ with :
115+ name : vsix
116+ path : ./dist/
117+ - name : Use Node.js
118+ uses : actions/setup-node@master
119+ with :
120+ node-version : 12.x
121+ - name : Prepare build
122+ id : set-version
123+ run : |
124+ VERSION=`cat ./dist/.version`
125+ echo ::set-output name=name::`cat ./dist/.name`
126+ tmp=$(mktemp)
127+ git config --global user.name 'ProjectBot'
128+ git config --global user.email '[email protected] ' 129+ jq --arg version "${VERSION}-SNAPSHOT" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
130+ git add package.json
131+ git commit -m 'auto bump version with release'
132+ jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
133+ jq '.enableProposedApi = false' package.json > "$tmp" && mv "$tmp" package.json
134+ npm install
135+ npm i -g vsce
136+ git push
137+ - name : Upload Release Asset
138+ id : upload-release-asset
139+ uses : actions/upload-release-asset@master
140+ if : runner.os == 'Linux'
141+ env :
142+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
143+ with :
144+ upload_url : ${{ github.event.release.upload_url }}
145+ asset_path : ./dist/package.vsix
146+ asset_name : ${{ steps.set-version.outputs.name }}.vsix
147+ asset_content_type : application/zip
148+ - name : Publish to Marketplace
149+ run : vsce publish -p ${{ secrets.VSCE_TOKEN }}
150+
0 commit comments