Skip to content

Commit

Permalink
Merge branch 'main' of github.com:bitwarden/sdk into cargo-tie-versions
Browse files Browse the repository at this point in the history
# Conflicts:
#	crates/bitwarden-json/Cargo.toml
#	crates/bws/Cargo.toml
#	crates/sdk-schemas/Cargo.toml
  • Loading branch information
Hinton committed Apr 9, 2024
2 parents 77458a1 + c272758 commit 3610fda
Show file tree
Hide file tree
Showing 115 changed files with 1,655 additions and 803 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install rust
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 # stable
uses: dtolnay/rust-toolchain@dc6353516c68da0f06325f42ad880f76a5e77ec9 # stable
with:
toolchain: stable

Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
fetch-depth: 0

- name: Install rust
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 # stable
uses: dtolnay/rust-toolchain@dc6353516c68da0f06325f42ad880f76a5e77ec9 # stable
with:
toolchain: stable

Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/build-cli-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ name: Build bws Docker image

on:
push:
paths:
- "crates/bws/**"
branches:
- "main"
- "rc"
- "hotfix-rc"
workflow_dispatch:
pull_request:
paths:
- ".github/workflows/build-cli-docker.yml"
- "crates/bws/**"

env:
_AZ_REGISTRY: bitwardenprod.azurecr.io
Expand Down Expand Up @@ -106,7 +105,7 @@ jobs:
platforms: |
linux/amd64,
linux/arm64/v8
push: ${{ env.is_publish_branch }}
push: true
tags: ${{ steps.tag-list.outputs.tags }}
secrets: |
"GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install rust
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 # stable
uses: dtolnay/rust-toolchain@dc6353516c68da0f06325f42ad880f76a5e77ec9 # stable
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install rust
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 # stable
uses: dtolnay/rust-toolchain@dc6353516c68da0f06325f42ad880f76a5e77ec9 # stable
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
Expand Down Expand Up @@ -260,7 +260,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install rust
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 # stable
uses: dtolnay/rust-toolchain@dc6353516c68da0f06325f42ad880f76a5e77ec9 # stable
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
Expand Down Expand Up @@ -411,7 +411,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install rust
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 # stable
uses: dtolnay/rust-toolchain@dc6353516c68da0f06325f42ad880f76a5e77ec9 # stable
with:
toolchain: stable

Expand Down
31 changes: 26 additions & 5 deletions .github/workflows/build-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
push:
branches:
- main
- rc
- hotfix-rc
pull_request:
workflow_dispatch:

jobs:
generate_schemas:
Expand All @@ -12,12 +16,31 @@ jobs:
build_rust:
uses: ./.github/workflows/build-rust-cross-platform.yml

version:
name: Get version
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install xmllint
run: sudo apt-get install -y libxml2-utils

- name: Get version
id: version
run: |
VERSION=$(xmllint --xpath 'string(/Project/PropertyGroup/Version)' languages/csharp/Bitwarden.Sdk/Bitwarden.Sdk.csproj)
echo "version=$VERSION" >> $GITHUB_OUTPUT
build_dotnet:
name: Build .NET
runs-on: ubuntu-22.04
needs:
- generate_schemas
- build_rust
- version

steps:
- name: Checkout Repository
Expand Down Expand Up @@ -58,21 +81,19 @@ jobs:
name: libbitwarden_c_files-x86_64-pc-windows-msvc
path: languages/csharp/Bitwarden.Sdk/windows-x64

- name: Build .NET 6 Project
- name: Build .NET Project
working-directory: languages/csharp/Bitwarden.Sdk
run: |
dotnet restore
dotnet build --configuration Release
- name: Pack NuGet Package
env:
VERSION: 0.0.1
run: dotnet pack --configuration Release -p:PackageID=Bitwarden.Sdk -p:Version=${VERSION} --output ./nuget-output /nologo /v:n
run: dotnet pack --configuration Release --output ./nuget-output /nologo /v:n
working-directory: languages/csharp/Bitwarden.Sdk

