From f8df5f8b7ff677116e99dc9a706424b642e86afb Mon Sep 17 00:00:00 2001 From: Michal Checinski Date: Fri, 16 Feb 2024 12:34:21 +0100 Subject: [PATCH] Publish ruby only on workflow dispatch get the artifacts from build workflows instead of triggering them --- .github/workflows/publish-ruby.yml | 94 ++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 25 deletions(-) diff --git a/.github/workflows/publish-ruby.yml b/.github/workflows/publish-ruby.yml index 3dce457b2..cbb2116bc 100644 --- a/.github/workflows/publish-ruby.yml +++ b/.github/workflows/publish-ruby.yml @@ -1,23 +1,40 @@ 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 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 @@ -27,33 +44,60 @@ jobs: with: ruby-version: 3.2 - - name: Download Ruby schemas artifact - uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2 + - name: Login to Azure + uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 with: - name: schemas.rb + creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} + + - name: Retrieve ruby gem api key + id: retrieve-secret + uses: bitwarden/gh-actions/get-keyvault-secrets@main + with: + keyvault: "bitwarden-ci" + secrets: "ruby-gem-api-key" + + - name: Download artifacts + uses: bitwarden/gh-actions/download-artifacts@main + with: + workflow: generate_schemas.yml path: languages/ruby/bitwarden_sdk/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 @@ -84,5 +128,5 @@ jobs: 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 }} + GEM_HOST_API_KEY: ${{ steps.retrieve-secret.outputs.ruby-gem-api-key }} working-directory: languages/ruby/bitwarden_sdk