Skip to content
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

[DEVOPS-1749] update release pipeline for C# #668

Merged
merged 7 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 81 additions & 23 deletions .github/workflows/publish-dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,65 @@
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

env:
_KEY_VAULT: "bitwarden-ci"

jobs:
generate_schemas:
uses: ./.github/workflows/generate_schemas.yml
validate:
name: Setup
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- 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: Install xmllint
run: sudo apt-get install -y libxml2-utils

build_rust:
uses: ./.github/workflows/build-rust-cross-platform.yml
- 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

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

needs: validate
steps:
- name: Checkout Repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Download C# schemas artifact
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
uses: bitwarden/gh-actions/download-artifacts@main
with:
name: schemas.cs
workflow: generate_schemas.yml
workflow_conclusion: success
branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }}
artifacts: schemas.cs
path: languages/csharp/Bitwarden.Sdk

- name: Set up .NET Core
Expand All @@ -37,34 +68,61 @@ jobs:
global-json-file: languages/csharp/global.json

- name: Download x86_64-apple-darwin files
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
uses: bitwarden/gh-actions/download-artifacts@main
with:
name: libbitwarden_c_files-x86_64-apple-darwin
workflow: build-rust-cross-platform.yml
workflow_conclusion: success
branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }}
artifacts: libbitwarden_c_files-x86_64-apple-darwin
path: languages/csharp/Bitwarden.Sdk/macos-x64

- name: Download aarch64-apple-darwin files
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
uses: bitwarden/gh-actions/download-artifacts@main
with:
name: libbitwarden_c_files-aarch64-apple-darwin
workflow: build-rust-cross-platform.yml
workflow_conclusion: success
branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }}
artifacts: libbitwarden_c_files-aarch64-apple-darwin
path: languages/csharp/Bitwarden.Sdk/macos-arm64

- name: Download x86_64-unknown-linux-gnu files
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
uses: bitwarden/gh-actions/download-artifacts@main
with:
name: libbitwarden_c_files-x86_64-unknown-linux-gnu
workflow: build-rust-cross-platform.yml
workflow_conclusion: success
branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }}
artifacts: libbitwarden_c_files-x86_64-unknown-linux-gnu
path: languages/csharp/Bitwarden.Sdk/linux-x64

- name: Download x86_64-pc-windows-msvc files
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
uses: bitwarden/gh-actions/download-artifacts@main
with:
name: libbitwarden_c_files-x86_64-pc-windows-msvc
workflow: build-rust-cross-platform.yml
workflow_conclusion: success
branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }}
artifacts: 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 }}
VERSION: ${{ needs.validate.outputs.version }}
run: dotnet pack --configuration Release -p:PackageID=Bitwarden.Sdk -p:Version=${VERSION} --output ./nuget-output /nologo /v:n
working-directory: languages/csharp/Bitwarden.Sdk

- name: Login to Azure - Prod Subscription
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
with:
creds: ${{ secrets.AZURE_CI_SERVICE_PRINCIPAL }}

- name: Retrieve secrets
id: retrieve-secrets
uses: bitwarden/gh-actions/get-keyvault-secrets@main
with:
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 ./languages/csharp/Bitwarden.Sdk/nuget-output/*.nupkg -k ${{ env.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
6 changes: 6 additions & 0 deletions .github/workflows/version-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- python-sdk
- ruby-sdk
- go-sdk
- dotnet-sdk
- php-sdk
version_number:
description: "New version (example: '2024.1.0')"
Expand Down Expand Up @@ -163,6 +164,11 @@ jobs:
if: ${{ inputs.project == 'go-sdk' }}
run: sed -i 's/[0-9]\.[0-9]\.[0-9]/${{ inputs.version_number }}/' ./languages/go/.version

### dotnet sdk
- name: Bump dotnet-sdk Version
if: ${{ inputs.project == 'dotnet-sdk' }}
run: sed -i 's/<Version>[0-9]\.[0-9]\.[0-9]<\/Version>/<Version>${{ inputs.version_number }}<\/Version>/' languages/csharp/Bitwarden.Sdk/Bitwarden.Sdk.csproj

### php sdk
- name: Bump php-sdk Version
if: ${{ inputs.project == 'php-sdk' }}
Expand Down
5 changes: 3 additions & 2 deletions languages/csharp/Bitwarden.Sdk/Bitwarden.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
<RepositoryType>Git</RepositoryType>

<PackageProjectUrl>https://bitwarden.com/products/secrets-manager/</PackageProjectUrl>
<PackageId>Bitwarden.Sdk</PackageId>
<PackageId>Bitwarden.Secrets.Sdk</PackageId>
<PackageIcon>bitwarden.png</PackageIcon>
<PackageTags>Bitwarden;Sdk;.NET</PackageTags>
<PackageTags>Bitwarden;Secrets Manager;Sdk;.NET</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<Version>0.1.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading