diff --git a/.github/workflows/build-wasm-internal.yml b/.github/workflows/build-wasm-internal.yml index 8afcfaa2..df623af8 100644 --- a/.github/workflows/build-wasm-internal.yml +++ b/.github/workflows/build-wasm-internal.yml @@ -73,3 +73,40 @@ jobs: name: sdk-internal path: ${{ github.workspace }}/languages/js/sdk-internal/* if-no-files-found: error + + trigger-wasm-publish: + name: Trigger WASM publish + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-22.04 + needs: build + steps: + - name: Wait for Tests + uses: lewagon/wait-on-check-action@ccfb013c15c8afb7bf2b7c028fb74dc5a068cccc # v1.3.4 + with: + ref: ${{ github.ref }} + check-name: "Rust tests / CI is green" + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Login to Azure - CI Subscription + uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 + with: + creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} + + - name: Retrieve github PAT secrets + id: retrieve-secret-pat + uses: bitwarden/gh-actions/get-keyvault-secrets@main + with: + keyvault: "bitwarden-ci" + secrets: "github-pat-bitwarden-devops-bot-repo-scope" + + - name: Trigger WASM publish + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + github-token: ${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }} + script: | + await github.rest.actions.createWorkflowDispatch({ + owner: 'bitwarden', + repo: 'sdk-internal', + workflow_id: 'publish-wasm-internal.yml', + ref: 'main', + }) diff --git a/.github/workflows/publish-internal.yml b/.github/workflows/publish-wasm-internal.yml similarity index 81% rename from .github/workflows/publish-internal.yml rename to .github/workflows/publish-wasm-internal.yml index eef5b4d0..9202efdd 100644 --- a/.github/workflows/publish-internal.yml +++ b/.github/workflows/publish-wasm-internal.yml @@ -14,7 +14,7 @@ on: - Dry Run version: description: "Release Version" - required: true + required: false defaults: run: @@ -24,6 +24,8 @@ jobs: setup: name: Setup runs-on: ubuntu-22.04 + outputs: + release-version: ${{ steps.version-output.outputs.version }} steps: - name: Checkout repo uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 @@ -38,6 +40,17 @@ jobs: exit 1 fi + - name: Version output + id: version-output + run: | + if [ -z ${{ inputs.version }} ]; then + BRANCH=${{ github.head_ref || github.ref_name }} + VERSION=0.2.0-${BRANCH/\//-}.${{ github.run_number }} + echo "version=$VERSION" >> $GITHUB_OUTPUT + else + echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT + fi + npm: name: Publish NPM runs-on: ubuntu-22.04 @@ -74,9 +87,10 @@ jobs: - name: Set version run: | - npm version --no-git-tag-version ${{ inputs.version }} + npm version --no-git-tag-version $VERSION env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION: ${{needs.setup.outputs.release-version}} - name: Setup NPM run: |