Skip to content

Commit

Permalink
[DEVOPS-1785] Update release pipeline for ruby sdk (#614)
Browse files Browse the repository at this point in the history
## Type of change

<!-- (mark with an `X`) -->

```
- [ ] Bug fix
- [x] New feature development
- [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [x] Build/deploy pipeline (DevOps)
- [ ] Other
```

## Objective

https://bitwarden.atlassian.net/browse/DEVOPS-1785

<!--Describe what the purpose of this PR is. For example: what bug
you're fixing or what new feature you're adding-->

## Code changes

<!--Explain the changes you've made to each file or major component.
This should help the reviewer understand your changes-->
<!--Also refer to any related changes or PRs in other repositories-->

- **.github/workflows/build-rust-cross-platform.yml:** Trigger on push
to `main`, `rc` and `hotfix-rc`
- **.github/workflows/generate_schemas.yml** Trigger on push to `main`,
`rc` and `hotfix-rc`
- **.github/workflows/publish-ruby.yml** Publish ruby only on workflow
dispatch get the artifacts from build workflows instead of triggering
them
- **.github/workflows/version-bump.yml** Add ruby sdk to bump version
workflow

## Before you submit

- Please add **unit tests** where it makes sense to do so
  • Loading branch information
michalchecinski authored Feb 22, 2024
1 parent 0366e86 commit 412ae78
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 33 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/build-rust-cross-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ name: Build Rust Cross Platform

on:
workflow_call:
workflow_dispatch:
push:
branches:
- main
- rc
- hotfix-rc
paths:
- "crates/**"

jobs:
build_rust:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/generate_schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ name: Generate schemas

on:
workflow_call:
workflow_dispatch:
push:
branches:
- main
- rc
- hotfix-rc

env:
CARGO_TERM_COLOR: always
Expand Down
94 changes: 61 additions & 33 deletions .github/workflows/publish-ruby.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,43 @@
name: Publish Ruby SDK
run-name: Publish Ruby SDK ${{ inputs.release_type }}

on:
push:
branches:
- main
workflow_dispatch:
inputs:
release_type:
description: "Release Options"
required: true
default: "Release"
type: choice
options:
- Release
- Dry Run
permissions:
id-token: write
contents: write

jobs:
generate_schemas:
uses: ./.github/workflows/generate_schemas.yml
setup:
name: Setup
runs-on: ubuntu-22.04
steps:
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

build_rust:
uses: ./.github/workflows/build-rust-cross-platform.yml
- name: Branch check
if: ${{ github.event.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
build_ruby:
name: Build Ruby
publish_ruby:
name: Publish Ruby
runs-on: ubuntu-22.04
needs:
- generate_schemas
- build_rust
needs: setup
steps:
- name: Checkout Repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand All @@ -27,33 +47,48 @@ jobs:
with:
ruby-version: 3.2

- name: Download Ruby schemas artifact
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
- name: Download artifacts
uses: bitwarden/gh-actions/download-artifacts@main
with:
name: schemas.rb
workflow: generate_schemas.yml
path: languages/ruby/bitwarden_sdk_secrets/lib
workflow_conclusion: success
branch: ${{ github.event.inputs.release_type == 'Dry Run' && 'main' || github.ref_name }}
name: schemas.rb

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

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

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

- name: Download x86_64-pc-windows-msvc files
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
- name: Download x86_64-pc-windows-msvc artifact
uses: bitwarden/gh-actions/download-artifacts@main
with:
workflow: generate_schemas.yml
workflow_conclusion: success
branch: ${{ github.event.inputs.release_type == 'Dry Run' && 'main' || github.ref_name }}
name: libbitwarden_c_files-x86_64-pc-windows-msvc
path: temp/windows-x64

Expand All @@ -77,12 +112,5 @@ jobs:
working-directory: languages/ruby/bitwarden_sdk_secrets

- name: Push gem to Rubygems
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem push *.gem
env:
GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
working-directory: languages/ruby/bitwarden_sdk_secrets
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
uses: rubygems/release-gem@48512b949a6517699b78f000b4f36e641d321ed3 # v1.0.0
6 changes: 6 additions & 0 deletions .github/workflows/version-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ on:
- cli
- napi
- python-sdk
- ruby-sdk
version_number:
description: "New version (example: '2024.1.0')"
required: true
Expand Down Expand Up @@ -150,6 +151,11 @@ jobs:
sed -i 's/version = "[0-9]\.[0-9]\.[0-9]"/version = "${{ inputs.version_number }}"/' ./languages/python/pyproject.toml
sed -i 's/__version__ = "[0-9]\.[0-9]\.[0-9]"/__version__ = "${{ inputs.version_number }}"/' ./languages/python/bitwarden_sdk/__init__.py
### ruby sdk
- name: Bump ruby-sdk Version
if: ${{ inputs.project == 'ruby-sdk' }}
run: sed -i "s/VERSION = '[0-9]\.[0-9]\.[0-9]'/VERSION = '${{ inputs.version_number }}'/" ./languages/ruby/bitwarden_sdk/lib/version.rb

############################
# VERSION BUMP SECTION END #
############################
Expand Down

0 comments on commit 412ae78

Please sign in to comment.