Skip to content

Commit 6dee241

Browse files
committed
add github workflow
1 parent fbf8e98 commit 6dee241

File tree

3 files changed

+125
-44
lines changed

3 files changed

+125
-44
lines changed

.github/workflows/pr-check.yml

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,29 @@
11
name: pr-check
22
on:
3-
pull_request:
4-
paths:
5-
- '**.yml'
6-
- 'src/**'
7-
- 'config/**'
8-
permissions: write-all
3+
pull_request:
4+
paths:
5+
- "**.yml"
6+
- "src/**"
7+
- "config/**"
8+
- "resource/**"
9+
- "package.json"
910

1011
jobs:
11-
pr-check:
12-
runs-on: ubuntu-latest
13-
steps:
14-
- name: Checkout
15-
uses: actions/checkout@v3
16-
- run: echo "ok"
17-
- name: Install Node.js
18-
uses: actions/setup-node@v3
19-
with:
20-
node-version: 16.x
21-
- name: Install the vsce npm package
22-
run: |
23-
npm install
24-
npm install -g vsce
25-
- name: Run headless test
26-
uses: coactions/setup-xvfb@v1
27-
if: runner.os == 'Linux'
28-
with:
29-
run: xvfb-run -a npm test
30-
- name: Run test
31-
run: npm test
32-
if: runner.os != 'Linux'
12+
pr-check:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
- name: Install Node.js
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: 16.x
21+
- run: npm install
22+
- name: Run headless test
23+
uses: coactions/setup-xvfb@v1
24+
if: runner.os == 'Linux'
25+
with:
26+
run: xvfb-run -a npm test
27+
- name: Run test
28+
run: npm test
29+
if: runner.os != 'Linux'

.github/workflows/pre-release-tag.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: pre-release-tag
2+
on:
3+
pull_request:
4+
paths:
5+
- "**.yml"
6+
- "src/**"
7+
- "config/**"
8+
- "resource/**"
9+
- "package.json"
10+
types:
11+
- labeled
12+
13+
jobs:
14+
pre-release-tag:
15+
if: ${{ github.event.label.name == 'pre-release' }}
16+
permissions:
17+
contents: write
18+
runs-on: ubuntu-latest
19+
environment: RELEASE_ENV
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v3
23+
- name: Install Node.js
24+
uses: actions/setup-node@v3
25+
with:
26+
node-version: 16.x
27+
- run: npm ci
28+
29+
- name: Set Git identity
30+
run: |
31+
git config user.email "[email protected]"
32+
git config user.name "nickyinluo"
33+
34+
- name: Get Current Version
35+
id: vscode-ext-pkg-ver
36+
uses: martinbeentjes/[email protected]
37+
38+
- name: "Automated Version Bump"
39+
id: version-bump
40+
uses: "phips28/gh-action-bump-version@master"
41+
with:
42+
tag-prefix: "v"
43+
version-type: "patch"
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
47+
- name: "Output NEW_TAG"
48+
env:
49+
NEW_TAG: ${{ steps.version-bump.outputs.newTag }}
50+
OLD_VER: ${{ steps.vscode-ext-pkg-ver.outputs.current-version }}
51+
run: echo "new tag[$NEW_TAG], old version[$OLD_VER]"

.github/workflows/pre-release.yml

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,66 @@
11
name: pre-release
22
on:
3+
pull_request:
4+
types:
5+
- closed
36
push:
4-
branches:
5-
- master
6-
- feat/** # debug
77
tags:
8-
- v*
9-
- v*.*.*
8+
- "v*"
109

1110
jobs:
12-
build:
11+
pre-release:
12+
if: github.event.pull_request.merged == true || startsWith(github.ref, 'refs/tags/')
13+
permissions:
14+
contents: write
15+
pull-requests: write
1316
runs-on: ubuntu-latest
17+
environment: RELEASE_ENV
1418
steps:
1519
- name: Checkout
1620
uses: actions/checkout@v3
1721
- name: Install Node.js
1822
uses: actions/setup-node@v3
1923
with:
2024
node-version: 16.x
21-
- run: npm install
22-
- name: Run headless test
23-
uses: coactions/setup-xvfb@v1
24-
if: runner.os == 'Linux'
25-
with:
26-
run: xvfb-run -a npm test
27-
- run: npm test
28-
if: runner.os != 'Linux'
29-
- name: Pre release
25+
- run: npm ci
26+
27+
- name: Set tags from commit tag
28+
if: startsWith(github.ref, 'refs/tags/')
29+
run: |
30+
NEW_TAG=${GITHUB_REF#refs/tags/}
31+
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV
32+
echo "new tag[${{ env.NEW_TAG }}] from commit tag will be set"
33+
34+
- name: Get Current Version
35+
id: vscode-ext-pkg-ver
36+
uses: martinbeentjes/[email protected]
37+
38+
- name: Set tags from label
39+
if: startsWith(github.ref, 'refs/heads/')
40+
run: |
41+
echo "NEW_TAG=${{ steps.vscode-ext-pkg-ver.outputs.current-version}}" >> $GITHUB_ENV
42+
echo "new tag [${{ env.NEW_TAG }}] from label will be set"
43+
44+
- run: echo "NEW_TAG:[${{ env.NEW_TAG }}]"
45+
46+
- name: Set Git identity
47+
run: |
48+
git config user.email "[email protected]"
49+
git config user.name "nickyinluo"
50+
51+
- name: Package extension
3052
if: success()
31-
run: npm run package.patch
53+
run: |
54+
npm run package.current
3255
env:
3356
VSCE_PAT: ${{ secrets.VS_MARKETPLACE_TOKEN }}
57+
58+
- name: Pre-release to Github
59+
uses: "marvinpinto/action-automatic-releases@latest"
60+
with:
61+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
62+
automatic_release_tag: ${{ env.NEW_TAG }}
63+
prerelease: true
64+
title: "v${{ env.NEW_TAG }}-beta"
65+
files: |
66+
vscode-tencentcloud-terraform-*.vsix

0 commit comments

Comments
 (0)