-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PM-12967] Create bitwarden-wasm-internal #1089
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
22ef11f
Create bitwarden-wasm-internal
Hinton 570c96a
Undo cargo changes
Hinton 468c461
Build sdk internal
Hinton 6c6e7f6
Fix fallback script
Hinton 8214f82
Tweak sdk-internal to work properly
Hinton 0e5f326
Only publish from main
Hinton 48536e7
Add missing DeviceType
Hinton bb20e46
Merge branch 'main' of github.com:bitwarden/sdk into ps/bitwarden-wasโฆ
Hinton 2e9a13b
Split build and publish workflows
Hinton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
name: Build @bitwarden/sdk-internal | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- "main" | ||
- "rc" | ||
- "hotfix-rc" | ||
workflow_dispatch: | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: crates/bitwarden-wasm-internal | ||
|
||
jobs: | ||
build: | ||
name: Building @bitwarden/sdk-wasm-internal | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 | ||
with: | ||
node-version: 20 | ||
registry-url: "https://npm.pkg.github.com" | ||
cache: "npm" | ||
|
||
- name: Install dependencies | ||
run: npm i -g binaryen | ||
|
||
- name: Install rust | ||
uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable | ||
with: | ||
toolchain: stable | ||
targets: wasm32-unknown-unknown | ||
|
||
- name: Cache cargo registry | ||
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 | ||
with: | ||
key: wasm-cargo-cache | ||
|
||
- name: Install wasm-bindgen-cli | ||
run: cargo install wasm-bindgen-cli | ||
|
||
- name: Build | ||
run: ./build.sh -r | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 | ||
with: | ||
name: sdk-internal | ||
path: ${{ github.workspace }}/languages/js/sdk-internal/* | ||
if-no-files-found: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
--- | ||
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 | ||
default: "latest" | ||
|
||
defaults: | ||
run: | ||
working-directory: languages/js/sdk-internal | ||
|
||
jobs: | ||
setup: | ||
name: Setup | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
release-version: ${{ steps.version-output.outputs.version }} | ||
tag_name: ${{ steps.version-output.outputs.tag_name }} | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
|
||
- 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 | ||
run: | | ||
if [[ "${{ inputs.version }}" == "latest" || "${{ inputs.version }}" == "" ]]; then | ||
TAG_NAME=$(curl "https://api.github.com/repos/bitwarden/sdk/releases" | jq -c '.[] | select(.tag_name | contains("sdk-internal")) | .tag_name' | head -1) | ||
VERSION=$(echo $TAG_NAME | grep -ohE '20[0-9]{2}\.([1-9]|1[0-2])\.[0-9]+') | ||
echo "Latest Released Version: $VERSION" | ||
echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
|
||
echo "Latest Released Tag name: $TAG_NAME" | ||
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT | ||
else | ||
echo "Release Version: ${{ inputs.version }}" | ||
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT | ||
fi | ||
|
||
npm: | ||
name: Publish NPM | ||
runs-on: ubuntu-22.04 | ||
needs: setup | ||
env: | ||
_VERSION: ${{ needs.setup.outputs.release-version }} | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
with: | ||
ref: ${{ needs.setup.outputs.tag_name }} | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Login to Azure | ||
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 | ||
with: | ||
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} | ||
|
||
- name: Retrieve secrets | ||
id: retrieve-secrets | ||
uses: bitwarden/gh-actions/get-keyvault-secrets@main | ||
with: | ||
keyvault: "bitwarden-ci" | ||
secrets: "npm-api-key" | ||
|
||
- name: Download artifact | ||
run: | | ||
wget https://github.com/bitwarden/sdk/releases/download/sdk-internal-v${{ env._VERSION }}/sdk-internal.zip | ||
unzip sdk-internal.zip | ||
rm sdk-internal.zip | ||
|
||
- name: Create GitHub deployment | ||
if: ${{ inputs.release_type != 'Dry Run' }} | ||
uses: chrnorm/deployment-action@55729fcebec3d284f60f5bcabbd8376437d696b1 # v2.0.7 | ||
id: deployment | ||
with: | ||
token: "${{ secrets.GITHUB_TOKEN }}" | ||
initial-status: "in_progress" | ||
environment: "Bitwarden SDK Internal - Production" | ||
description: "Deployment ${{ env._VERSION }} from branch ${{ github.ref_name }}" | ||
task: release | ||
|
||
- name: Setup NPM | ||
run: | | ||
echo 'registry="https://registry.npmjs.org/"' > ./.npmrc | ||
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ./.npmrc | ||
|
||
echo 'registry="https://registry.npmjs.org/"' > ~/.npmrc | ||
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc | ||
env: | ||
NPM_TOKEN: ${{ steps.retrieve-secrets.outputs.npm-api-key }} | ||
|
||
- name: Publish NPM | ||
if: ${{ inputs.release_type != 'Dry Run' }} | ||
run: npm publish --access public --registry=https://registry.npmjs.org/ --userconfig=./.npmrc | ||
|
||
- name: Update deployment status to Success | ||
if: ${{ inputs.release_type != 'Dry Run' && success() }} | ||
uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 | ||
with: | ||
token: "${{ secrets.GITHUB_TOKEN }}" | ||
state: "success" | ||
deployment-id: ${{ steps.deployment.outputs.deployment_id }} | ||
|
||
- name: Update deployment status to Failure | ||
if: ${{ inputs.release_type != 'Dry Run' && failure() }} | ||
uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 | ||
with: | ||
token: "${{ secrets.GITHUB_TOKEN }}" | ||
state: "failure" | ||
deployment-id: ${{ steps.deployment.outputs.deployment_id }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[package] | ||
name = "bitwarden-wasm-internal" | ||
version = "0.1.0" | ||
publish = false | ||
|
||
authors.workspace = true | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
license-file.workspace = true | ||
keywords.workspace = true | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
bitwarden = { workspace = true, features = ["internal", "wasm"] } | ||
console_error_panic_hook = "0.1.7" | ||
console_log = { version = "1.0.0", features = ["color"] } | ||
js-sys = "0.3.68" | ||
log = "0.4.20" | ||
serde_json = ">=1.0.96, <2.0" | ||
wasm-bindgen = { version = "0.2.91", features = ["serde-serialize"] } | ||
wasm-bindgen-futures = "0.4.41" | ||
|
||
[lints] | ||
workspace = true |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: should this use the workspace version?
wasm-bindgen = { workspace = true }
I haven't seen this syntax before, but I saw that you did this in
crates/bitwarden-core/Cargo.toml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we use an explicit version here while the workspace uses ranges.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok, is that because this version is used for building and in that case
wasm-bindgen
andwasm-bindgen-cli
versions need to be exact, while for the other stuff we can be more relaxed with the version? Do you think that different versions can cause issues? Or should it be fine since we're using the same minor versions?