From 18d246314c99f8cb23f26769bf29ec11383c35a6 Mon Sep 17 00:00:00 2001 From: Ryan Goree Date: Fri, 10 Nov 2023 15:57:05 -0600 Subject: [PATCH] [hyperwasm] Consolidate workflows (#33) --- .github/workflows/build_wasm.yml | 38 ++++++++++++++++-------------- .github/workflows/publish_wasm.yml | 33 -------------------------- 2 files changed, 20 insertions(+), 51 deletions(-) delete mode 100644 .github/workflows/publish_wasm.yml diff --git a/.github/workflows/build_wasm.yml b/.github/workflows/build_wasm.yml index d60f0ce..2852440 100644 --- a/.github/workflows/build_wasm.yml +++ b/.github/workflows/build_wasm.yml @@ -1,24 +1,11 @@ name: build wasm package on: - push: - branches: - - main pull_request: branches: - main - workflow_call: - inputs: - # Allows other workflows to explicitly control whether this workflow runs - build: - description: 'Whether to build the package' - type: boolean - default: false - required: true - secrets: - HYPERDRIVE_ACCESS_KEY: - description: 'SSH key for checking out hyperdrive' - required: true + release: + types: [published] jobs: detect-changes: @@ -28,12 +15,12 @@ jobs: build: needs: detect-changes - # Run if changes are detected OR if explicitly requested by another workflow - if: needs.detect-changes.outputs.changed == 'true' || inputs.build + # Run if changes are detected OR if triggered by a release + if: (needs.detect-changes.outputs.changed == 'true') || (github.event_name == 'release' && startsWith(github.ref, 'refs/tags/hyperwasm@v')) name: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: token: ${{github.token}} @@ -49,6 +36,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: 16 + registry-url: https://npm.pkg.github.com/ - name: setup foundry uses: foundry-rs/foundry-toolchain@v1 @@ -66,3 +54,17 @@ jobs: - name: build wasm package working-directory: crates/hyperwasm run: sh build.sh + + publish: + # Run only if triggered by a release + if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/hyperwasm@v') + needs: build + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - run: npm publish + working-directory: crates/hyperwasm/pkg + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish_wasm.yml b/.github/workflows/publish_wasm.yml deleted file mode 100644 index 1b5f241..0000000 --- a/.github/workflows/publish_wasm.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: publish hyperwasm npm package - -on: - workflow_dispatch: - release: - types: [published] - -jobs: - build: - uses: ./.github/workflows/build_wasm.yml - with: - # Only run this job if the release tag starts with "hyperwasm@v" - build: ${{ startsWith(github.ref, 'refs/tags/hyperwasm@v') }} - secrets: inherit - - publish: - needs: build - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - defaults: - run: - working-directory: crates/hyperwasm/pkg - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 - with: - node-version: 16 - registry-url: https://npm.pkg.github.com/ - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}