Skip to content

Commit

Permalink
github: split matrix into individual build steps per OS
Browse files Browse the repository at this point in the history
So we don't have to wait for the whole matrix to start building
individual packages per OS

Signed-off-by: William Casarin <[email protected]>
  • Loading branch information
jb55 committed Nov 28, 2024
1 parent 79e0228 commit b6d07f1
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 77 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build, Test

on:
workflow_call:
inputs:
os:
required: true
type: string
upload-artifact-name:
required: true
type: string
upload-artifact-name:
required: true
type: string
additional-setup:
required: false
type: string

jobs:
run:
runs-on: ${{ inputs.os }}
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Rust cache
uses: Swatinem/rust-cache@v2

- name: Additional Setup (if specified)
if: ${{ inputs.additional-setup != '' }}
run: ${{ inputs.additional-setup }}

- name: Run Tests
uses: actions-rs/cargo@v1
with:
command: test
args: --release

- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release

- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.upload-artifact-name }}
path: ${{ inputs.upload-artifact-path }}
109 changes: 32 additions & 77 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,85 +37,36 @@ jobs:
command: clippy
args: -- -D warnings

build-and-test:
name: Build and Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
toolchain: [stable]
steps:
# Checkout the repository
- name: Checkout Code
uses: actions/checkout@v2

# Set up the Rust toolchain
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
override: true

# Cache
- name: Rust cache
uses: Swatinem/rust-cache@v2

# Install dependencies (only for Ubuntu)
- name: Install Dependencies (Ubuntu)
if: runner.os == 'Linux'
run: sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev

# Run tests
- name: Run Tests
uses: actions-rs/cargo@v1
with:
command: test
args: --release

# Build
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release

# Strip Debug Symbols
#
## > Don't strip for now <
#
#- name: Strip Debug Symbols
# if: runner.os == 'Linux'
# run: strip target/release/notedeck || echo "Skipping strip if not applicable"

# Upload bin for further packaging steps
- name: Upload Build Artifacts (Linux)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
with:
name: notedeck-linux-bin
path: target/release/notedeck

# Upload artifacts (for macOS, adjust paths as needed)
- name: Upload Build Artifacts (macOS)
if: runner.os == 'macOS'
uses: actions/upload-artifact@v4
with:
name: notedeck-macos-bin
path: target/release/notedeck

# Upload exe for further packaging steps
- name: Upload Build Artifacts (Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: notedeck.exe
path: target/release/notedeck.exe
linux-build-test:
name: Build and Test (Linux)
uses: ./.github/workflows/build-and-test.yml
with:
os: ubuntu-latest
upload-artifact-name: notedeck-linux-bin
upload-artifact-path: target/release/notedeck
additional-setup: |
sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev
macos-build-test:
name: Build and Test (macOS)
uses: ./.github/workflows/build-and-test.yml
with:
os: macos-latest
upload-artifact-name: notedeck-macos-bin
upload-artifact-path: target/release/notedeck

windows-build-test:
name: Build and Test (Windows)
uses: ./.github/workflows/build-and-test.yml
with:
os: windows-latest
upload-artifact-name: notedeck.exe
upload-artifact-path: target/release/notedeck.exe

packaging:
name: Build Linux Packages
runs-on: ubuntu-latest
needs: build-and-test
needs: linux-build-test
steps:
# Checkout the repository
- name: Checkout Code
Expand Down Expand Up @@ -161,7 +112,7 @@ jobs:
macos-dmg:
name: Build macOS DMG
runs-on: macos-latest
needs: build-and-test
needs: macos-build-test
env:
NOTEDECK_APPLE_RELEASE_CERT_ID: ${{ secrets.NOTEDECK_APPLE_RELEASE_CERT_ID }}
NOTEDECK_RELEASE_APPLE_ID: ${{ secrets.NOTEDECK_RELEASE_APPLE_ID }}
Expand All @@ -180,6 +131,10 @@ jobs:
toolchain: stable
override: true

# create-dmg and cargo-bundle caching
- name: Rust cache
uses: Swatinem/rust-cache@v2

- name: Download Build Artifacts (MacOS)
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -209,7 +164,7 @@ jobs:
windows-installer:
name: Build Windows Installer
runs-on: windows-latest
needs: build-and-test
needs: windows-build-test
steps:
# Checkout the repository
- name: Checkout Code
Expand Down

0 comments on commit b6d07f1

Please sign in to comment.