diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index e116281..e310bc5 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -10,11 +10,25 @@ permissions: contents: write jobs: + set-version: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.get_version.outputs.tag }} + steps: + - name: Set version number + id: get_version + run: | + version="${{ github.ref_name }}" + echo "tag=$version" >> $GITHUB_OUTPUT + create-binaries: + needs: set-version uses: ./.github/workflows/create-artifact.yml + with: + version: ${{ needs.set-version.outputs.version }} build: - needs: create-binaries + needs: [set-version, create-binaries] runs-on: ubuntu-latest steps: @@ -34,14 +48,8 @@ jobs: npm i -g @aikidosec/safe-chain safe-chain setup-ci - - name: Set version number - id: get_version - run: | - version="${{ github.ref_name }}" - echo "tag=$version" >> $GITHUB_OUTPUT - - name: Set the version in safe-chain package - run: npm --no-git-tag-version version ${{ steps.get_version.outputs.tag }} --workspace=packages/safe-chain + run: npm --no-git-tag-version version ${{ needs.set-version.outputs.version }} --workspace=packages/safe-chain - name: Install dependencies run: npm ci @@ -55,10 +63,10 @@ jobs: cp LICENSE packages/safe-chain/ cp -r docs packages/safe-chain/ - - name: Publish to npm - run: | - echo "Publishing version ${{ steps.get_version.outputs.tag }} to NPM" - npm publish --workspace=packages/safe-chain --access public --provenance + # - name: Publish to npm + # run: | + # echo "Publishing version ${{ steps.get_version.outputs.tag }} to NPM" + # npm publish --workspace=packages/safe-chain --access public --provenance - name: Download all binary artifacts uses: actions/download-artifact@v4 @@ -71,7 +79,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh release upload ${{ steps.get_version.outputs.tag }} \ + gh release upload ${{ needs.set-version.outputs.version }} \ binaries/safe-chain-macos-x64/* \ binaries/safe-chain-macos-arm64/* \ binaries/safe-chain-linux-x64/* \ diff --git a/.github/workflows/create-artifact.yml b/.github/workflows/create-artifact.yml index 7d573e5..ad43a9d 100644 --- a/.github/workflows/create-artifact.yml +++ b/.github/workflows/create-artifact.yml @@ -3,6 +3,11 @@ name: Create binaries on: pull_request: workflow_call: + inputs: + version: + description: 'Version to set in package.json' + required: false + type: string jobs: create-binaries: @@ -59,6 +64,10 @@ jobs: npm i -g @aikidosec/safe-chain safe-chain setup-ci + - name: Set the version in safe-chain package + if: inputs.version != '' + run: npm --no-git-tag-version version ${{ inputs.version }} --workspace=packages/safe-chain + - name: Install dependencies run: npm ci --ignore-scripts