Skip to content

Commit 7514cf3

Browse files
Merge pull request #5 from gjsjohnmurray/improve-CI
Adopt CI from vscode-objectscript
2 parents ffd1761 + ab4ed85 commit 7514cf3

File tree

4 files changed

+451
-275
lines changed

4 files changed

+451
-275
lines changed

.github/workflows/main.yml

Lines changed: 81 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: CI
33
on:
44
push:
55
branches:
6-
- master
6+
- main
77
paths-ignore:
88
- "docs/**"
99
- ".vscode/**"
@@ -12,10 +12,15 @@ on:
1212
- "**/*.md"
1313
pull_request:
1414
branches:
15-
- master
15+
- main
1616
release:
1717
types:
1818
- released
19+
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.base_ref || github.run_id }}
22+
cancel-in-progress: false
23+
1924
jobs:
2025
build:
2126
timeout-minutes: 10
@@ -24,131 +29,147 @@ jobs:
2429
matrix:
2530
os: [ubuntu-latest, windows-latest, macOS-latest]
2631
outputs:
27-
name: ${{ steps.set-version.outputs.name }}
28-
version: ${{ steps.set-version.outputs.version }}
32+
taggedbranch: ${{ steps.find-branch.outputs.taggedbranch }}
2933
steps:
30-
- uses: actions/checkout@v2
34+
- uses: actions/checkout@v3
3135
- 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
3245
- name: Set an output
3346
id: set-version
34-
if: runner.os == 'Windows'
35-
shell: bash
47+
if: runner.os == 'Linux'
3648
run: |
3749
set -x
3850
VERSION=$(jq -r '.version' package.json | cut -d- -f1)
3951
[ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
4052
CHANGELOG=$(cat CHANGELOG.md | sed -n "/## \[${VERSION}\]/,/## /p" | sed '/^$/d;1d;$d')
4153
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
42-
echo ::set-output name=changelog::$CHANGELOG
54+
echo "changelog=$CHANGELOG" >> $GITHUB_OUTPUT
4355
git tag -l | cat
4456
[ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=-beta && VERSION+=.$(($(git tag -l "v$VERSION.*" | sort -nt. -k4 2>/dev/null | tail -1 | cut -d. -f4)+1))
4557
[ $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
4759
NAME=$(jq -r '.name' package.json)-$VERSION
48-
echo ::set-output name=name::$NAME
60+
echo "name=$NAME" >> $GITHUB_OUTPUT
4961
tmp=$(mktemp)
5062
jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
5163
mkdir dist
5264
echo $VERSION > .version
5365
echo $NAME > .name
5466
- name: Use Node.js
55-
uses: actions/setup-node@v1
67+
uses: actions/setup-node@v3
5668
with:
57-
node-version: 14.x
69+
node-version: 16
5870
- run: npm install
71+
- name: lint
72+
if: runner.os == 'Linux-NOSUCH'
73+
run: npm run lint
5974
- run: npm run compile
6075
- name: npm test
61-
uses: GabrielBB/xvfb-action@v1.0
76+
uses: coactions/setup-xvfb@v1
6277
with:
6378
run: npm run test
6479
- name: Build package
65-
if: runner.os == 'Windows'
80+
if: runner.os == 'Linux'
6681
run: |
6782
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')
7085
with:
7186
name: ${{ steps.set-version.outputs.name }}.vsix
7287
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
7395
beta:
7496
if: (github.event_name == 'push')
75-
runs-on: windows-latest
97+
runs-on: ubuntu-latest
7698
needs: build
7799
steps:
78-
- uses: actions/download-artifact@v2
100+
- uses: actions/download-artifact@v3
79101
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
81114
- 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'
86118
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 }}
89120
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 }}
103123
publish:
104-
if: github.event_name == 'release'
105-
runs-on: windows-latest
106124
needs: build
125+
if: github.event_name == 'release' && needs.build.outputs.taggedbranch == 'main'
126+
runs-on: ubuntu-latest
107127
steps:
108-
- uses: actions/checkout@v2
128+
- uses: actions/checkout@v3
109129
with:
110-
ref: master
130+
ref: main
111131
token: ${{ secrets.TOKEN }}
132+
- uses: actions/download-artifact@v3
133+
with:
134+
name: meta
135+
path: .
112136
- name: Use Node.js
113-
uses: actions/setup-node@v1
137+
uses: actions/setup-node@v3
114138
with:
115-
node-version: 14.x
139+
node-version: 16
116140
- name: Prepare build
117141
id: set-version
118-
shell: bash
119142
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
122146
tmp=$(mktemp)
123147
git config --global user.name 'ProjectBot'
124148
git config --global user.email '[email protected]'
125149
jq --arg version "${NEXT_VERSION}-SNAPSHOT" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
126150
git add package.json
127151
git commit -m 'auto bump version with release'
128152
jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
129-
jq '.enableProposedApi = false' package.json > "$tmp" && mv "$tmp" package.json
130153
npm install
154+
jq 'del(.enableProposedApi,.enabledApiProposals)' package.json > "$tmp" && mv "$tmp" package.json
131155
git push
132156
- name: Build package
133157
run: |
134-
npx vsce package -o ${{ needs.build.outputs.name }}.vsix
158+
npx vsce package -o ${{ steps.set-version.outputs.name }}.vsix
135159
- name: Upload Release Asset
136160
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'
140163
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 }}
145167
- name: Publish to VSCode Marketplace
146-
shell: bash
147168
run: |
148169
[ -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
150171
- name: Publish to Open VSX Registry
151-
shell: bash
172+
timeout-minutes: 5
152173
run: |
153174
[ -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

Comments
 (0)