From 58d9222b6c76ad01f646a07084aef47fee046533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=CC=88zgu=CC=88r=20Akgu=CC=88n?= Date: Sun, 19 Nov 2023 12:24:32 +0000 Subject: [PATCH] update github actions. one for testing and another for automatically making a release from tags --- .github/workflows/release.yml | 68 +++++++++++++++++++ .github/workflows/{workflow.yaml => test.yml} | 28 ++++---- 2 files changed, 83 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/release.yml rename .github/workflows/{workflow.yaml => test.yml} (53%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4aff2b9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,68 @@ +name: Make a release + +on: + workflow_dispatch: # can be triggered manually + push: + tags: + - "v*.*.*" + pull_request: # and for PRs (dry-run) + +permissions: + contents: write + +jobs: + + Release: + + strategy: + matrix: + os: [ubuntu-latest] + + runs-on: ${{ matrix.os }} + + steps: + + - uses: actions/checkout@v3 + name: Checkout repository + + + - name: Set version string to the commit hash + run: echo "RELEASE_VERSION=${{ github.sha }}" >> "$GITHUB_ENV" + + - name: Set version string based on trigger (ref_name if on tag) + run: echo "RELEASE_VERSION=${{ github.ref_name }}" >> "$GITHUB_ENV" + if: startsWith(github.ref, 'refs/tags/') + + - name: Set version string based on trigger (PR number if a PR) + run: echo "RELEASE_VERSION=${{ github.event.pull_request.number }}" >> "$GITHUB_ENV" + if: github.event_name == 'pull_request' + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 16.x + + - run: npm install + + - run: xvfb-run -a npm test + + - run: npm test + + - name: Publish + if: success() && startsWith(github.ref, 'refs/tags/') + run: npm run deploy + env: + VSCE_PAT: ${{ secrets.VSCE_PAT }} + +# See https://github.com/softprops/action-gh-release + - name: Create Release + id: create_release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + name: ${RELEASE_VERSION} + draft: false + prerelease: false + generate_release_notes: true diff --git a/.github/workflows/workflow.yaml b/.github/workflows/test.yml similarity index 53% rename from .github/workflows/workflow.yaml rename to .github/workflows/test.yml index d78f807..d8a3e3e 100644 --- a/.github/workflows/workflow.yaml +++ b/.github/workflows/test.yml @@ -1,30 +1,32 @@ +name: Run tests + on: + workflow_dispatch: # can be triggered manually push: - branches: - - main - release: - types: - - created + pull_request: + jobs: - build: + + Test: + strategy: matrix: os: [macos-latest, ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout uses: actions/checkout@v3 + - name: Install Node.js uses: actions/setup-node@v3 with: node-version: 16.x + - run: npm install + - run: xvfb-run -a npm test - if: runner.os == 'Linux' + - run: npm test - if: runner.os != 'Linux' - - name: Publish - if: success() && startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest' - run: npm run deploy - env: - VSCE_PAT: ${{ secrets.VSCE_PAT }} \ No newline at end of file