1
1
name : CI
2
2
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
5
16
jobs :
6
17
build :
7
18
runs-on : ${{ matrix.os }}
@@ -17,16 +28,21 @@ jobs:
17
28
run : |
18
29
set -x
19
30
VERSION=$(jq -r '.version' package.json | cut -d- -f1)
31
+ [ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
20
32
CHANGELOG=$(cat CHANGELOG.md | sed -n "/## \[${VERSION}\]/,/## /p" | sed '/^$/d;1d;$d')
21
33
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
22
34
echo ::set-output name=changelog::$CHANGELOG
23
- VERSION+=-beta
24
35
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.*" 2>/dev/null | tail -1 | cut -d. -f4)+1))
37
+ [ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev
26
38
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
28
41
tmp=$(mktemp)
29
42
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
30
46
- name : Use Node.js
31
47
uses : actions/setup-node@master
32
48
with :
40
56
- name : Build package
41
57
if : runner.os == 'Linux'
42
58
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`
45
81
- name : Create Release
46
82
id : create_release
47
83
uses : actions/create-release@master
51
87
with :
52
88
tag_name : v${{ steps.set-version.outputs.version }}
53
89
release_name : v${{ steps.set-version.outputs.version }}
54
- draft : false
55
- prerelease : true
90
+ prerelease : ${{ github.event_name != 'release' }}
56
91
body : |
57
92
Changes in this release
58
93
${{ steps.set-version.outputs.changelog }}
64
99
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
65
100
with :
66
101
upload_url : ${{ steps.create_release.outputs.upload_url }}
67
- asset_path : ./dist/vscode-objectscript.vsix
102
+ asset_path : ./dist/package.vsix
103
+ asset_name : ${{ steps.set-version.outputs.name }}.vsix
104
+ 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@master
111
+ - uses : actions/download-artifact@master
112
+ with :
113
+ name : vsix
114
+ path : ./dist/
115
+ - name : Use Node.js
116
+ uses : actions/setup-node@master
117
+ with :
118
+ node-version : 12.x
119
+ - name : Prepare build
120
+ id : set-version
121
+ run : |
122
+ VERSION=`cat ./dist/.version`
123
+ echo ::set-output name=name::`cat ./dist/.name`
124
+ jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
125
+ jq '.enableProposedApi = false' package.json > "$tmp" && mv "$tmp" package.json
126
+ npm install
127
+ npm i -g vsce
128
+ - name : Upload Release Asset
129
+ id : upload-release-asset
130
+ uses : actions/upload-release-asset@master
131
+ if : runner.os == 'Linux'
132
+ env :
133
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
134
+ with :
135
+ upload_url : ${{ github.event.release.upload_url }}
136
+ asset_path : ./dist/package.vsix
68
137
asset_name : ${{ steps.set-version.outputs.name }}.vsix
69
138
asset_content_type : application/zip
139
+ - name : Publish to Marketplace
140
+ run : vsce publish -p ${{ secrets.VSCE_TOKEN }}
141
+
0 commit comments