Skip to content

Commit

Permalink
refactor(ci): update release workflow to build indiv targets
Browse files Browse the repository at this point in the history
- add workflow_dispatch / cron schedule once a week for early alerts
- support rust caching (individual caching keys)

individual targets allow us to avoid needing to do selecting cargo build cleaning due to cross-rs linking errors. Having a restored cache helps us speed up builds, which is always nice
  • Loading branch information
YOU54F committed Jun 8, 2024
1 parent 582de5c commit cf1bed4
Showing 1 changed file with 40 additions and 17 deletions.
57 changes: 40 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,38 @@ on:
branches:
- master

workflow_dispatch:

schedule:
- cron: 0 0 * * 4 # Midnight Wednesday

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true

jobs:
build-release:
name: build-release (${{ matrix.targets }})
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
include:
- operating-system: ubuntu-20.04
targets: x86_64-unknown-linux-gnu,x86_64-unknown-linux-musl,aarch64-unknown-linux-gnu,aarch64-unknown-linux-musl
targets: x86_64-unknown-linux-gnu
- operating-system: ubuntu-20.04
targets: x86_64-unknown-linux-musl
- operating-system: ubuntu-20.04
targets: aarch64-unknown-linux-gnu
- operating-system: ubuntu-20.04
targets: aarch64-unknown-linux-musl
- operating-system: windows-2019
targets: aarch64-pc-windows-msvc,x86_64-pc-windows-msvc
targets: x86_64-pc-windows-msvc
- operating-system: windows-2019
targets: aarch64-pc-windows-msvc
- operating-system: macos-12
targets: aarch64-apple-darwin,x86_64-apple-darwin
targets: x86_64-apple-darwin
- operating-system: macos-14
targets: aarch64-apple-darwin
fail-fast: false

env:
Expand All @@ -43,6 +59,7 @@ jobs:
uses: Swatinem/rust-cache@v2
with:
workspaces: rust
key: ${{ matrix.targets }}

- name: Set up QEMU
if: runner.os == 'Linux'
Expand Down Expand Up @@ -71,52 +88,58 @@ jobs:
id: cargo-flags
shell: bash
run: |
if [[ "${{ github.event_name }}" = "release" ]]; then
echo "flags=--release" >> "$GITHUB_OUTPUT"
else
echo "flags=" >> "$GITHUB_OUTPUT"
fi
echo "flags=--release" >> "$GITHUB_OUTPUT"
- name: Build verifier CLI
if: |
github.event_name == 'push' ||
github.event_name == 'pull_request' ||
github.event_name == 'workflow_dispatch' ||
startsWith(github.ref, 'refs/tags/pact_verifier_cli')
shell: bash
run: |
./release-${{ steps.platform-abbreviation.outputs.platform }}.sh \
./release-${{ steps.platform-abbreviation.outputs.platform }}.sh ${{ matrix.targets }} \
${{ steps.cargo-flags.outputs.flags }}
working-directory: rust/pact_verifier_cli

- name: Build FFI library
if: |
github.event_name == 'push' ||
github.event_name == 'pull_request' ||
github.event_name == 'workflow_dispatch' ||
startsWith(github.ref, 'refs/tags/libpact_ffi')
shell: bash
run: |
./release-${{ steps.platform-abbreviation.outputs.platform }}.sh \
./release-${{ steps.platform-abbreviation.outputs.platform }}.sh ${{ matrix.targets }} \
${{ steps.cargo-flags.outputs.flags }}
working-directory: rust/pact_ffi

- name: Smoke Test FFI library
if: |
github.event_name == 'push' ||
github.event_name == 'pull_request' ||
github.event_name == 'workflow_dispatch' ||
startsWith(github.ref, 'refs/tags/libpact_ffi')
shell: bash
run: |
./smoke-test.sh ${{ matrix.targets }}
working-directory: ruby

- name: Upload the artifacts
if: |
startsWith(github.ref, 'refs/tags/libpact_ffi') ||
startsWith(github.ref, 'refs/tags/pact_verifier_cli') ||
startsWith(github.ref, 'refs/tags/pact_mock_server_cli')
startsWith(github.ref, 'refs/tags/pact_verifier_cli')
uses: actions/upload-artifact@v4
with:
name: release-artifacts-${{ matrix.operating-system }}
name: release-artifacts-${{ matrix.targets }}
path: rust/release_artifacts
if-no-files-found: error
if-no-files-found: warn

publish:
runs-on: ubuntu-latest
if: |
startsWith(github.ref, 'refs/tags/libpact_ffi') ||
startsWith(github.ref, 'refs/tags/pact_verifier_cli') ||
startsWith(github.ref, 'refs/tags/pact_mock_server_cli')
startsWith(github.ref, 'refs/tags/pact_verifier_cli')
needs: build-release

steps:
Expand Down

0 comments on commit cf1bed4

Please sign in to comment.