Skip to content

Commit

Permalink
wip cross build
Browse files Browse the repository at this point in the history
  • Loading branch information
jb55 committed Nov 30, 2024
1 parent 2969db7 commit 002f9f4
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 95 deletions.
28 changes: 4 additions & 24 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,26 @@
name: Build & Test
name: Test

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

jobs:
run:
runs-on: ${{ inputs.os }}

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Rust toolchain
uses: dtolnay/rust-toolchain@stable

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

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

- name: Run Tests
run: cargo test --release

- name: Build
run: cargo build --release

- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.upload-artifact-name }}
path: ${{ inputs.upload-artifact-path }}
- name: Run Tests (Native Only)
run: cargo test
128 changes: 63 additions & 65 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,37 @@ jobs:
components: clippy
- run: cargo clippy -- -D warnings

linux-build-test:
name: Build and Test (Linux)
linux-test:
name: 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)
macos-test:
name: 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)
windows-test:
name: 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
name: rpm/deb
runs-on: ubuntu-latest
needs: linux-build-test
if: github.ref_name == 'master'
needs: linux-test
#if: github.ref_name == 'master'

strategy:
fail-fast: false
matrix:
arch: [x86_64, aarch64]

steps:
# Checkout the repository
- name: Checkout Code
Expand All @@ -70,69 +70,79 @@ jobs:
- name: Install Packaging Tools
run: |
sudo apt-get update
sudo apt-get install -y rpm binutils
if [ "${{ matrix.arch }}" = "aarch64" ]; then
sudo apt-get install -y gcc-x86-64-linux-gnu
fi
cargo install cargo-generate-rpm cargo-deb
rustup target add ${{ matrix.arch }}-unknown-linux-gnu
# download!
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: notedeck-linux-bin
path: target/release

