From 0e728426689a569d033a01166e8f18b9794a293f Mon Sep 17 00:00:00 2001 From: WofWca Date: Sun, 26 Mar 2023 16:11:56 +0400 Subject: [PATCH] chore: add GitHub action to make a release with `.xdc` file --- .github/workflows/offline-version-website.yml | 61 ++++++++++++++----- 1 file changed, 45 insertions(+), 16 deletions(-) diff --git a/.github/workflows/offline-version-website.yml b/.github/workflows/offline-version-website.yml index 4f9680856d..cdc13e39a0 100644 --- a/.github/workflows/offline-version-website.yml +++ b/.github/workflows/offline-version-website.yml @@ -3,16 +3,18 @@ name: Deploy Nuxt site to Pages on: - # Runs on pushes targeting the default branch push: - branches: ["webxdc-prototype"] + tags: + - webxdc* + # branches: ["webxdc-prototype"] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: - contents: read + # Need `contents: write` to make a release. + contents: write pages: write id-token: write @@ -23,8 +25,43 @@ concurrency: cancel-in-progress: false jobs: - # Build job - build: + release-webxdc: + # Only make a release on tags + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + # TODO refactor: steps are duplicated for both jobs. I think + # YAML can help here. + - name: Checkout + uses: actions/checkout@v3 + # https://pnpm.io/continuous-integration + - name: Set up pnpm + uses: pnpm/action-setup@v2 + with: + version: 7 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: "16" + cache: "pnpm" + - name: Install dependencies + run: pnpm install + + - name: Build + run: pnpm run build-webxdc + - name: Release + uses: softprops/action-gh-release@v1 + with: + # prerelease: ${{ contains(github.event.ref, '-beta') }} + prerelease: true + fail_on_unmatched_files: true + files: dist/*.xdc + + # Deploy to GitHub Pages. + deploy-gh-pages: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: - name: Checkout @@ -39,10 +76,11 @@ jobs: with: node-version: "16" cache: "pnpm" - - name: Setup Pages - uses: actions/configure-pages@v3 - name: Install dependencies run: pnpm install + + - name: Setup Pages + uses: actions/configure-pages@v3 - name: Build env: REPO_OWNER_AND_NAME: ${{ github.repository }} @@ -53,15 +91,6 @@ jobs: uses: actions/upload-pages-artifact@v1 with: path: ./dist - - # Deployment job - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v1