diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index e1a9887..f980407 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -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' \ No newline at end of file + 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' \ No newline at end of file diff --git a/.github/workflows/pre-release-tag.yml b/.github/workflows/pre-release-tag.yml new file mode 100644 index 0000000..2a45e9a --- /dev/null +++ b/.github/workflows/pre-release-tag.yml @@ -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 "nickyinluo@tencent.com" + git config user.name "nickyinluo" + + - name: Get Current Version + id: vscode-ext-pkg-ver + uses: martinbeentjes/npm-get-version-action@v1.3.1 + + - 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]" \ No newline at end of file diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index c649453..2940ad4 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -1,16 +1,20 @@ 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 @@ -18,16 +22,45 @@ jobs: 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/npm-get-version-action@v1.3.1 + + - 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 "nickyinluo@tencent.com" + 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 \ No newline at end of file