# Build Packages
- name: Build Packages
# Build
- name: Build (${{ matrix.arch }})
run: |
cargo generate-rpm
cargo deb
if [ "${{ matrix.arch }}" != "$(uname -m)" ]; then
cargo build --release --target=${{ matrix.arch }}-unknown-linux-gnu
else
cargo build --release
fi
# Build RPM Package
- name: Build RPM Package
run: |
if [ "${{ matrix.arch }}" != "$(uname -m)" ]; then
cargo generate-rpm --target=${{ matrix.arch }}-unknown-linux-gnu
else
cargo generate-rpm
fi
# Build Debian Package
- name: Build Debian Package
run: |
if [ "${{ matrix.arch }}" != "$(uname -m)" ]; then
cargo deb --target=${{ matrix.arch }}-unknown-linux-gnu
else
cargo deb
fi
# Upload RPM Package
- name: Upload RPM Package
uses: actions/upload-artifact@v4
with:
name: notedeck.rpm
path: target/generate-rpm/*.rpm
name: ${{ inputs.artifact-name }}-${{ matrix.arch }}.rpm
path: target/${{ matrix.arch }}-unknown-linux-gnu/generate-rpm/*.rpm

# Upload Debian Package
- name: Upload Debian Package
uses: actions/upload-artifact@v4
with:
name: notedeck.deb
path: target/debian/*.deb
name: ${{ inputs.artifact-name }}-${{ inputs.arch }}.deb
path: target/${{ matrix.arch }}-unknown-linux-gnu/debian/*.deb

macos-dmg:
name: Build macOS DMG
name: macOS dmg
runs-on: macos-latest
needs: macos-build-test
if: github.ref_name == 'master'
needs: macos-test
#if: github.ref_name == 'master'
env:
NOTEDECK_APPLE_RELEASE_CERT_ID: ${{ secrets.NOTEDECK_APPLE_RELEASE_CERT_ID }}
NOTEDECK_RELEASE_APPLE_ID: ${{ secrets.NOTEDECK_RELEASE_APPLE_ID }}
NOTEDECK_APPLE_APP_SPECIFIC_PW: ${{ secrets.NOTEDECK_APPLE_APP_SPECIFIC_PW }}
NOTEDECK_APPLE_TEAM_ID: ${{ secrets.NOTEDECK_APPLE_TEAM_ID }}

strategy:
fail-fast: false
matrix:
arch: [x86_64, aarch64]

steps:
# Checkout the repository
- name: Checkout Code
uses: actions/checkout@v4

# Set up Rust
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable

# 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:
name: notedeck-macos-bin # Assuming you need the Release build
path: target/release

- name: Install Required Tools
run: |
brew install create-dmg
cargo install cargo-bundle
rustup target add ${{ matrix.arch }}-apple-darwin
- name: Import apple codesign cert
uses: apple-actions/import-codesign-certs@v3
Expand All @@ -141,30 +151,24 @@ jobs:
p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }}

- name: Run macOS DMG Build Script
run: ./scripts/macos_build.sh
run: ARCH=${{ matrix.arch }} ./scripts/macos_build.sh

- name: Upload DMG Artifact
uses: actions/upload-artifact@v4
with:
name: notedeck.dmg
path: packages/notedeck.dmg
name: notedeck-${{ matrix.arch }}.dmg
path: packages/notedeck-${{ matrix.arch }}.dmg

windows-installer:
name: Build Windows Installer
runs-on: windows-latest
needs: windows-build-test
needs: windows-test
if: github.ref_name == 'master'
steps:
# Checkout the repository
- name: Checkout Code
uses: actions/checkout@v4

- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: notedeck.exe # Assuming you need the Release build
path: target/release

# Create packages directory
- name: Create packages directory
run: mkdir packages
Expand All @@ -173,13 +177,6 @@ jobs:
- name: Install Inno Setup
run: choco install innosetup --no-progress --yes

# Validate executable exists
- name: Validate required files
run: |
if (!(Test-Path -Path target\release\notedeck.exe)) {
throw "Executable 'notedeck.exe' not found in 'target/release'."
}
# Build Installer
- name: Run Inno Setup Script
run: |
Expand All @@ -195,3 +192,4 @@ jobs:
with:
name: DamusNotedeckInstaller.exe
path: packages\DamusNotedeckInstaller.exe

14 changes: 8 additions & 6 deletions scripts/macos_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ set -o pipefail # Catch errors in pipelines

# Ensure the script is running in the correct directory
REQUIRED_DIR="notedeck"
ARCH=${ARCH:-"aarch64"}
TARGET=${TARGET:-${ARCH}-apple-darwin}
CURRENT_DIR=$(basename "$PWD")

if [ "$CURRENT_DIR" != "$REQUIRED_DIR" ]; then
Expand Down Expand Up @@ -40,7 +42,7 @@ fi

# Build the .app bundle
echo "Building .app bundle..."
cargo bundle --release
cargo bundle --release --target $TARGET

# Sign the app
echo "Codesigning the app..."
Expand All @@ -51,11 +53,11 @@ codesign \
--options runtime \
--entitlements entitlements.plist \
--sign "$NOTEDECK_APPLE_RELEASE_CERT_ID" \
target/release/bundle/osx/notedeck.app
target/${TARGET}/release/bundle/osx/notedeck.app

# Create a zip for notarization
echo "Creating zip for notarization..."
zip -r notedeck.zip target/release/bundle/osx/notedeck.app
zip -r notedeck.zip target/${TARGET}/release/bundle/osx/notedeck.app

# Submit for notarization
echo "Submitting for notarization..."
Expand All @@ -68,7 +70,7 @@ xcrun notarytool submit \

# Staple the notarization
echo "Stapling notarization to the app..."
xcrun stapler staple target/release/bundle/osx/notedeck.app
xcrun stapler staple target/${TARGET}/release/bundle/osx/notedeck.app

echo "Removing notedeck.zip"
rm notedeck.zip
Expand All @@ -79,7 +81,7 @@ mkdir -p packages
create-dmg \
--window-size 600 400 \
--app-drop-link 400 100 \
packages/notedeck.dmg \
target/release/bundle/osx/notedeck.app
packages/notedeck-${ARCH}.dmg \
target/${TARGET}/release/bundle/osx/notedeck.app

echo "Build and signing process completed successfully."

0 comments on commit 002f9f4

Please sign in to comment.