Skip to content

Publish @bitwarden/sdk-internal Release #344

Publish @bitwarden/sdk-internal Release

Publish @bitwarden/sdk-internal Release #344

name: Publish @bitwarden/sdk-internal
run-name: Publish @bitwarden/sdk-internal ${{ inputs.release_type }}
on:
workflow_dispatch:
inputs:
release_type:
description: "Release Options"
required: true
default: "Release"
type: choice
options:
- Release
- Dry Run
version:
description: "Release Version"
required: false
jobs:
setup:
name: Setup
runs-on: ubuntu-24.04
permissions:
contents: read
outputs:
release-version: ${{ steps.version-output.outputs.version }}
steps:
- name: Checkout repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Branch check
if: ${{ inputs.release_type != 'Dry Run' }}
run: |
if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then
echo "==================================="
echo "[!] Can only release from the 'main' branch"
echo "==================================="
exit 1
fi
- name: Version output
id: version-output
env:
BRANCH: "${{ github.head_ref || github.ref_name }}"
run: |
if [ -z ${{ inputs.version }} ]; then
VERSION=0.2.0-${BRANCH/\//-}.${{ github.run_number }}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "### NPM Version: $VERSION" >> $GITHUB_STEP_SUMMARY
else
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
echo "### NPM Version: ${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
fi
npm:
name: Publish NPM - ${{matrix.license_type.readable}}
environment: NPM
runs-on: ubuntu-24.04
needs: setup
permissions:
contents: read
id-token: write
strategy:
matrix:
license_type:
- artifact_name: "sdk-internal"
npm_folder: "npm"
readable: "open source license"
- artifact_name: "commercial-sdk-internal"
npm_folder: "bitwarden_license/npm"
readable: "commercial license"
steps:
- name: Checkout repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 24
registry-url: "https://registry.npmjs.org/"
- name: Download artifact
uses: bitwarden/gh-actions/download-artifacts@main
with:
workflow: build-wasm-internal.yml
workflow_conclusion: success
branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }}
artifacts: ${{ matrix.license_type.artifact_name }}
path: crates/bitwarden-wasm-internal/${{ matrix.license_type.npm_folder }}
- name: Set version
working-directory: crates/bitwarden-wasm-internal/${{ matrix.license_type.npm_folder }}
run: |
npm version --no-git-tag-version $VERSION
env:
VERSION: ${{needs.setup.outputs.release-version}}
- name: Publish NPM
if: ${{ inputs.release_type != 'Dry Run' }}
working-directory: crates/bitwarden-wasm-internal/${{ matrix.license_type.npm_folder }}
run: npm publish --access public --tag latest