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