Skip to content

Commit

Permalink
add github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
lyu571 committed Nov 13, 2023
1 parent fbf8e98 commit 6dee241
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 44 deletions.
53 changes: 25 additions & 28 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
name: pr-check
on:
pull_request:
paths:
- '**.yml'
- 'src/**'
- 'config/**'
permissions: write-all
pull_request:
paths:
- "**.yml"
- "src/**"
- "config/**"
- "resource/**"
- "package.json"

jobs:
pr-check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- run: echo "ok"
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Install the vsce npm package
run: |
npm install
npm install -g vsce
- name: Run headless test
uses: coactions/setup-xvfb@v1
if: runner.os == 'Linux'
with:
run: xvfb-run -a npm test
- name: Run test
run: npm test
if: runner.os != 'Linux'
pr-check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
- run: npm install
- name: Run headless test
uses: coactions/setup-xvfb@v1
if: runner.os == 'Linux'
with:
run: xvfb-run -a npm test
- name: Run test
run: npm test
if: runner.os != 'Linux'
51 changes: 51 additions & 0 deletions .github/workflows/pre-release-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: pre-release-tag
on:
pull_request:
paths:
- "**.yml"
- "src/**"
- "config/**"
- "resource/**"
- "package.json"
types:
- labeled

jobs:
pre-release-tag:
if: ${{ github.event.label.name == 'pre-release' }}
permissions:
contents: write
runs-on: ubuntu-latest
environment: RELEASE_ENV
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
- run: npm ci

- name: Set Git identity
run: |
git config user.email "[email protected]"
git config user.name "nickyinluo"
- name: Get Current Version
id: vscode-ext-pkg-ver
uses: martinbeentjes/[email protected]

- name: "Automated Version Bump"
id: version-bump
uses: "phips28/gh-action-bump-version@master"
with:
tag-prefix: "v"
version-type: "patch"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: "Output NEW_TAG"
env:
NEW_TAG: ${{ steps.version-bump.outputs.newTag }}
OLD_VER: ${{ steps.vscode-ext-pkg-ver.outputs.current-version }}
run: echo "new tag[$NEW_TAG], old version[$OLD_VER]"
65 changes: 49 additions & 16 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,66 @@
name: pre-release
on:
pull_request:
types:
- closed
push:
branches:
- master
- feat/** # debug
tags:
- v*
- v*.*.*
- "v*"

jobs:
build:
pre-release:
if: github.event.pull_request.merged == true || startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
environment: RELEASE_ENV
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
- run: npm install
- name: Run headless test
uses: coactions/setup-xvfb@v1
if: runner.os == 'Linux'
with:
run: xvfb-run -a npm test
- run: npm test
if: runner.os != 'Linux'
- name: Pre release
- run: npm ci

- name: Set tags from commit tag
if: startsWith(github.ref, 'refs/tags/')
run: |
NEW_TAG=${GITHUB_REF#refs/tags/}
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV
echo "new tag[${{ env.NEW_TAG }}] from commit tag will be set"
- name: Get Current Version
id: vscode-ext-pkg-ver
uses: martinbeentjes/[email protected]

- name: Set tags from label
if: startsWith(github.ref, 'refs/heads/')
run: |
echo "NEW_TAG=${{ steps.vscode-ext-pkg-ver.outputs.current-version}}" >> $GITHUB_ENV
echo "new tag [${{ env.NEW_TAG }}] from label will be set"
- run: echo "NEW_TAG:[${{ env.NEW_TAG }}]"

- name: Set Git identity
run: |
git config user.email "[email protected]"
git config user.name "nickyinluo"
- name: Package extension
if: success()
run: npm run package.patch
run: |
npm run package.current
env:
VSCE_PAT: ${{ secrets.VS_MARKETPLACE_TOKEN }}

- name: Pre-release to Github
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ env.NEW_TAG }}
prerelease: true
title: "v${{ env.NEW_TAG }}-beta"
files: |
vscode-tencentcloud-terraform-*.vsix

0 comments on commit 6dee241

Please sign in to comment.