Skip to content

Commit

Permalink
BRE-330 - Update Rust crate workflows (#1057)
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrassia authored Sep 17, 2024
1 parent c3b8c8d commit 3de7906
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 40 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-cli-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- name: Check Branch to Publish
env:
PUBLISH_BRANCHES: "master,rc,hotfix-rc"
PUBLISH_BRANCHES: "main,rc,hotfix-rc"
id: publish-branch-check
run: |
REF=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
run: |
REF=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
IMAGE_TAG=$(echo "${REF}" | sed "s#/#-#g") # slash safe branch name
if [[ "${IMAGE_TAG}" == "master" ]]; then
if [[ "${IMAGE_TAG}" == "main" ]]; then
IMAGE_TAG=dev
elif [[ ("${IMAGE_TAG}" == "rc") || ("${IMAGE_TAG}" == "hotfix-rc") ]]; then
IMAGE_TAG=rc
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
steps:
- name: Check if any job failed
if: |
github.ref == 'refs/heads/master'
github.ref == 'refs/heads/main'
|| github.ref == 'refs/heads/rc'
|| github.ref == 'refs/heads/hotfix-rc'
env:
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/build-rust-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:
push:
branches:
- "main"
- "rc"
- "hotfix-rc"

env:
CARGO_TERM_COLOR: always
Expand All @@ -17,7 +15,7 @@ jobs:
build:
name: Building ${{matrix.package}} for - ${{ matrix.os }}

runs-on: ${{ matrix.settings.os || 'ubuntu-latest' }}
runs-on: ${{ matrix.os || 'ubuntu-latest' }}

strategy:
fail-fast: false
Expand All @@ -42,7 +40,6 @@ jobs:
uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable
with:
toolchain: stable
targets: ${{ matrix.settings.target }}

- name: Cache cargo registry
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
Expand All @@ -61,9 +58,8 @@ jobs:
release-dry-run:
name: Release dry-run
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/head/main' || github.ref == 'refs/head/rc' || github.ref == 'refs/head/hotfix-rc' }}
needs:
- build
if: ${{ github.ref == 'refs/head/main' }}
needs: build
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
Expand All @@ -72,7 +68,6 @@ jobs:
uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable
with:
toolchain: stable
targets: ${{ matrix.settings.target }}

- name: Cache cargo registry
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
Expand Down
33 changes: 10 additions & 23 deletions .github/workflows/publish-rust-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,24 @@ on:
- Redeploy
- Dry Run

defaults:
run:
shell: bash

jobs:
setup:
name: Setup
publish:
name: Publish
runs-on: ubuntu-22.04
steps:
- name: Checkout repo
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Branch check
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
if: ${{ inputs.release_type != 'Dry Run' }}
run: |
if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then
if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then
echo "==================================="
echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches"
echo "[!] Can only release from the 'main' branch"
echo "==================================="
exit 1
fi
publish:
name: Publish
runs-on: ubuntu-latest
needs:
- setup
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Login to Azure
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
with:
Expand All @@ -70,7 +57,7 @@ jobs:
run: cargo install cargo-release

- name: Create GitHub deployment
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
if: ${{ inputs.release_type != 'Dry Run' }}
uses: chrnorm/deployment-action@55729fcebec3d284f60f5bcabbd8376437d696b1 # v2.0.7
id: deployment
with:
Expand All @@ -81,22 +68,22 @@ jobs:
task: release

- name: Cargo release
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
if: ${{ inputs.release_type != 'Dry Run' }}
env:
PUBLISH_GRACE_SLEEP: 10
CARGO_REGISTRY_TOKEN: ${{ steps.retrieve-secrets.outputs.cratesio-api-token }}
run: cargo-release release publish --exclude bw --exclude bws --execute --no-confirm

- name: Update deployment status to Success
if: ${{ github.event.inputs.release_type != 'Dry Run' && success() }}
if: ${{ inputs.release_type != 'Dry Run' && success() }}
uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3
with:
token: "${{ secrets.GITHUB_TOKEN }}"
state: "success"
deployment-id: ${{ steps.deployment.outputs.deployment_id }}

- name: Update deployment status to Failure
if: ${{ github.event.inputs.release_type != 'Dry Run' && failure() }}
if: ${{ inputs.release_type != 'Dry Run' && failure() }}
uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3
with:
token: "${{ secrets.GITHUB_TOKEN }}"
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/rust-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
push:
branches:
- "main"
- "rc"
- "hotfix-rc"
pull_request:

env:
Expand All @@ -23,7 +21,7 @@ jobs:
- run: exit 0

test:
name: ${{ matrix.os }} / ${{matrix.target || 'default' }}
name: ${{ matrix.os }} / default

runs-on: ${{ matrix.os || 'ubuntu-22.04' }}

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/version-bump.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Version Bump
run-name: Version Bump - v${{ inputs.version_number }}
run-name: Version Bump - ${{ inputs.project }} - v${{ inputs.version_number }}

on:
workflow_dispatch:
Expand All @@ -25,7 +25,7 @@ on:
required: true
cut_rc_branch:
description: "Cut RC branch?"
default: true
default: false
type: boolean

jobs:
Expand Down Expand Up @@ -198,7 +198,7 @@ jobs:
env:
GH_TOKEN: ${{ steps.retrieve-secrets.outputs.github-pat-bitwarden-devops-bot-repo-scope }}
PR_BRANCH: ${{ steps.create-branch.outputs.name }}
TITLE: "Bump version to ${{ inputs.version_number }}"
TITLE: "Bump ${{ inputs.project }} version to ${{ inputs.version_number }}"
run: |
PR_URL=$(gh pr create --title "$TITLE" \
--base "main" \
Expand Down

0 comments on commit 3de7906

Please sign in to comment.