1212 - master
1313 release :
1414 types :
15- - created
15+ - released
1616jobs :
1717 build :
1818 timeout-minutes : 10
2121 matrix :
2222 os : [ubuntu-latest, windows-latest, macOS-latest]
2323 steps :
24- - uses : actions/checkout@master
24+ - uses : actions/checkout@v2
2525 - run : git fetch --depth=1 origin +refs/tags/*:refs/tags/*
2626 - name : Set an output
2727 id : set-version
@@ -35,17 +35,17 @@ jobs:
3535 echo ::set-output name=changelog::$CHANGELOG
3636 git tag -l | cat
3737 [ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=-beta && VERSION+=.$(($(git tag -l "v$VERSION.*" | sort -nt. -k4 2>/dev/null | tail -1 | cut -d. -f4)+1))
38- [ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev
38+ [ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev.${{ github.event.pull_request.number }}
3939 echo ::set-output name=version::$VERSION
4040 NAME=$(jq -r '.name' package.json)-$VERSION
4141 echo ::set-output name=name::$NAME
4242 tmp=$(mktemp)
4343 jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
4444 mkdir dist
45- echo $VERSION > ./dist/. version
46- echo $NAME > ./dist/. name
45+ echo $VERSION > .version
46+ echo $NAME > .name
4747 - name : Use Node.js
48- uses : actions/setup-node@master
48+ uses : actions/setup-node@v1
4949 with :
5050 node-version : 12.x
5151 - run : npm install
@@ -60,31 +60,41 @@ jobs:
6060 - name : Build package
6161 if : runner.os == 'Linux'
6262 run : |
63- ./node_modules/.bin/vsce package -o ./dist/package.vsix
64- - uses : actions/upload-artifact@master
63+ npx vsce package -o ${{ steps.set-version.outputs.name }}.vsix
64+ - uses : actions/upload-artifact@v2
65+ if : runner.os == 'Linux'
66+ with :
67+ name : ${{ steps.set-version.outputs.name }}.vsix
68+ path : ${{ steps.set-version.outputs.name }}.vsix
69+ - uses : actions/upload-artifact@v2
6570 if : runner.os == 'Linux'
6671 with :
67- name : vsix
68- path : ./dist/
72+ name : meta
73+ path : |
74+ .name
75+ .version
6976 beta :
7077 if : (github.event_name == 'push')
7178 runs-on : ubuntu-latest
7279 needs : build
7380 steps :
74- - uses : actions/download-artifact@master
81+ - uses : actions/download-artifact@v2
7582 with :
76- name : vsix
77- path : ./dist/
83+ name : meta
84+ path : .
7885 - name : Set an output
7986 id : set-version
8087 if : runner.os == 'Linux'
8188 run : |
8289 set -x
83- echo ::set-output name=version::`cat ./dist/.version`
84- echo ::set-output name=name::`cat ./dist/.name`
90+ echo ::set-output name=version::`cat .version`
91+ echo ::set-output name=name::`cat .name`
92+ - uses : actions/download-artifact@v2
93+ with :
94+ name : ${{ steps.set-version.outputs.name }}.vsix
8595 - name : Create Release
8696 id : create_release
87- uses : actions/create-release@master
97+ uses : actions/create-release@v1
8898 if : runner.os == 'Linux'
8999 env :
90100 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
@@ -97,13 +107,13 @@ jobs:
97107 ${{ steps.set-version.outputs.changelog }}
98108 - name : Upload Release Asset
99109 id : upload-release-asset
100- uses : actions/upload-release-asset@master
110+ uses : actions/upload-release-asset@v1
101111 if : runner.os == 'Linux'
102112 env :
103113 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
104114 with :
105115 upload_url : ${{ steps.create_release.outputs.upload_url }}
106- asset_path : ./dist/package .vsix
116+ asset_path : ${{ steps.set-version.outputs.name }} .vsix
107117 asset_name : ${{ steps.set-version.outputs.name }}.vsix
108118 asset_content_type : application/zip
109119 publish :
@@ -114,20 +124,21 @@ jobs:
114124 - uses : actions/checkout@v2
115125 with :
116126 ref : master
117- - uses : actions/download-artifact@master
127+ token : ${{ secrets.TOKEN }}
128+ - uses : actions/download-artifact@v2
118129 with :
119- name : vsix
120- path : ./dist/
130+ name : meta
131+ path : .
121132 - name : Use Node.js
122- uses : actions/setup-node@master
133+ uses : actions/setup-node@v1
123134 with :
124135 node-version : 12.x
125136 - name : Prepare build
126137 id : set-version
127138 run : |
128- VERSION=`cat ./dist/. version`
129- NEXT_VERSION=`cat ./dist/. version | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
130- echo ::set-output name=name::`cat ./dist/. name`
139+ VERSION=`cat .version`
140+ NEXT_VERSION=`cat .version | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
141+ echo ::set-output name=name::`cat .name`
131142 tmp=$(mktemp)
132143 git config --global user.name 'ProjectBot'
133144 git config --global user.email '[email protected] ' @@ -137,21 +148,26 @@ jobs:
137148 jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
138149 jq '.enableProposedApi = false' package.json > "$tmp" && mv "$tmp" package.json
139150 npm install
140- npm i -g vsce ovsx
141151 git push
152+ - name : Build package
153+ run : |
154+ npx vsce package -o ${{ steps.set-version.outputs.name }}.vsix
142155 - name : Upload Release Asset
143156 id : upload-release-asset
144- uses : actions/upload-release-asset@master
157+ uses : actions/upload-release-asset@v1
145158 if : runner.os == 'Linux'
146159 env :
147160 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
148161 with :
149162 upload_url : ${{ github.event.release.upload_url }}
150- asset_path : ./dist/package .vsix
163+ asset_path : ${{ steps.set-version.outputs.name }} .vsix
151164 asset_name : ${{ steps.set-version.outputs.name }}.vsix
152165 asset_content_type : application/zip
153- - name : Publish to Marketplaces
166+ - name : Publish to VSCode Marketplace
154167 run : |
155- vsce publish -p ${{ secrets.VSCE_TOKEN }}
156- ovsx publish --pat ${{ secrets.OVSX_TOKEN }}
157-
168+ [ -n "${{ secrets.VSCE_TOKEN }}" ] && \
169+ npx vsce publish --packagePath ${{ steps.set-version.outputs.name }}.vsix -p ${{ secrets.VSCE_TOKEN }} || true
170+ - name : Publish to Open VSX Registry
171+ run : |
172+ [ -n "${{ secrets.OVSX_TOKEN }}" ] && \
173+ npx ovsx publish ${{ steps.set-version.outputs.name }}.vsix --pat ${{ secrets.OVSX_TOKEN }} || true
0 commit comments