Release Go SDK Dry Run #33
Workflow file for this run
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
name: Release Go SDK | |
run-name: Release Go SDK ${{ inputs.release_type }} | |
on: | |
workflow_dispatch: | |
inputs: | |
release_type: | |
description: "Release Options" | |
required: true | |
default: "Release" | |
type: choice | |
options: | |
- Release | |
- Dry Run | |
env: | |
GO111MODULE: on | |
GO_VERSION: "^1.18" | |
_KEY_VAULT: "bitwarden-ci" | |
jobs: | |
validate: | |
name: Setup | |
runs-on: ubuntu-22.04 | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | |
- 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: Get version | |
id: version | |
run: | | |
VERSION=$(cat languages/go/.version | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+") | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
repo-sync: | |
name: Push changed files to SDK Go repo | |
runs-on: ubuntu-22.04 | |
needs: validate | |
env: | |
_BOT_EMAIL: [email protected] | |
_BOT_NAME: bitwarden-devops-bot | |
_PKG_VERSION: ${{ needs.validate.outputs.version }} | |
steps: | |
- name: Checkout SDK repo | |
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | |
with: | |
path: sdk | |
- name: Login to Azure - Prod Subscription | |
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 | |
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: "github-pat-bitwarden-devops-bot-repo-scope" | |
- name: Checkout SDK-Go repo | |
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | |
with: | |
repository: bitwarden/sm-sdk-go | |
path: sm-sdk-go | |
ref: main | |
token: ${{ steps.retrieve-secrets.outputs.github-pat-bitwarden-devops-bot-repo-scope }} | |
- name: Setup Git | |
working-directory: sm-sdk-go | |
run: | | |
git config --local user.email "${{ env._BOT_EMAIL }}" | |
git config --local user.name "${{ env._BOT_NAME }}" | |
- name: Download x86_64-apple-darwin artifact | |
uses: bitwarden/gh-actions/download-artifacts@main | |
with: | |
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 | |
skip_unpack: true | |
- name: Download aarch64-apple-darwin artifact | |
uses: bitwarden/gh-actions/download-artifacts@main | |
with: | |
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 | |
skip_unpack: true | |
- name: Download x86_64-unknown-linux-musl artifact | |
uses: bitwarden/gh-actions/download-artifacts@main | |
with: | |
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-musl | |
skip_unpack: true | |
- name: Download aarch64-unknown-linux-musl artifact | |
uses: bitwarden/gh-actions/download-artifacts@main | |
with: | |
workflow: build-rust-cross-platform.yml | |
workflow_conclusion: success | |
branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} | |
artifacts: libbitwarden_c_files-aarch64-unknown-linux-musl | |
skip_unpack: true | |
- name: Download x86_64-pc-windows-gnu artifact | |
uses: bitwarden/gh-actions/download-artifacts@main | |
with: | |
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-gnu | |
skip_unpack: true | |
- name: Update files | |
run: | | |
# Copy files to local sm-sdk-go repo path | |
cp --verbose -rf sdk/languages/go/. sm-sdk-go | |
# Remove the old cinterface lib files | |
rm -rf sm-sdk-go/internal/cinterface/lib/* | |
mkdir -p sm-sdk-go/internal/cinterface/lib/{darwin-{x64,arm64},linux-{x64,arm64},windows-x64} | |
- name: Extract static libs to their respective directories | |
run: | | |
unzip 'libbitwarden_c_files-x86_64-apple-darwin.zip' '*.a' -d sm-sdk-go/internal/cinterface/lib/darwin-x64 | |
unzip 'libbitwarden_c_files-aarch64-apple-darwin.zip' '*.a' -d sm-sdk-go/internal/cinterface/lib/darwin-arm64 | |
unzip 'libbitwarden_c_files-x86_64-unknown-linux-musl.zip' '*.a' -d sm-sdk-go/internal/cinterface/lib/linux-x64 | |
unzip 'libbitwarden_c_files-aarch64-unknown-linux-musl.zip' '*.a' -d sm-sdk-go/internal/cinterface/lib/linux-arm64 | |
unzip 'libbitwarden_c_files-x86_64-pc-windows-gnu.zip' '*.a' -d sm-sdk-go/internal/cinterface/lib/windows-x64 | |
- name: Download artifacts | |
uses: bitwarden/gh-actions/download-artifacts@main | |
with: | |
workflow: generate_schemas.yml | |
path: sm-sdk-go | |
workflow_conclusion: success | |
branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} | |
artifacts: schemas.go | |
- name: Push changes | |
working-directory: sm-sdk-go | |
run: | | |
git add . | |
git commit -m "Update Go SDK to ${{ github.sha }}" | |
if [[ "${{ inputs.release_type }}" == "Dry Run" ]]; then | |
echo "===================================" | |
echo "[!] Dry Run - Skipping push" | |
echo "===================================" | |
git ls-files -m | |
exit 0 | |
else | |
git push origin main | |
fi | |
- name: Create release tag on SDK Go repo | |
if: ${{ inputs.release_type != 'Dry Run' }} | |
working-directory: sm-sdk-go | |
run: | | |
# Check if tag exists, set output then exit 0 if true. | |
if git log v${{ env._PKG_VERSION }} >/dev/null 2>&1; then | |
echo "===================================" | |
echo "[!] Tag v${{ env._PKG_VERSION }} already exists" | |
echo "===================================" | |
exit 1 | |
fi | |
git tag v${{ env._PKG_VERSION }} | |
git push origin v${{ env._PKG_VERSION }} | |
github-release: | |
name: GitHub Release | |
runs-on: ubuntu-22.04 | |
needs: | |
- repo-sync | |
- validate | |
env: | |
_PKG_VERSION: ${{ needs.validate.outputs.version }} | |
steps: | |
- name: Login to Azure - Prod Subscription | |
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 | |
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: "github-pat-bitwarden-devops-bot-repo-scope" | |
- name: Download x86_64-apple-darwin artifact | |
uses: bitwarden/gh-actions/download-artifacts@main | |
with: | |
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 | |
skip_unpack: true | |
- name: Download aarch64-apple-darwin artifact | |
uses: bitwarden/gh-actions/download-artifacts@main | |
with: | |
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 | |
skip_unpack: true | |
- name: Download x86_64-unknown-linux-musl artifact | |
uses: bitwarden/gh-actions/download-artifacts@main | |
with: | |
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-musl | |
skip_unpack: true | |
- name: Download aarch64-unknown-linux-musl artifact | |
uses: bitwarden/gh-actions/download-artifacts@main | |
with: | |
workflow: build-rust-cross-platform.yml | |
workflow_conclusion: success | |
branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} | |
artifacts: libbitwarden_c_files-aarch64-unknown-linux-musl | |
skip_unpack: true | |
- name: Download x86_64-pc-windows-gnu artifact | |
uses: bitwarden/gh-actions/download-artifacts@main | |
with: | |
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-gnu | |
skip_unpack: true | |
- name: Rename build artifacts | |
run: | | |
artifacts=("x86_64-apple-darwin" "aarch64-apple-darwin" "x86_64-unknown-linux-musl" "aarch64-unknown-linux-musl" "x86_64-pc-windows-gnu") | |
for value in "${artifacts[@]}" | |
do | |
unzip libbitwarden_c_files-$value.zip -d libbitwarden_c_files-$value | |
cd libbitwarden_c_files-$value | |
zip -Rj ../libbitwarden_c_files-$value-$_PKG_VERSION.zip 'libbitwarden_c.*' | |
cd .. | |
done | |
ls ./libbitwarden_c_files-x86_64-apple-darwin-$_PKG_VERSION -lRa | |
- name: Create release | |
if: ${{ inputs.release_type != 'Dry Run' }} | |
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 | |
with: | |
tag: v${{ env._PKG_VERSION }} | |
name: v${{ env._PKG_VERSION }} | |
body: "<insert release notes here>" | |
token: ${{ steps.retrieve-secrets.outputs.github-pat-bitwarden-devops-bot-repo-scope }} | |
draft: true | |
repo: sm-sdk-go | |
owner: bitwarden | |
artifacts: "libbitwarden_c_files-x86_64-apple-darwin-${{ env._PKG_VERSION }}.zip, | |
libbitwarden_c_files-aarch64-apple-darwin-${{ env._PKG_VERSION }}.zip, | |
libbitwarden_c_files-x86_64-unknown-linux-gnu-${{ env._PKG_VERSION }}.zip, | |
libbitwarden_c_files-x86_64-pc-windows-msvc-${{ env._PKG_VERSION }}.zip" |