Skip to content

Commit e923673

Browse files
committed
different fixes in github actions
1 parent 6991477 commit e923673

File tree

1 file changed

+146
-136
lines changed

1 file changed

+146
-136
lines changed

.github/workflows/main.yml

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

0 commit comments

Comments
 (0)