Skip to content

Fix: Ensure consistent artifact packaging for releases #10

Fix: Ensure consistent artifact packaging for releases

Fix: Ensure consistent artifact packaging for releases #10

Workflow file for this run

name: Build and Package
on:
push:
branches:
- main
jobs:
build:
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
package_type: deb
- os: windows-latest
target: x86_64-pc-windows-gnu
package_type: windows
- os: macos-latest
target: aarch64-apple-darwin
package_type: mac
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
- name: Cache cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Install dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y dpkg-dev libssl-dev pkg-config
- name: Install dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
brew update
brew install openssl@3 rustup-init pkg-config llvm create-dmg
echo "OPENSSL_DIR=$(brew --prefix openssl@3)" >> $GITHUB_ENV
echo "OPENSSL_LIB_DIR=$(brew --prefix openssl@3)/lib" >> $GITHUB_ENV
echo "OPENSSL_INCLUDE_DIR=$(brew --prefix openssl@3)/include" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> $GITHUB_ENV
echo "CC=$(brew --prefix llvm)/bin/clang" >> $GITHUB_ENV
echo "CXX=$(brew --prefix llvm)/bin/clang++" >> $GITHUB_ENV
- name: Install dependencies (Windows)
if: matrix.os == 'windows-latest'
run: |
choco install wixtoolset -y
choco install openssl -y
- name: Build Rust project (Windows/Linux)
if: matrix.package_type != 'mac'
run: |
cargo build --release --locked --target ${{ matrix.target }} --manifest-path app/Cargo.toml
env:
PKG_CONFIG_ALLOW_CROSS: 1
- name: Build Rust project (macOS)
if: matrix.package_type == 'mac'
run: |
cargo build --release --locked --target ${{ matrix.target }} --manifest-path app/Cargo.toml
env:
PKG_CONFIG_ALLOW_CROSS: 1
OPENSSL_DIR: ${{ env.OPENSSL_DIR }}
OPENSSL_LIB_DIR: ${{ env.OPENSSL_LIB_DIR }}
OPENSSL_INCLUDE_DIR: ${{ env.OPENSSL_INCLUDE_DIR }}
- name: Package Debian (.deb)
if: matrix.package_type == 'deb'
run: |
cargo install cargo-deb --force
cargo deb --target ${{ matrix.target }} --manifest-path app/Cargo.toml
mkdir -p artifacts
mv app/target/${{ matrix.target }}/debian/*.deb artifacts/
env:
DEB_BUILD_OPTIONS: nocheck
- name: Package Windows (.exe/.msi)
if: matrix.package_type == 'windows'
run: |
cargo install cargo-wix --force
cd app
cargo wix init
cargo wix
cd ..
mkdir -p artifacts
mv app/target/wix/*.msi artifacts/
shell: bash
- name: Package macOS (.dmg)
if: matrix.package_type == 'mac'
run: |
cd app
cargo install cargo-bundle --force
cargo bundle --release --target ${{ matrix.target }}
cd ..
env:
BUNDLE_ID: com.singhropar.gitswift
BUNDLE_NAME: gitswift
MACOSX_DEPLOYMENT_TARGET: 10.12
OPENSSL_DIR: ${{ env.OPENSSL_DIR }}
OPENSSL_LIB_DIR: ${{ env.OPENSSL_LIB_DIR }}
OPENSSL_INCLUDE_DIR: ${{ env.OPENSSL_INCLUDE_DIR }}
CC: ${{ env.CC }}
CXX: ${{ env.CXX }}
- name: Convert .app to .dmg
if: matrix.package_type == 'mac'
run: |
mkdir -p dist
create-dmg \
--volname="GitSwift Installer" \
"app/target/aarch64-apple-darwin/release/bundle/osx/gitswift.app" \
"dist/"
mkdir -p artifacts
mv dist/*.dmg artifacts/
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: packages-${{ matrix.os }}
path: artifacts/*