55 branches :
66 - master
77 paths-ignore :
8- - ' *.md'
9- - ' **/*.md'
8+ - " docs/**"
9+ - " .vscode/**"
10+ - " .github/**"
11+ - " *.md"
12+ - " **/*.md"
1013 pull_request :
1114 branches :
1215 - master
@@ -19,139 +22,126 @@ jobs:
1922 runs-on : ${{ matrix.os }}
2023 strategy :
2124 matrix :
22- # os: [ubuntu-latest, windows-latest, macOS-latest]
2325 os : [ubuntu-latest]
26+ outputs :
27+ name : ${{ steps.set-version.outputs.name }}
28+ version : ${{ steps.set-version.outputs.version }}
29+ taggedbranch : ${{ steps.find-branch.outputs.taggedbranch }}
2430 steps :
25- - uses : actions/checkout@v4
26- - run : git fetch --depth=1 origin +refs/tags/*:refs/tags/*
27- - name : Set an output
28- id : set-version
29- if : runner.os == 'Linux'
30- run : |
31- set -x
32- VERSION=$(jq -r '.version' package.json | cut -d- -f1)
33- [ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
34- CHANGELOG=$(cat CHANGELOG.md | sed -n "/## \[${VERSION}\]/,/## /p" | sed '/^$/d;1d;$d')
35- CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
36- echo ::set-output name=changelog::$CHANGELOG
37- git tag -l | cat
38- [ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=-beta && VERSION+=.$(($(git tag -l "v$VERSION.*" | sort -nt. -k4 2>/dev/null | tail -1 | cut -d. -f4)+1))
39- [ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev.${{ github.event.pull_request.number }}
40- echo ::set-output name=version::$VERSION
41- NAME=$(jq -r '.name' package.json)-$VERSION
42- echo ::set-output name=name::$NAME
43- tmp=$(mktemp)
44- jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
45- mkdir dist
46- echo $VERSION > .version
47- echo $NAME > .name
48- - name : Use Node.js
49- uses : actions/setup-node@v4
50- with :
51- node-version : 20
52- - run : npm install
53- - name : lint
54- if : runner.os == 'Linux'
55- run : npm run lint
56- - run : npm run compile
57- - name : Build package
58- if : runner.os == 'Linux'
59- run : |
60- npx vsce package -o ${{ steps.set-version.outputs.name }}.vsix
61- - uses : actions/upload-artifact@v4
62- if : runner.os == 'Linux'
63- with :
64- name : ${{ steps.set-version.outputs.name }}.vsix
65- path : ${{ steps.set-version.outputs.name }}.vsix
66- - uses : actions/upload-artifact@v4
67- if : runner.os == 'Linux'
68- with :
69- name : meta
70- path : |
71- .name
72- .version
31+ - uses : actions/checkout@v3
32+ - run : git fetch --depth=1 origin +refs/tags/*:refs/tags/*
33+ - name : Find which branch the release tag points at
34+ id : find-branch
35+ if : github.event_name == 'release'
36+ shell : bash
37+ run : |
38+ git fetch --depth=1 origin +refs/heads/*:refs/heads/*
39+ set -x
40+ TAGGEDBRANCH=$(git for-each-ref --points-at=${{github.sha}} --format='%(refname:lstrip=2)' refs/heads/)
41+ echo "taggedbranch=$TAGGEDBRANCH" >> $GITHUB_OUTPUT
42+ - name : Set an output
43+ id : set-version
44+ if : runner.os == 'Linux'
45+ shell : bash
46+ run : |
47+ set -x
48+ VERSION=$(jq -r '.version' package.json | cut -d- -f1)
49+ [ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
50+ CHANGELOG=$(cat CHANGELOG.md | sed -n "/## \[${VERSION}\]/,/## /p" | sed '/^$/d;1d;$d')
51+ CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
52+ echo "changelog=$CHANGELOG" >> $GITHUB_OUTPUT
53+ git tag -l | cat
54+ [ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=-beta && VERSION+=.$(($(git tag -l "v$VERSION.*" | sort -nt. -k4 2>/dev/null | tail -1 | cut -d. -f4)+1))
55+ [ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev.${{ github.event.pull_request.number }}
56+ echo "version=$VERSION" >> $GITHUB_OUTPUT
57+ NAME=$(jq -r '.name' package.json)-$VERSION
58+ echo "name=$NAME" >> $GITHUB_OUTPUT
59+ tmp=$(mktemp)
60+ jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
61+ mkdir dist
62+ echo $VERSION > .version
63+ echo $NAME > .name
64+ - name : Use Node.js
65+ uses : actions/setup-node@v3
66+ with :
67+ node-version : 20
68+ - run : npm install
69+ - name : lint
70+ if : runner.os == 'Linux'
71+ run : npm run lint
72+ - run : npm run compile
73+ - name : Build package
74+ if : runner.os == 'Linux'
75+ run : |
76+ npx vsce package -o ${{ steps.set-version.outputs.name }}.vsix
77+ - uses : actions/upload-artifact@v4.4.2
78+ if : (runner.os == 'Linux') && (github.event_name != 'release')
79+ with :
80+ name : ${{ steps.set-version.outputs.name }}.vsix
81+ path : ${{ steps.set-version.outputs.name }}.vsix
7382 beta :
7483 if : (github.event_name == 'push')
7584 runs-on : ubuntu-latest
7685 needs : build
7786 steps :
78- - uses : actions/download-artifact@v4
79- with :
80- name : meta
81- path : .
82- - name : Set an output
83- id : set-version
84- if : runner.os == 'Linux'
85- run : |
86- set -x
87- echo ::set-output name=version::`cat .version`
88- echo ::set-output name=name::`cat .name`
89- - uses : actions/download-artifact@v4
90- with :
91- name : ${{ steps.set-version.outputs.name }}.vsix
92- - name : Upload Release Asset
93- id : upload-release-asset
94- uses : softprops/action-gh-release@v2
95- if : runner.os == 'Linux'
96- env :
97- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
98- with :
99- tag_name : v${{ steps.set-version.outputs.version }}
100- prerelease : ${{ github.event_name != 'release' }}
101- files : ${{ steps.set-version.outputs.name }}.vsix
102- token : ${{ secrets.GITHUB_TOKEN }}
87+ - uses : actions/download-artifact@v4.1.7
88+ with :
89+ name : ${{ needs.build.outputs.name }}.vsix
90+ - name : Create Release
91+ id : create_release
92+ uses : softprops/action-gh-release@v1
93+ with :
94+ tag_name : v${{ needs.build.outputs.version }}
95+ name : v${{ needs.build.outputs.version }}
96+ prerelease : ${{ github.event_name != 'release' }}
97+ token : ${{ secrets.GITHUB_TOKEN }}
98+ files : ${{ needs.build.outputs.name }}.vsix
10399 publish :
104- if : github.event_name == 'release'
105- runs-on : ubuntu-latest
106100 needs : build
101+ if : github.event_name == 'release' && needs.build.outputs.taggedbranch == 'master'
102+ runs-on : ubuntu-latest
107103 steps :
108- - uses : actions/checkout@v4
109- with :
110- ref : master
111- token : ${{ secrets.GITHUB_TOKEN }}
112- - uses : actions/download-artifact@v4
113- with :
114- name : meta
115- path : .
116- - name : Use Node.js
117- uses : actions/setup-node@v4
118- with :
119- node-version : 14
120- - name : Prepare build
121- id : set-version
122- run : |
123- VERSION=`cat .version`
124- NEXT_VERSION=`cat .version | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
125- echo ::set-output name=name::`cat .name`
126- tmp=$(mktemp)
127- git config --global user.name 'ProjectBot'
128- git config --global user.email 'bot@users.noreply.github.com'
129- jq --arg version "${NEXT_VERSION}-SNAPSHOT" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
130- git add package.json
131- git commit -m 'auto bump version with release'
132- jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
133- jq '.enableProposedApi = false' package.json > "$tmp" && mv "$tmp" package.json
134- npm install
135- git push
136- - name : Build package
137- run : |
138- npx vsce package -o ${{ steps.set-version.outputs.name }}.vsix
139- - name : Upload Release Asset
140- id : upload-release-asset
141- uses : softprops/action-gh-release@v2
142- if : runner.os == 'Linux'
143- env :
144- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
145- with :
146- tag_name : v${{ steps.set-version.outputs.version }}
147- prerelease : ${{ github.event_name != 'release' }}
148- files : ${{ steps.set-version.outputs.name }}.vsix
149- token : ${{ secrets.GITHUB_TOKEN }}
150- - name : Publish to VSCode Marketplace
151- run : |
152- [ -n "${{ secrets.VSCE_TOKEN }}" ] && \
153- npx vsce publish --packagePath ${{ steps.set-version.outputs.name }}.vsix -p ${{ secrets.VSCE_TOKEN }} || true
154- - name : Publish to Open VSX Registry
155- run : |
156- [ -n "${{ secrets.OVSX_TOKEN }}" ] && \
157- npx ovsx publish ${{ steps.set-version.outputs.name }}.vsix --pat ${{ secrets.OVSX_TOKEN }} || true
104+ - uses : actions/checkout@v3
105+ with :
106+ ref : master
107+ token : ${{ secrets.TOKEN }}
108+ - name : Use Node.js
109+ uses : actions/setup-node@v3
110+ with :
111+ node-version : 20
112+ - name : Prepare build
113+ id : set-version
114+ shell : bash
115+ run : |
116+ VERSION=${{ needs.build.outputs.version }}
117+ NEXT_VERSION=`echo $VERSION | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
118+ tmp=$(mktemp)
119+ git config --global user.name 'ProjectBot'
120+ git config --global user.email 'bot@users.noreply.github.com'
121+ jq --arg version "${NEXT_VERSION}-SNAPSHOT" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
122+ git add package.json
123+ git commit -m 'auto bump version with release [skip ci]'
124+ jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
125+ jq 'del(.enableProposedApi,.enabledApiProposals)' package.json > "$tmp" && mv "$tmp" package.json
126+ npm install
127+ git push
128+ - name : Build package
129+ run : |
130+ npx vsce package -o ${{ needs.build.outputs.name }}.vsix
131+ - name : Upload Release Asset
132+ id : upload-release-asset
133+ uses : softprops/action-gh-release@v1
134+ with :
135+ tag_name : ${{ github.event.release.tag_name }}
136+ files : ${{ needs.build.outputs.name }}.vsix
137+ token : ${{ secrets.GITHUB_TOKEN }}
138+ - name : Publish to VSCode Marketplace
139+ shell : bash
140+ run : |
141+ [ -n "${{ secrets.VSCE_TOKEN }}" ] && \
142+ npx vsce publish --packagePath ${{ needs.build.outputs.name }}.vsix -p ${{ secrets.VSCE_TOKEN }} || true
143+ - name : Publish to Open VSX Registry
144+ shell : bash
145+ run : |
146+ [ -n "${{ secrets.OVSX_TOKEN }}" ] && \
147+ npx ovsx publish ${{ needs.build.outputs.name }}.vsix --pat ${{ secrets.OVSX_TOKEN }} || true
0 commit comments