199 lines
6.6 KiB
YAML
199 lines
6.6 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
|
|
jobs:
|
|
build:
|
|
name: Build ${{ matrix.platform }}
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- platform: windows-x64
|
|
os: windows-latest
|
|
target: x86_64-pc-windows-msvc
|
|
- platform: windows-arm64
|
|
os: windows-latest
|
|
target: aarch64-pc-windows-msvc
|
|
- platform: macos-x64
|
|
os: macos-latest
|
|
target: x86_64-apple-darwin
|
|
- platform: macos-arm64
|
|
os: macos-latest
|
|
target: aarch64-apple-darwin
|
|
- platform: linux-x64
|
|
os: ubuntu-latest
|
|
target: x86_64-unknown-linux-gnu
|
|
- platform: linux-arm64
|
|
os: ubuntu-latest
|
|
target: aarch64-unknown-linux-gnu
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.target }}
|
|
|
|
# Windows and macOS builds using cargo-packager
|
|
- name: Build with cargo-packager (Windows/macOS)
|
|
if: runner.os != 'Linux'
|
|
working-directory: crates/coop
|
|
run: |
|
|
cargo install cargo-packager --locked
|
|
cargo packager --release --target ${{ matrix.target }} --config before-packaging-command="cargo build --release --target ${{ matrix.target }}"
|
|
|
|
- name: Upload Windows/macOS artifacts
|
|
if: runner.os != 'Linux'
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.platform }}-artifacts
|
|
path: |
|
|
crates/coop/dist/*.dmg
|
|
crates/coop/dist/*.msi
|
|
crates/coop/dist/*.exe
|
|
if-no-files-found: error
|
|
|
|
# Linux builds using custom scripts
|
|
- name: Install Linux build dependencies
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y flatpak flatpak-builder snapd squashfs-tools jq gettext-base
|
|
|
|
# Install cross-compilation tools for ARM64
|
|
- name: Install ARM64 cross-compilation tools
|
|
if: runner.os == 'Linux' && matrix.target == 'aarch64-unknown-linux-gnu'
|
|
run: |
|
|
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
|
|
|
|
- name: Configure cross-compilation environment
|
|
if: runner.os == 'Linux' && matrix.target == 'aarch64-unknown-linux-gnu'
|
|
run: |
|
|
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
|
|
echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV
|
|
echo "AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar" >> $GITHUB_ENV
|
|
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
|
|
|
|
- name: Install Snapcraft
|
|
if: runner.os == 'Linux'
|
|
run: sudo snap install snapcraft --classic
|
|
|
|
- name: Make scripts executable
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
chmod +x script/get-crate-version
|
|
chmod +x script/linux
|
|
chmod +x script/snap-build
|
|
chmod +x script/bundle-linux
|
|
chmod +x script/flatpak/deps
|
|
chmod +x script/flatpak/bundle-flatpak
|
|
|
|
- name: Install required dependencies
|
|
if: runner.os == 'Linux'
|
|
working-directory: script
|
|
run: ./linux
|
|
|
|
# Only build Flatpak and Snap for x86_64 (most common use case)
|
|
- name: Build Flatpak (x86_64 only)
|
|
if: runner.os == 'Linux' && matrix.target == 'x86_64-unknown-linux-gnu'
|
|
working-directory: script/flatpak
|
|
run: |
|
|
./deps
|
|
./bundle-flatpak
|
|
|
|
- name: Build Snap (x86_64 only)
|
|
if: runner.os == 'Linux' && matrix.target == 'x86_64-unknown-linux-gnu'
|
|
run: |
|
|
VERSION=$(script/get-crate-version coop)
|
|
script/snap-build $VERSION
|
|
|
|
# For ARM64, build a simple binary package
|
|
- name: Build ARM64 binary
|
|
if: runner.os == 'Linux' && matrix.target == 'aarch64-unknown-linux-gnu'
|
|
run: |
|
|
cargo build --release --target ${{ matrix.target }}
|
|
|
|
- name: Create ARM64 tarball
|
|
if: runner.os == 'Linux' && matrix.target == 'aarch64-unknown-linux-gnu'
|
|
run: |
|
|
VERSION=$(script/get-crate-version coop)
|
|
mkdir -p linux-artifacts
|
|
cd target/aarch64-unknown-linux-gnu/release
|
|
tar -czf ../../../linux-artifacts/coop-${VERSION}-linux-aarch64.tar.gz coop
|
|
ls -la ../../../linux-artifacts/
|
|
|
|
- name: Collect Linux x86_64 artifacts
|
|
if: runner.os == 'Linux' && matrix.target == 'x86_64-unknown-linux-gnu'
|
|
run: |
|
|
mkdir -p linux-artifacts
|
|
# Find and copy flatpak files
|
|
find . -name "*.flatpak" -exec cp {} linux-artifacts/ \;
|
|
# Find and copy snap files
|
|
find . -name "*.snap" -exec cp {} linux-artifacts/ \;
|
|
ls -la linux-artifacts/
|
|
|
|
- name: Upload Linux artifacts
|
|
if: runner.os == 'Linux'
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.platform }}-artifacts
|
|
path: linux-artifacts/**/*
|
|
if-no-files-found: error
|
|
|
|
release:
|
|
name: Create Release
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Make get-crate-version executable
|
|
run: chmod +x script/get-crate-version
|
|
|
|
- name: Get version
|
|
id: version
|
|
run: |
|
|
VERSION=$(script/get-crate-version coop)
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
|
|
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: Display artifacts structure
|
|
run: |
|
|
echo "Artifacts structure:"
|
|
find artifacts -type f -exec ls -la {} \;
|
|
|
|
- name: Create draft release
|
|
id: create_release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: ${{ steps.version.outputs.tag }}
|
|
name: Release ${{ steps.version.outputs.tag }}
|
|
draft: true
|
|
prerelease: false
|
|
generate_release_notes: true
|
|
files: |
|
|
artifacts/**/*
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Output release info
|
|
run: |
|
|
echo "Created draft release: ${{ steps.create_release.outputs.url }}"
|
|
echo "Release ID: ${{ steps.create_release.outputs.id }}"
|