From b73d2b74873cbe848c6b2ad2a0159ba2880d07ac Mon Sep 17 00:00:00 2001 From: Hinton Date: Thu, 31 Oct 2024 11:58:37 +0100 Subject: [PATCH 1/7] Re-work publish workflow to automatically set version if not defined --- ...ish-internal.yml => publish-wasm-internal.yml} | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) rename .github/workflows/{publish-internal.yml => publish-wasm-internal.yml} (84%) diff --git a/.github/workflows/publish-internal.yml b/.github/workflows/publish-wasm-internal.yml similarity index 84% rename from .github/workflows/publish-internal.yml rename to .github/workflows/publish-wasm-internal.yml index eef5b4d0..763dd4f7 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,16 @@ jobs: exit 1 fi + - name: Version output + id: version-output + run: | + if [ -z ${{ inputs.version }} ]; then + VERSION=0.2.0-${{ github.head_ref || github.ref_name }} ${{ 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 @@ -77,6 +89,7 @@ jobs: npm version --no-git-tag-version ${{ inputs.version }} env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION: ${{needs.setup.outputs.release-version}} - name: Setup NPM run: | From 27a542d660a2c96180fbb1f3edad591c9f9c6710 Mon Sep 17 00:00:00 2001 From: Hinton Date: Thu, 31 Oct 2024 12:05:14 +0100 Subject: [PATCH 2/7] Rename back --- .../workflows/{publish-wasm-internal.yml => publish-internal.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{publish-wasm-internal.yml => publish-internal.yml} (100%) diff --git a/.github/workflows/publish-wasm-internal.yml b/.github/workflows/publish-internal.yml similarity index 100% rename from .github/workflows/publish-wasm-internal.yml rename to .github/workflows/publish-internal.yml From b2ef015f562fbf70c5fc7e8e64572ca6bffb00b1 Mon Sep 17 00:00:00 2001 From: Hinton Date: Thu, 31 Oct 2024 12:10:05 +0100 Subject: [PATCH 3/7] Add dot --- .github/workflows/publish-internal.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-internal.yml b/.github/workflows/publish-internal.yml index 763dd4f7..86cbd9ad 100644 --- a/.github/workflows/publish-internal.yml +++ b/.github/workflows/publish-internal.yml @@ -44,7 +44,7 @@ jobs: id: version-output run: | if [ -z ${{ inputs.version }} ]; then - VERSION=0.2.0-${{ github.head_ref || github.ref_name }} ${{ github.run_number }} + VERSION=0.2.0-${{ github.head_ref || github.ref_name }}.${{ github.run_number }} echo "version=$VERSION" >> $GITHUB_OUTPUT else echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT From 988ffa5f69ca61d242ea06e3dd14bebabdd7a4e2 Mon Sep 17 00:00:00 2001 From: Hinton Date: Thu, 31 Oct 2024 12:12:04 +0100 Subject: [PATCH 4/7] Use correct version --- .github/workflows/publish-internal.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-internal.yml b/.github/workflows/publish-internal.yml index 86cbd9ad..4a103ff7 100644 --- a/.github/workflows/publish-internal.yml +++ b/.github/workflows/publish-internal.yml @@ -86,7 +86,7 @@ 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}} From 63e7c510ee94d07b0e9275f8807754f53aafc4ec Mon Sep 17 00:00:00 2001 From: Hinton Date: Thu, 31 Oct 2024 12:24:27 +0100 Subject: [PATCH 5/7] Sanitize branch name --- .github/workflows/publish-internal.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-internal.yml b/.github/workflows/publish-internal.yml index 4a103ff7..9202efdd 100644 --- a/.github/workflows/publish-internal.yml +++ b/.github/workflows/publish-internal.yml @@ -44,7 +44,8 @@ jobs: id: version-output run: | if [ -z ${{ inputs.version }} ]; then - VERSION=0.2.0-${{ github.head_ref || github.ref_name }}.${{ github.run_number }} + 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 From 7053b3632d6307fcd39b5a6fdf3db161bc655fa4 Mon Sep 17 00:00:00 2001 From: Hinton Date: Thu, 31 Oct 2024 12:28:16 +0100 Subject: [PATCH 6/7] Automatically trigger wasm publish --- .github/workflows/build-wasm-internal.yml | 30 +++++++++++++++++++ ...internal.yml => publish-wasm-internal.yml} | 0 2 files changed, 30 insertions(+) rename .github/workflows/{publish-internal.yml => publish-wasm-internal.yml} (100%) diff --git a/.github/workflows/build-wasm-internal.yml b/.github/workflows/build-wasm-internal.yml index 8afcfaa2..b169a5e7 100644 --- a/.github/workflows/build-wasm-internal.yml +++ b/.github/workflows/build-wasm-internal.yml @@ -73,3 +73,33 @@ 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: 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 100% rename from .github/workflows/publish-internal.yml rename to .github/workflows/publish-wasm-internal.yml From c2397c3de766a9049d51324e90374412c4f3928a Mon Sep 17 00:00:00 2001 From: Hinton Date: Fri, 1 Nov 2024 16:47:22 +0100 Subject: [PATCH 7/7] Wait for CI to be green before auto triggering publish --- .github/workflows/build-wasm-internal.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build-wasm-internal.yml b/.github/workflows/build-wasm-internal.yml index b169a5e7..df623af8 100644 --- a/.github/workflows/build-wasm-internal.yml +++ b/.github/workflows/build-wasm-internal.yml @@ -80,6 +80,13 @@ jobs: 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: