Skip to content

Commit

Permalink
Try?
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksongoode committed Sep 1, 2024
1 parent a3e3f06 commit 7be67b5
Showing 1 changed file with 44 additions and 75 deletions.
119 changes: 44 additions & 75 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: CI
on:
push:
branches: [master]
tags:
- v[0-9]+.*
pull_request:
branches: [master]

Expand All @@ -26,7 +28,8 @@ jobs:
- name: Check Formatting
run: cargo clippy -- -D warnings

build:
build-and-release:
needs: code-style
strategy:
fail-fast: false
matrix:
Expand All @@ -36,7 +39,11 @@ jobs:
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- os: macOS-latest
target: x86_64-apple-darwin
- os: macOS-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc

runs-on: ${{ matrix.os }}
env:
Expand All @@ -50,64 +57,44 @@ jobs:
with:
key: ${{ hashFiles('Cross.toml') }}

- name: Install Cross
if: runner.os == 'Linux'
run: cargo install cross

- name: Build (Linux)
if: runner.os == 'Linux'
run: cross build --release --target ${{ matrix.target }}

- name: Build Release (macOS)
if: runner.os == 'macOS'
run: |
rustup target add x86_64-apple-darwin aarch64-apple-darwin
cargo build --release --target x86_64-apple-darwin --target aarch64-apple-darwin
- name: Build Release (Windows)
if: runner.os == 'Windows'
run: cargo build --release

- name: Cache cargo-bundle
if: runner.os == 'macOS'
id: cache-cargo-bundle
uses: actions/cache@v4
- name: Build and Upload Binary
uses: taiki-e/upload-rust-binary-action@v1
with:
path: ~/.cargo/bin/cargo-bundle
key: ${{ runner.os }}-cargo-bundle-${{ hashFiles('**/Cargo.lock') }}

- name: Install cargo-bundle
if: runner.os == 'macOS' && steps.cache-cargo-bundle.outputs.cache-hit != 'true'
run: cargo install cargo-bundle

- name: Bundle macOS Release
if: runner.os == 'macOS'
run: cargo bundle --release
# working-directory: psst-gui

- name: Create macOS universal binary
if: runner.os == 'macOS'
run: |
lipo -create -output target/release/universal-psst-gui \
target/x86_64-apple-darwin/release/psst-gui \
target/aarch64-apple-darwin/release/psst-gui
- name: Replace bundled binary with universal binary
if: runner.os == 'macOS'
run: |
cp target/release/universal-psst-gui \
target/release/bundle/osx/Psst.app/Contents/MacOS/psst-gui
- name: Install create-dmg
if: runner.os == 'macOS'
run: brew install create-dmg

- name: Create DMG
if: runner.os == 'macOS'
bin: psst-gui
target: ${{ matrix.target }}
archive: psst-${{ matrix.target }}
include: LICENSE,README.md
tar: ${{ startsWith(matrix.os, 'ubuntu') && 'all' || 'none' }}
zip: ${{ matrix.os == 'windows-latest' && 'all' || 'none' }}
checksum: sha256
dry-run: ${{ !startsWith(github.ref, 'refs/tags/') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_PROFILE_RELEASE_LTO: true
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 1

- name: Build for macOS (Universal Binary)
if: matrix.os == 'macOS-latest' && matrix.target == 'x86_64-apple-darwin'
uses: taiki-e/upload-rust-binary-action@v1
with:
bin: psst-gui
target: universal-apple-darwin
archive: psst-universal-apple-darwin
include: LICENSE,README.md
checksum: sha256
dry-run: ${{ !startsWith(github.ref, 'refs/tags/') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_PROFILE_RELEASE_LTO: true
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 1

- name: Create DMG with create-dmg
if: matrix.os == 'macOS-latest' && matrix.target == 'x86_64-apple-darwin'
run: |
brew install create-dmg
create-dmg \
--volname "Psst" \
--volicon "${{ github.workspace }}/psst-gui/assets/logo.icns" \
--volicon "psst-gui/assets/logo.icns" \
--window-pos 200 120 \
--window-size 600 400 \
--icon-size 100 \
Expand All @@ -120,32 +107,14 @@ jobs:
- name: Upload macOS DMG
uses: actions/upload-artifact@v4
if: runner.os == 'macOS'
if: matrix.os == 'macOS-latest' && matrix.target == 'x86_64-apple-darwin'
with:
name: Psst.dmg
path: Psst.dmg

- name: Make Linux Binary Executable
if: runner.os == 'Linux'
run: chmod +x target/${{ matrix.target }}/release/psst-gui

- name: Upload Linux Binary
uses: actions/upload-artifact@v4
if: runner.os == 'Linux'
with:
name: psst-gui-${{ matrix.target }}
path: target/${{ matrix.target }}/release/psst-gui

- name: Upload Windows Executable
uses: actions/upload-artifact@v4
if: runner.os == 'Windows'
with:
name: Psst.exe
path: target/release/psst-gui.exe

deb:
runs-on: ubuntu-latest
needs: build
needs: build-and-release
strategy:
matrix:
include:
Expand Down

0 comments on commit 7be67b5

Please sign in to comment.