Skip to content

Commit

Permalink
Re-work publish workflow to automatically set version if not defined (#…
Browse files Browse the repository at this point in the history
…17)

Publish wasm automatically on merge to main. Determine version from
job-id and branch.
  • Loading branch information
Hinton authored Nov 4, 2024
1 parent 1d89786 commit 8afb703
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build-wasm-internal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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',
})
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
- Dry Run
version:
description: "Release Version"
required: true
required: false

defaults:
run:
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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: |
Expand Down

0 comments on commit 8afb703

Please sign in to comment.