- name: Upload NuGet package
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: Bitwarden.Sdk.0.0.1.nupkg
name: Bitwarden.Sdk.${{ needs.version.outputs.version }}.nupkg
path: |
./languages/csharp/Bitwarden.Sdk/nuget-output/*.nupkg
2 changes: 1 addition & 1 deletion .github/workflows/build-napi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
cache-dependency-path: crates/bitwarden-napi/package-lock.json

- name: Install rust
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 # stable
uses: dtolnay/rust-toolchain@dc6353516c68da0f06325f42ad880f76a5e77ec9 # stable
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-python-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
node-version: 18

- name: Install rust
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 # stable
uses: dtolnay/rust-toolchain@dc6353516c68da0f06325f42ad880f76a5e77ec9 # stable
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-rust-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install rust
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 # stable
uses: dtolnay/rust-toolchain@dc6353516c68da0f06325f42ad880f76a5e77ec9 # stable
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install rust
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 # stable
uses: dtolnay/rust-toolchain@dc6353516c68da0f06325f42ad880f76a5e77ec9 # stable
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-rust-cross-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install rust
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 # stable
uses: dtolnay/rust-toolchain@dc6353516c68da0f06325f42ad880f76a5e77ec9 # stable
with:
toolchain: stable

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/direct-minimal-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install rust
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 # stable
uses: dtolnay/rust-toolchain@dc6353516c68da0f06325f42ad880f76a5e77ec9 # stable
with:
toolchain: nightly
targets: ${{ matrix.settings.target }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate_schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install rust
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 # stable
uses: dtolnay/rust-toolchain@dc6353516c68da0f06325f42ad880f76a5e77ec9 # stable
with:
toolchain: stable

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install rust
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 # stable
uses: dtolnay/rust-toolchain@dc6353516c68da0f06325f42ad880f76a5e77ec9 # stable
with:
toolchain: stable

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/memory-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
sudo apt -y install gdb
- name: Install rust
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 # stable
uses: dtolnay/rust-toolchain@dc6353516c68da0f06325f42ad880f76a5e77ec9 # stable
with:
toolchain: stable

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/minimum-rust-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install rust
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 # stable
uses: dtolnay/rust-toolchain@dc6353516c68da0f06325f42ad880f76a5e77ec9 # stable
with:
# Important: When updating this, make sure to update the Readme file
# and also the `rust-version` field in all the `Cargo.toml`.
Expand Down
106 changes: 57 additions & 49 deletions .github/workflows/publish-dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,70 +1,78 @@
name: Deploy NuGet Package
name: Publish .NET NuGet
run-name: Publish .NET NuGet Package ${{ inputs.release_type }}

on:
workflow_dispatch:
inputs:
version_number:
description: "New Version"
release_type:
description: "Release Options"
required: true
default: "Release"
type: choice
options:
- Release
- Dry Run

jobs:
generate_schemas:
uses: ./.github/workflows/generate_schemas.yml

build_rust:
uses: ./.github/workflows/build-rust-cross-platform.yml
env:
_KEY_VAULT: "bitwarden-ci"

deploy:
name: Deploy
jobs:
validate:
name: Setup
runs-on: ubuntu-22.04
needs:
- generate_schemas
- build_rust

outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout Repository
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Download C# schemas artifact
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
with:
name: schemas.cs
path: languages/csharp/Bitwarden.Sdk
- name: Branch check
if: ${{ inputs.release_type != 'Dry Run' }}
run: |
if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then
echo "==================================="
echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches"
echo "==================================="
exit 1
fi
- name: Set up .NET Core
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0
with:
global-json-file: languages/csharp/global.json
- name: Install xmllint
run: sudo apt-get install -y libxml2-utils

- name: Download x86_64-apple-darwin files
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
with:
name: libbitwarden_c_files-x86_64-apple-darwin
path: languages/csharp/Bitwarden.Sdk/macos-x64
- name: Get version
id: version
run: |
VERSION=$(xmllint --xpath 'string(/Project/PropertyGroup/Version)' languages/csharp/Bitwarden.Sdk/Bitwarden.Sdk.csproj)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Download aarch64-apple-darwin files
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
deploy:
name: Deploy
runs-on: ubuntu-22.04
needs: validate
steps:
- name: Download NuGet package
uses: bitwarden/gh-actions/download-artifacts@main
with:
name: libbitwarden_c_files-aarch64-apple-darwin
path: languages/csharp/Bitwarden.Sdk/macos-arm64
workflow: build-dotnet.yml
workflow_conclusion: success
branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }}
artifacts: Bitwarden.Sdk.${{ needs.validate.outputs.version }}.nupkg
path: ./nuget-output

- name: Download x86_64-unknown-linux-gnu files
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
- name: Login to Azure - Prod Subscription
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
with:
name: libbitwarden_c_files-x86_64-unknown-linux-gnu
path: languages/csharp/Bitwarden.Sdk/linux-x64
creds: ${{ secrets.AZURE_CI_SERVICE_PRINCIPAL }}

- name: Download x86_64-pc-windows-msvc files
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
- name: Retrieve secrets
id: retrieve-secrets
uses: bitwarden/gh-actions/get-keyvault-secrets@main
with:
name: libbitwarden_c_files-x86_64-pc-windows-msvc
path: languages/csharp/Bitwarden.Sdk/windows-x64

- name: Pack NuGet Package
env:
VERSION: ${{ github.event.inputs.version_number }}
run: dotnet pack --configuration Release -p:PackageID=Bitwarden.Sdk -p:Version=${VERSION} --output ./nuget-output /nologo /v:n
working-directory: languages/csharp/Bitwarden.Sdk
keyvault: ${{ env._KEY_VAULT }}
secrets: "nuget-api-key"

- name: Publish NuGet Package
run: dotnet nuget push ./languages/csharp/Bitwarden.Sdk/nuget-output/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
if: ${{ inputs.release_type != 'Dry Run' }}
env:
NUGET_API_KEY: ${{ steps.retrieve-secrets.outputs.nuget-api-key }}
run: dotnet nuget push ./nuget-output/*.nupkg -k ${{ env.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
Loading

0 comments on commit 3610fda

Please sign in to comment.