Skip to content

Commit a4751f5

Browse files
Merge pull request #48 from daimor/ci-update
update ci
2 parents c4447d8 + 2276d24 commit a4751f5

File tree

1 file changed

+144
-132
lines changed

1 file changed

+144
-132
lines changed

.github/workflows/main.yml

Lines changed: 144 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ on:
55
branches:
66
- master
77
paths-ignore:
8-
- 'docs/**'
9-
- '.vscode/**'
10-
- '.github/**'
11-
- '*.md'
12-
- '**/*.md'
8+
- "docs/**"
9+
- ".vscode/**"
10+
- ".github/**"
11+
- "*.md"
12+
- "**/*.md"
1313
pull_request:
1414
branches:
1515
- master
1616
release:
1717
types:
18-
- created
18+
- released
1919
jobs:
2020
build:
2121
timeout-minutes: 10
@@ -24,139 +24,151 @@ jobs:
2424
matrix:
2525
os: [ubuntu-latest, windows-latest, macOS-latest]
2626
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-
- run: npm run compile
56-
- name: npm test
57-
uses: GabrielBB/[email protected]
58-
with:
59-
run: npm run test
60-
- name: Build package
61-
if: runner.os == 'Linux'
62-
run: |
63-
./node_modules/.bin/vsce package -o ./dist/${{ steps.set-version.outputs.name }}.vsix
64-
- uses: actions/upload-artifact@v2
65-
if: runner.os == 'Linux'
66-
with:
67-
name: vsix
68-
path: |
69-
./dist/${{ steps.set-version.outputs.name }}.vsix
70-
./dist/.name
71-
./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: 12.x
54+
- run: npm install
55+
- run: npm run compile
56+
- name: npm test
57+
uses: GabrielBB/[email protected]
58+
with:
59+
run: npm run test
60+
- name: Build package
61+
if: runner.os == 'Linux'
62+
run: |
63+
npx vsce package -o ${{ steps.set-version.outputs.name }}.vsix
64+
- uses: actions/upload-artifact@v2
65+
if: runner.os == 'Linux'
66+
with:
67+
name: ${{ steps.set-version.outputs.name }}.vsix
68+
path: ${{ steps.set-version.outputs.name }}.vsix
69+
- uses: actions/upload-artifact@v2
70+
if: runner.os == 'Linux'
71+
with:
72+
name: meta
73+
path: |
74+
.name
75+
.version
7276
beta:
7377
if: (github.event_name == 'push')
7478
runs-on: ubuntu-latest
7579
needs: build
7680
steps:
77-
- uses: actions/download-artifact@v2
78-
with:
79-
name: vsix
80-
path: ./dist/
81-
- name: Set an output
82-
id: set-version
83-
if: runner.os == 'Linux'
84-
run: |
85-
set -x
86-
echo ::set-output name=version::`cat ./dist/.version`
87-
echo ::set-output name=name::`cat ./dist/.name`
88-
- name: Create Release
89-
id: create_release
90-
uses: actions/create-release@v1
91-
if: runner.os == 'Linux'
92-
env:
93-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94-
with:
95-
tag_name: v${{ steps.set-version.outputs.version }}
96-
release_name: v${{ steps.set-version.outputs.version }}
97-
prerelease: ${{ github.event_name != 'release' }}
98-
body: |
99-
Changes in this release
100-
${{ steps.set-version.outputs.changelog }}
101-
- name: Upload Release Asset
102-
id: upload-release-asset
103-
uses: actions/upload-release-asset@v1
104-
if: runner.os == 'Linux'
105-
env:
106-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107-
with:
108-
upload_url: ${{ steps.create_release.outputs.upload_url }}
109-
asset_path: ./dist/${{ steps.set-version.outputs.name }}.vsix
110-
asset_name: ${{ steps.set-version.outputs.name }}.vsix
111-
asset_content_type: application/zip
81+
- uses: actions/download-artifact@v2
82+
with:
83+
name: meta
84+
path: .
85+
- name: Set an output
86+
id: set-version
87+
if: runner.os == 'Linux'
88+
run: |
89+
set -x
90+
echo ::set-output name=version::`cat .version`
91+
echo ::set-output name=name::`cat .name`
92+
- uses: actions/download-artifact@v2
93+
with:
94+
name: ${{ steps.set-version.outputs.name }}.vsix
95+
- name: Create Release
96+
id: create_release
97+
uses: actions/create-release@v1
98+
if: runner.os == 'Linux'
99+
env:
100+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101+
with:
102+
tag_name: v${{ steps.set-version.outputs.version }}
103+
release_name: v${{ steps.set-version.outputs.version }}
104+
prerelease: ${{ github.event_name != 'release' }}
105+
body: |
106+
Changes in this release
107+
${{ steps.set-version.outputs.changelog }}
108+
- name: Upload Release Asset
109+
id: upload-release-asset
110+
uses: actions/upload-release-asset@v1
111+
if: runner.os == 'Linux'
112+
env:
113+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114+
with:
115+
upload_url: ${{ steps.create_release.outputs.upload_url }}
116+
asset_path: ${{ steps.set-version.outputs.name }}.vsix
117+
asset_name: ${{ steps.set-version.outputs.name }}.vsix
118+
asset_content_type: application/zip
112119
publish:
113120
if: github.event_name == 'release'
114121
runs-on: ubuntu-latest
115122
needs: build
116123
steps:
117-
- uses: actions/checkout@v2
118-
with:
119-
ref: master
120-
token: ${{ secrets.TOKEN }}
121-
- uses: actions/download-artifact@v2
122-
with:
123-
name: vsix
124-
path: ./dist/
125-
- name: Use Node.js
126-
uses: actions/setup-node@v1
127-
with:
128-
node-version: 12.x
129-
- name: Prepare build
130-
id: set-version
131-
run: |
132-
VERSION=`cat ./dist/.version`
133-
NEXT_VERSION=`cat ./dist/.version | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
134-
echo ::set-output name=name::`cat ./dist/.name`
135-
tmp=$(mktemp)
136-
git config --global user.name 'ProjectBot'
137-
git config --global user.email '[email protected]'
138-
jq --arg version "${NEXT_VERSION}-SNAPSHOT" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
139-
git add package.json
140-
git commit -m 'auto bump version with release'
141-
jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
142-
jq '.enableProposedApi = false' package.json > "$tmp" && mv "$tmp" package.json
143-
npm install
144-
git push
145-
- name: Upload Release Asset
146-
id: upload-release-asset
147-
uses: actions/upload-release-asset@v1
148-
if: runner.os == 'Linux'
149-
env:
150-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
151-
with:
152-
upload_url: ${{ github.event.release.upload_url }}
153-
asset_path: ./dist/${{ steps.set-version.outputs.name }}.vsix
154-
asset_name: ${{ steps.set-version.outputs.name }}.vsix
155-
asset_content_type: application/zip
156-
- name: Publish to VSCode Marketplace
157-
run: |
158-
[ -n "${{ secrets.VSCE_TOKEN }}" ] && ./node_modules/.bin/vsce publish -p ${{ secrets.VSCE_TOKEN }} || true
159-
- name: Publish to Open VSX Registry
160-
run: |
161-
[ -n "${{ secrets.OVSX_TOKEN }}" ] && ./node_modules/.bin/ovsx publish --pat ${{ secrets.OVSX_TOKEN }} || true
162-
124+
- uses: actions/checkout@v2
125+
with:
126+
ref: master
127+
token: ${{ secrets.TOKEN }}
128+
- uses: actions/download-artifact@v2
129+
with:
130+
name: meta
131+
path: .
132+
- name: Use Node.js
133+
uses: actions/setup-node@v1
134+
with:
135+
node-version: 12.x
136+
- name: Prepare build
137+
id: set-version
138+
run: |
139+
VERSION=`cat .version`
140+
NEXT_VERSION=`cat .version | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
141+
echo ::set-output name=name::`cat .name`
142+
tmp=$(mktemp)
143+
git config --global user.name 'ProjectBot'
144+
git config --global user.email '[email protected]'
145+
jq --arg version "${NEXT_VERSION}-SNAPSHOT" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
146+
git add package.json
147+
git commit -m 'auto bump version with release'
148+
jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json
149+
jq '.enableProposedApi = false' package.json > "$tmp" && mv "$tmp" package.json
150+
npm install
151+
git push
152+
echo ::set-output name=ovsx::`cat .name`
153+
- uses: actions/download-artifact@v2
154+
with:
155+
name: ${{ steps.set-version.outputs.name }}.vsix
156+
- name: Upload Release Asset
157+
id: upload-release-asset
158+
uses: actions/upload-release-asset@v1
159+
if: runner.os == 'Linux'
160+
env:
161+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
162+
with:
163+
upload_url: ${{ github.event.release.upload_url }}
164+
asset_path: ${{ steps.set-version.outputs.name }}.vsix
165+
asset_name: ${{ steps.set-version.outputs.name }}.vsix
166+
asset_content_type: application/zip
167+
- name: Publish to VSCode Marketplace
168+
run: |
169+
[ -n "${{ secrets.VSCE_TOKEN }}" ] && \
170+
npx vsce publish --packagePath ${{ steps.set-version.outputs.name }}.vsix -p ${{ secrets.VSCE_TOKEN }} || true
171+
- name: Publish to Open VSX Registry
172+
run: |
173+
[ -n "${{ secrets.OVSX_TOKEN }}" ] && \
174+
npx ovsx publish --packagePath ${{ steps.set-version.outputs.name }}.vsix --pat ${{ secrets.OVSX_TOKEN }} || true

0 commit comments

Comments
 (0)