5
5
branches :
6
6
- master
7
7
paths-ignore :
8
- - ' docs/**'
9
- - ' .vscode/**'
10
- - ' .github/**'
11
- - ' *.md'
12
- - ' **/*.md'
8
+ - " docs/**"
9
+ - " .vscode/**"
10
+ - " .github/**"
11
+ - " *.md"
12
+ - " **/*.md"
13
13
pull_request :
14
14
branches :
15
15
- master
16
16
release :
17
17
types :
18
- - created
18
+ - released
19
19
jobs :
20
20
build :
21
21
timeout-minutes : 10
@@ -24,143 +24,153 @@ jobs:
24
24
matrix :
25
25
os : [ubuntu-latest, windows-latest, macOS-latest]
26
26
steps :
27
- - uses : actions/checkout@v2
28
- - run : git fetch --depth=1 origin +refs/tags/*:refs/tags/*
29
- - name : Set an output
30
- id : set-version
31
- if : runner.os == 'Linux'
32
- run : |
33
- set -x
34
- VERSION=$(jq -r '.version' package.json | cut -d- -f1)
35
- [ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
36
- CHANGELOG=$(cat CHANGELOG.md | sed -n "/## \[${VERSION}\]/,/## /p" | sed '/^$/d;1d;$d')
37
- CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
38
- echo ::set-output name=changelog::$CHANGELOG
39
- git tag -l | cat
40
- [ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=-beta && VERSION+=.$(($(git tag -l "v$VERSION.*" | sort -nt. -k4 2>/dev/null | tail -1 | cut -d. -f4)+1))
41
- [ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev.${{ github.event.pull_request.number }}
42
- echo ::set-output name=version::$VERSION
43
- NAME=$(jq -r '.name' package.json)-$VERSION
44
- echo ::set-output name=name::$NAME
45
- tmp=$(mktemp)
46
- jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
47
- mkdir dist
48
- echo $VERSION > ./dist/.version
49
- echo $NAME > ./dist/.name
50
- - name : Use Node.js
51
- uses : actions/setup-node@v1
52
- with :
53
- node-version : 12.x
54
- - run : npm install
55
- - name : lint
56
- if : runner.os == 'Linux'
57
- run : npm run lint
58
- - run : npm run compile
59
- - name : npm test
60
-
61
- with :
62
- run : npm run test
63
- - name : Build package
64
- if : runner.os == 'Linux'
65
- run : |
66
- ./node_modules/.bin/vsce package -o ./dist/${{ steps.set-version.outputs.name }}.vsix
67
- - uses : actions/upload-artifact@v2
68
- if : runner.os == 'Linux'
69
- with :
70
- name : vsix
71
- path : |
72
- ./dist/${{ steps.set-version.outputs.name }}.vsix
73
- ./dist/.name
74
- ./dist/.version
27
+ - uses : actions/checkout@v2
28
+ - run : git fetch --depth=1 origin +refs/tags/*:refs/tags/*
29
+ - name : Set an output
30
+ id : set-version
31
+ if : runner.os == 'Linux'
32
+ run : |
33
+ set -x
34
+ VERSION=$(jq -r '.version' package.json | cut -d- -f1)
35
+ [ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
36
+ CHANGELOG=$(cat CHANGELOG.md | sed -n "/## \[${VERSION}\]/,/## /p" | sed '/^$/d;1d;$d')
37
+ CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
38
+ echo ::set-output name=changelog::$CHANGELOG
39
+ git tag -l | cat
40
+ [ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=-beta && VERSION+=.$(($(git tag -l "v$VERSION.*" | sort -nt. -k4 2>/dev/null | tail -1 | cut -d. -f4)+1))
41
+ [ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev.${{ github.event.pull_request.number }}
42
+ echo ::set-output name=version::$VERSION
43
+ NAME=$(jq -r '.name' package.json)-$VERSION
44
+ echo ::set-output name=name::$NAME
45
+ tmp=$(mktemp)
46
+ jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
47
+ mkdir dist
48
+ echo $VERSION > .version
49
+ echo $NAME > .name
50
+ - name : Use Node.js
51
+ uses : actions/setup-node@v1
52
+ with :
53
+ node-version : 14.x
54
+ - run : npm install
55
+ - name : lint
56
+ if : runner.os == 'Linux'
57
+ run : npm run lint
58
+ - run : npm run compile
59
+ - name : npm test
60
+
61
+ with :
62
+ run : npm run test
63
+ - name : Build package
64
+ if : runner.os == 'Linux'
65
+ run : |
66
+ npx vsce package -o ${{ steps.set-version.outputs.name }}.vsix
67
+ - uses : actions/upload-artifact@v2
68
+ if : runner.os == 'Linux'
69
+ with :
70
+ name : ${{ steps.set-version.outputs.name }}.vsix
71
+ path : ${{ steps.set-version.outputs.name }}.vsix
72
+ - uses : actions/upload-artifact@v2
73
+ if : runner.os == 'Linux'
74
+ with :
75
+ name : meta
76
+ path : |
77
+ .name
78
+ .version
75
79
beta :
76
80
if : (github.event_name == 'push')
77
81
runs-on : ubuntu-latest
78
82
needs : build
79
83
steps :
80
- - uses : actions/download-artifact@v2
81
- with :
82
- name : vsix
83
- path : ./dist/
84
- - name : Set an output
85
- id : set-version
86
- if : runner.os == 'Linux'
87
- run : |
88
- set -x
89
- echo ::set-output name=version::`cat ./dist/.version`
90
- echo ::set-output name=name::`cat ./dist/.name`
91
- - name : Create Release
92
- id : create_release
93
- uses : actions/create-release@v1
94
- if : runner.os == 'Linux'
95
- env :
96
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
97
- with :
98
- tag_name : v${{ steps.set-version.outputs.version }}
99
- release_name : v${{ steps.set-version.outputs.version }}
100
- prerelease : ${{ github.event_name != 'release' }}
101
- body : |
102
- Changes in this release
103
- ${{ steps.set-version.outputs.changelog }}
104
- - name : Upload Release Asset
105
- id : upload-release-asset
106
- uses : actions/upload-release-asset@v1
107
- if : runner.os == 'Linux'
108
- env :
109
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
110
- with :
111
- upload_url : ${{ steps.create_release.outputs.upload_url }}
112
- asset_path : ./dist/${{ steps.set-version.outputs.name }}.vsix
113
- asset_name : ${{ steps.set-version.outputs.name }}.vsix
114
- asset_content_type : application/zip
84
+ - uses : actions/download-artifact@v2
85
+ with :
86
+ name : meta
87
+ path : .
88
+ - name : Set an output
89
+ id : set-version
90
+ if : runner.os == 'Linux'
91
+ run : |
92
+ set -x
93
+ echo ::set-output name=version::`cat .version`
94
+ echo ::set-output name=name::`cat .name`
95
+ - uses : actions/download-artifact@v2
96
+ with :
97
+ name : ${{ steps.set-version.outputs.name }}.vsix
98
+ - name : Create Release
99
+ id : create_release
100
+ uses : actions/create-release@v1
101
+ if : runner.os == 'Linux'
102
+ env :
103
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
104
+ with :
105
+ tag_name : v${{ steps.set-version.outputs.version }}
106
+ release_name : v${{ steps.set-version.outputs.version }}
107
+ prerelease : ${{ github.event_name != 'release' }}
108
+ body : |
109
+ Changes in this release
110
+ ${{ steps.set-version.outputs.changelog }}
111
+ - name : Upload Release Asset
112
+ id : upload-release-asset
113
+ uses : actions/upload-release-asset@v1
114
+ if : runner.os == 'Linux'
115
+ env :
116
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
117
+ with :
118
+ upload_url : ${{ steps.create_release.outputs.upload_url }}
119
+ asset_path : ${{ steps.set-version.outputs.name }}.vsix
120
+ asset_name : ${{ steps.set-version.outputs.name }}.vsix
121
+ asset_content_type : application/zip
115
122
publish :
116
123
if : github.event_name == 'release'
117
124
runs-on : ubuntu-latest
118
125
needs : build
119
126
steps :
120
- - uses : actions/checkout@v2
121
- with :
122
- ref : master
123
- token : ${{ secrets.TOKEN }}
124
- - uses : actions/download-artifact@v2
125
- with :
126
- name : vsix
127
- path : ./dist/
128
- - name : Use Node.js
129
- uses : actions/setup-node@v1
130
- with :
131
- node-version : 12.x
132
- - name : Prepare build
133
- id : set-version
134
- run : |
135
- VERSION=`cat ./dist/.version`
136
- NEXT_VERSION=`cat ./dist/.version | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
137
- echo ::set-output name=name::`cat ./dist/.name`
138
- tmp=$(mktemp)
139
- git config --global user.name 'ProjectBot'
140
- git config --global user.email '[email protected] '
141
- jq --arg version "${NEXT_VERSION}-SNAPSHOT" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
142
- git add package.json
143
- git commit -m 'auto bump version with release'
144
- jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
145
- jq '.enableProposedApi = false' package.json > "$tmp" && mv "$tmp" package.json
146
- npm install
147
- git push
148
- echo ::set-output name=ovsx::`cat ./dist/.name`
149
- - name : Upload Release Asset
150
- id : upload-release-asset
151
- uses : actions/upload-release-asset@v1
152
- if : runner.os == 'Linux'
153
- env :
154
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
155
- with :
156
- upload_url : ${{ github.event.release.upload_url }}
157
- asset_path : ./dist/${{ steps.set-version.outputs.name }}.vsix
158
- asset_name : ${{ steps.set-version.outputs.name }}.vsix
159
- asset_content_type : application/zip
160
- - name : Publish to VSCode Marketplace
161
- run : |
162
- [ -n "${{ secrets.VSCE_TOKEN }}" ] && ./node_modules/.bin/vsce publish -p ${{ secrets.VSCE_TOKEN }} || true
163
- - name : Publish to Open VSX Registry
164
- run : |
165
- [ -n "${{ secrets.OVSX_TOKEN }}" ] && ./node_modules/.bin/ovsx publish --pat ${{ secrets.OVSX_TOKEN }} || true
166
-
127
+ - uses : actions/checkout@v2
128
+ with :
129
+ ref : master
130
+ token : ${{ secrets.TOKEN }}
131
+ - uses : actions/download-artifact@v2
132
+ with :
133
+ name : meta
134
+ path : .
135
+ - name : Use Node.js
136
+ uses : actions/setup-node@v1
137
+ with :
138
+ node-version : 14.x
139
+ - name : Prepare build
140
+ id : set-version
141
+ run : |
142
+ VERSION=`cat .version`
143
+ NEXT_VERSION=`cat .version | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
144
+ echo ::set-output name=name::`cat .name`
145
+ tmp=$(mktemp)
146
+ git config --global user.name 'ProjectBot'
147
+ git config --global user.email '[email protected] '
148
+ jq --arg version "${NEXT_VERSION}-SNAPSHOT" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
149
+ git add package.json
150
+ git commit -m 'auto bump version with release'
151
+ jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
152
+ jq '.enableProposedApi = false' package.json > "$tmp" && mv "$tmp" package.json
153
+ npm install
154
+ git push
155
+ - name : Build package
156
+ run : |
157
+ npx vsce package -o ${{ steps.set-version.outputs.name }}.vsix
158
+ - name : Upload Release Asset
159
+ id : upload-release-asset
160
+ uses : actions/upload-release-asset@v1
161
+ if : runner.os == 'Linux'
162
+ env :
163
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
164
+ with :
165
+ upload_url : ${{ github.event.release.upload_url }}
166
+ asset_path : ${{ steps.set-version.outputs.name }}.vsix
167
+ asset_name : ${{ steps.set-version.outputs.name }}.vsix
168
+ asset_content_type : application/zip
169
+ - name : Publish to VSCode Marketplace
170
+ run : |
171
+ [ -n "${{ secrets.VSCE_TOKEN }}" ] && \
172
+ npx vsce publish --packagePath ${{ steps.set-version.outputs.name }}.vsix -p ${{ secrets.VSCE_TOKEN }} || true
173
+ - name : Publish to Open VSX Registry
174
+ run : |
175
+ [ -n "${{ secrets.OVSX_TOKEN }}" ] && \
176
+ npx ovsx publish ${{ steps.set-version.outputs.name }}.vsix --pat ${{ secrets.OVSX_TOKEN }} || true
0 commit comments