From b6cf39250e2c6c63e5ebae4532ba9d44816321d3 Mon Sep 17 00:00:00 2001 From: Matthias Behr Date: Sat, 23 Apr 2022 17:38:34 +0200 Subject: [PATCH] ci: introduce build_tag.yml to build and deploy --- .github/workflows/build.yml | 6 +-- .github/workflows/build_tag.yml | 79 +++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 25 +++++++++++ package-lock.json | 35 +++++++++++++++ package.json | 7 +++ 5 files changed, 149 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build_tag.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3dade47a..21d1f340 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,9 @@ name: build on: push: branches: - - "**" - tags: - - "v*" + - "ci/**" + # tags: + # - "v*" jobs: build: diff --git a/.github/workflows/build_tag.yml b/.github/workflows/build_tag.yml new file mode 100644 index 00000000..cc0b9802 --- /dev/null +++ b/.github/workflows/build_tag.yml @@ -0,0 +1,79 @@ +name: build_tag +on: + workflow_call: + inputs: + tagname: + required: true + type: string + +jobs: + build: + strategy: + matrix: + include: + - os: windows-latest + platform: win32 + arch: x64 + npm_config_arch: x64 + - os: windows-latest + platform: win32 + arch: ia32 + npm_config_arch: ia32 + # - os: windows-latest + # platform: win32 + # arch: arm64 + # npm_config_arch: arm + - os: ubuntu-latest + platform: linux + arch: x64 + npm_config_arch: x64 + - os: ubuntu-latest + platform: linux + arch: arm64 + npm_config_arch: arm64 + # - os: ubuntu-latest + # platform: linux + # arch: armhf + # npm_config_arch: arm + - os: ubuntu-latest + platform: alpine + arch: x64 + npm_config_arch: x64 + - os: macos-latest + platform: darwin + arch: x64 + npm_config_arch: x64 + - os: macos-latest + platform: darwin + arch: arm64 + npm_config_arch: arm64 + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ inputs.tagname }} + - uses: actions/setup-node@v2 + with: + node-version: 14.x + - run: npm install + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + npm_config_arch: ${{ matrix.npm_config_arch }} + - run: npx vsce --version + - shell: pwsh + run: echo "target=${{ matrix.platform }}-${{ matrix.arch }}" >> $env:GITHUB_ENV + - run: npx vsce package --target ${{ env.target }} + - uses: actions/upload-artifact@v2 + with: + name: ${{ env.target }} + path: "*.vsix" + + publish: + runs-on: ubuntu-latest + needs: build + if: success() + steps: + - uses: actions/download-artifact@v2 + - run: npx vsce publish --packagePath $(find . -iname *.vsix) + env: + VSCE_PAT: ${{ secrets.VSCE_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b1ee30fc..343d3bdb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,6 +6,8 @@ on: jobs: release: runs-on: ubuntu-latest + outputs: + NEXTVERSION: ${{ steps.relver.outputs.nextVer }} steps: - name: Checkout uses: actions/checkout@v2 @@ -20,7 +22,30 @@ jobs: - name: Install dependencies run: npm ci - name: Release + id: relver env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VSCE_PAT: ${{ secrets.VSCE_TOKEN }} run: npx semantic-release --debug + - name: print next version + run: echo NEXTVERSION= ${{ steps.relver.outputs.nextVer }} + - name: next version is valid + run: echo valid=${{ startsWith(steps.relver.outputs.nextVer, 'v') }} + #- name: Get new tag name + # id: get-latest-tag + # if: success() + # uses: actions-ecosystem/action-get-latest-tag@v1 + # with: + # semver_only: true + + buildAndDeploy: + #runs-on: ubuntu-latest + needs: release + if: "startsWith(needs.release.outputs.NEXTVERSION, 'v')" + #steps: + #- run: echo NEXTVERSION= ${{ needs.release.outputs.NEXTVERSION }} + #- run: echo valid=${{ startsWith(needs.release.outputs.NEXTVERSION, 'v') }} + uses: ./.github/workflows/build_tag.yml + with: + tagname: ${{ needs.release.outputs.NEXTVERSION }} + diff --git a/package-lock.json b/package-lock.json index 73d5e3db..3782b39f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,6 +28,7 @@ "@commitlint/cli": "^12.1.1", "@commitlint/config-conventional": "^12.1.1", "@semantic-release/changelog": "^5.0.1", + "@semantic-release/exec": "^5.0.0", "@semantic-release/git": "^9.0.0", "@types/glob": "^7.1.3", "@types/mocha": "^8.2.2", @@ -598,6 +599,26 @@ "integrity": "sha512-9Tj/qn+y2j+sjCI3Jd+qseGtHjOAeg7dU2/lVcqIQ9TV3QDaDXDYXcoOHU+7o2Hwh8L8ymL4gfuO7KxDs3q2zg==", "dev": true }, + "node_modules/@semantic-release/exec": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@semantic-release/exec/-/exec-5.0.0.tgz", + "integrity": "sha512-t7LWXIvDJQbuGCy2WmMG51WyaGSLTvZBv9INvcI4S0kn+QjnnVVUMhcioIqhb0r3yqqarMzHVcABFug0q0OXjw==", + "dev": true, + "dependencies": { + "@semantic-release/error": "^2.1.0", + "aggregate-error": "^3.0.0", + "debug": "^4.0.0", + "execa": "^4.0.0", + "lodash": "^4.17.4", + "parse-json": "^5.0.0" + }, + "engines": { + "node": ">=10.18" + }, + "peerDependencies": { + "semantic-release": ">=16.0.0 <18.0.0" + } + }, "node_modules/@semantic-release/git": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/@semantic-release/git/-/git-9.0.0.tgz", @@ -10420,6 +10441,20 @@ "integrity": "sha512-9Tj/qn+y2j+sjCI3Jd+qseGtHjOAeg7dU2/lVcqIQ9TV3QDaDXDYXcoOHU+7o2Hwh8L8ymL4gfuO7KxDs3q2zg==", "dev": true }, + "@semantic-release/exec": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@semantic-release/exec/-/exec-5.0.0.tgz", + "integrity": "sha512-t7LWXIvDJQbuGCy2WmMG51WyaGSLTvZBv9INvcI4S0kn+QjnnVVUMhcioIqhb0r3yqqarMzHVcABFug0q0OXjw==", + "dev": true, + "requires": { + "@semantic-release/error": "^2.1.0", + "aggregate-error": "^3.0.0", + "debug": "^4.0.0", + "execa": "^4.0.0", + "lodash": "^4.17.4", + "parse-json": "^5.0.0" + } + }, "@semantic-release/git": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/@semantic-release/git/-/git-9.0.0.tgz", diff --git a/package.json b/package.json index 9f40fce0..6676048e 100644 --- a/package.json +++ b/package.json @@ -784,6 +784,7 @@ "mocha": "^8.4.0", "semantic-release": "^17.4.7", "semantic-release-vsce": "^3.5.0", + "@semantic-release/exec": "^5.0.0", "typescript": "^4.2.4", "vscode-test": "^1.5.2" }, @@ -847,6 +848,12 @@ { "message": "chore(release): ${nextRelease.version}" } + ], + [ + "@semantic-release/exec", + { + "publishCmd": "echo ::set-output name=nextVer::${nextRelease.version}" + } ] ], "preset": "conventionalcommits"