@@ -2,18 +2,15 @@ name: CI
22
33on :
44 push :
5- branches :
6- - master
5+ branches : [ master ]
76 paths-ignore :
87 - " .vscode/**"
98 - " .github/**"
109 - " **/*.md"
1110 pull_request :
12- branches :
13- - master
11+ branches : [ master ]
1412 release :
15- types :
16- - released
13+ types : [ published ]
1714
1815concurrency :
1916 group : ${{ github.workflow }}-${{ github.base_ref || github.run_id }}
2320 build :
2421 timeout-minutes : 10
2522 runs-on : ubuntu-latest
26- outputs :
27- taggedbranch : ${{ steps.find-branch.outputs.taggedbranch }}
2823 steps :
2924 - uses : actions/checkout@v4
3025 - run : git fetch --depth=1 origin +refs/tags/*:refs/tags/*
31- - name : Find which branch the release tag points at
32- id : find-branch
33- if : github.event_name == 'release'
34- shell : bash
35- run : |
36- git fetch --depth=1 origin +refs/heads/*:refs/heads/*
37- set -x
38- TAGGEDBRANCH=$(git for-each-ref --points-at=${{github.sha}} --format='%(refname:lstrip=2)' refs/heads/)
39- echo "taggedbranch=$TAGGEDBRANCH" >> $GITHUB_OUTPUT
4026 - name : Set an output
4127 id : set-version
4228 run : |
@@ -57,32 +43,37 @@ jobs:
5743 mkdir dist
5844 echo $VERSION > meta.version
5945 echo $NAME > meta.name
46+
6047 - name : Use Node.js
6148 uses : actions/setup-node@v4
6249 with :
6350 node-version : 20
51+
6452 - run : npm install
6553 - name : lint
6654 run : npm run lint
6755 - run : npm run compile
6856 - name : npm test
6957 run : xvfb-run npm test
58+
7059 - name : Build package
71- run : |
72- npx vsce package -o ${{ steps.set-version.outputs.name }}.vsix
60+ run : npx vsce package -o ${{ steps.set-version.outputs.name }}.vsix
61+
7362 - uses : actions/upload-artifact@v4
7463 if : github.event_name != 'release'
7564 with :
7665 name : ${{ steps.set-version.outputs.name }}.vsix
7766 path : ${{ steps.set-version.outputs.name }}.vsix
67+
7868 - uses : actions/upload-artifact@v4
7969 with :
8070 name : meta
8171 path : |
8272 meta.name
8373 meta.version
74+
8475 beta :
85- if : ( github.event_name == 'push')
76+ if : github.event_name == 'push'
8677 runs-on : ubuntu-latest
8778 needs : build
8879 steps :
@@ -94,42 +85,48 @@ jobs:
9485 id : set-version
9586 run : |
9687 set -x
97- echo "version=` cat meta.version` " >> $GITHUB_OUTPUT
98- echo "name=` cat meta.name` " >> $GITHUB_OUTPUT
88+ echo "version=$( cat meta.version) " >> $GITHUB_OUTPUT
89+ echo "name=$( cat meta.name) " >> $GITHUB_OUTPUT
9990 - uses : actions/download-artifact@v4
10091 with :
10192 name : ${{ steps.set-version.outputs.name }}.vsix
10293 - name : Create Release
103- id : create-release
10494 uses : softprops/action-gh-release@v1
10595 with :
10696 tag_name : v${{ steps.set-version.outputs.version }}
107- prerelease : ${{ github.event_name != 'release' }}
97+ prerelease : true
10898 files : ${{ steps.set-version.outputs.name }}.vsix
10999 token : ${{ secrets.GITHUB_TOKEN }}
100+
110101 publish :
111102 needs : build
112- if : github.event_name == 'release' && needs.build.outputs.taggedbranch == 'master'
103+ if : github.event_name == 'release' && github.event.release.target_commitish == 'master'
113104 runs-on : ubuntu-latest
105+ permissions :
106+ contents : write
114107 steps :
115108 - uses : actions/checkout@v4
116109 with :
117110 ref : master
118- token : ${{ secrets.TOKEN }}
111+ fetch-depth : 0
112+ token : ${{ secrets.GITHUB_TOKEN }}
113+
119114 - uses : actions/download-artifact@v4
120115 with :
121116 name : meta
122117 path : .
118+
123119 - name : Use Node.js
124120 uses : actions/setup-node@v4
125121 with :
126122 node-version : 20
123+
127124 - name : Prepare build
128125 id : set-version
129126 run : |
130- VERSION=` cat meta.version`
131- NEXT_VERSION=` cat meta.version | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
132- echo "name=` cat meta.name` " >> $GITHUB_OUTPUT
127+ VERSION=$( cat meta.version)
128+ NEXT_VERSION=$( cat meta.version | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.)
129+ echo "name=$( cat meta.name) " >> $GITHUB_OUTPUT
133130 tmp=$(mktemp)
134131 git config --global user.name 'ProjectBot'
135132 git config --global user.email '[email protected] ' @@ -140,22 +137,24 @@ jobs:
140137 npm install
141138 jq 'del(.enableProposedApi,.enabledApiProposals)' package.json > "$tmp" && mv "$tmp" package.json
142139 git push
140+
143141 - name : Build package
144- run : |
145- npx vsce package -o ${{ steps.set-version.outputs.name }}.vsix
142+ run : npx vsce package -o ${{ steps.set-version.outputs.name }}.vsix
143+
146144 - name : Upload Release Asset
147- id : upload-release-asset
148145 uses : softprops/action-gh-release@v1
149146 with :
150147 tag_name : ${{ github.event.release.tag_name }}
151148 files : ${{ steps.set-version.outputs.name }}.vsix
152149 token : ${{ secrets.GITHUB_TOKEN }}
150+
153151 - name : Publish to VSCode Marketplace
154152 run : |
155153 [ -n "${{ secrets.VSCE_TOKEN }}" ] && \
156- npx vsce publish --packagePath ${{ steps.set-version.outputs.name }}.vsix -p ${{ secrets.VSCE_TOKEN }} || true
154+ npx vsce publish --packagePath ${{ steps.set-version.outputs.name }}.vsix -p ${{ secrets.VSCE_TOKEN }} || true
155+
157156 - name : Publish to Open VSX Registry
158157 timeout-minutes : 5
159158 run : |
160159 [ -n "${{ secrets.OVSX_TOKEN }}" ] && \
161- npx ovsx publish ${{ steps.set-version.outputs.name }}.vsix --pat ${{ secrets.OVSX_TOKEN }} || true
160+ npx ovsx publish ${{ steps.set-version.outputs.name }}.vsix --pat ${{ secrets.OVSX_TOKEN }} || true
0 commit comments