Merge pull request #159 from lilopkins/develop #59
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Rust Applications | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
create-release: | |
name: Create Release | |
runs-on: ubuntu-latest | |
permissions: write-all | |
outputs: | |
CARGO_PKG_VERSION: ${{ steps.version.outputs.CARGO_PKG_VERSION }} | |
CARGO_PKG_PRERELEASE: ${{ steps.version.outputs.CARGO_PKG_PRERELEASE }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Determine Cargo version | |
id: version | |
run: | | |
export CARGO_PKG_VERSION=$(awk -F '["=]' '/^\[(workspace.)?package\]/{p=1} p && /^version[[:space:]]*=/ {gsub(/"/, "", $3); print $3; p=0}' Cargo.toml) | |
export CARGO_PKG_PRERELEASE=$([[ $CARGO_PKG_VERSION =~ -[0-9A-Za-z]+ ]] && echo "true" || echo "false") | |
echo "CARGO_PKG_VERSION=${CARGO_PKG_VERSION}" >> $GITHUB_OUTPUT | |
echo "CARGO_PKG_PRERELEASE=${CARGO_PKG_PRERELEASE}" >> $GITHUB_OUTPUT | |
- name: Create Tag and Release | |
uses: actions/create-release@latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.version.outputs.CARGO_PKG_VERSION }} | |
release_name: v${{ steps.version.outputs.CARGO_PKG_VERSION }} | |
prerelease: ${{ steps.version.outputs.CARGO_PKG_PRERELEASE }} | |
build: | |
name: Build for Linux | |
runs-on: ubuntu-latest | |
needs: create-release | |
container: | |
image: ghcr.io/gtk-rs/gtk4-rs/gtk4:latest | |
permissions: write-all | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v1 | |
- name: Restore Cargo cache | |
uses: actions/cache/restore@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Install dependencies | |
run: yum -y update && yum -y install atk-devel libadwaita-devel | |
- name: Build | |
run: | | |
# Build | |
cargo build -p testangel --bin testangel --release | |
cargo build -p testangel --bin testangel-executor --no-default-features --features cli --release | |
cargo build -p testangel-arithmetic --release | |
cargo build -p testangel-compare --release | |
cargo build -p testangel-convert --release | |
cargo build -p testangel-date --release | |
cargo build -p testangel-evidence --release | |
cargo build -p testangel-rand --release | |
cargo build -p testangel-regex --release | |
cargo build -p testangel-user-interaction --release | |
# Prepare output dir | |
mkdir -p build || exit 1 | |
cp target/release/testangel build/ | |
cp target/release/testangel-executor build/ | |
# Prepare engines | |
mkdir -p build/engines || exit 1 | |
cp target/release/libtestangel_arithmetic.so build/engines | |
cp target/release/libtestangel_compare.so build/engines | |
cp target/release/libtestangel_convert.so build/engines | |
cp target/release/libtestangel_date.so build/engines | |
cp target/release/libtestangel_evidence.so build/engines | |
cp target/release/libtestangel_rand.so build/engines | |
cp target/release/libtestangel_regex.so build/engines | |
cp target/release/libtestangel_user_interaction.so build/engines | |
- name: Save Cargo cache | |
uses: actions/cache/save@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Archive Release | |
uses: thedoctor0/[email protected] | |
with: | |
type: tar | |
path: build | |
filename: release-linux-amd64.tar.gz | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: release-linux-amd64.tar.gz | |
tag_name: ${{ needs.create-release.outputs.CARGO_PKG_VERSION }} | |
prerelease: ${{ needs.create-release.outputs.CARGO_PKG_PRERELEASE }} | |
build-win: | |
name: Build for Windows | |
runs-on: windows-latest | |
needs: create-release | |
permissions: write-all | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v1 | |
- name: Restore Cargo cache | |
uses: actions/cache/restore@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Restore GTK4 | |
id: cache-gtk4 | |
uses: actions/cache/restore@v3 | |
with: | |
key: windows-gtk4 | |
path: | | |
C:\gtk-build | |
- name: Move git binary | |
run: | | |
Move-Item "C:\Program Files\Git\usr\bin" "C:\Program Files\Git\usr\notbin" | |
Move-Item "C:\Program Files\Git\bin" "C:\Program Files\Git\notbin" | |
- name: Build GTK4 | |
run: | | |
python -m pip install --user pipx | |
python -m pipx ensurepath | |
pipx install gvsbuild | |
gvsbuild build gtk4 libadwaita librsvg --ninja-opts -j2 | |
- name: Restore git binary | |
run: | | |
Move-Item "C:\Program Files\Git\usr\notbin" "C:\Program Files\Git\usr\bin" | |
Move-Item "C:\Program Files\Git\notbin" "C:\Program Files\Git\bin" | |
- name: Save GTK4 | |
uses: actions/cache/save@v3 | |
with: | |
key: ${{ steps.cache-gtk4.outputs.cache-primary-key }} | |
path: | | |
C:\gtk-build | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Build | |
shell: pwsh | |
run: | | |
$env:PATH="C:\gtk-build\gtk\x64\release\bin;" + $env:PATH | |
$env:LIB="C:\gtk-build\gtk\x64\release\lib;" + $env:LIB | |
$env:INCLUDE="C:\gtk-build\gtk\x64\release\include;C:\gtk-build\gtk\x64\release\include\cairo;C:\gtk-build\gtk\x64\release\include\glib-2.0;C:\gtk-build\gtk\x64\release\include\gobject-introspection-1.0;C:\gtk-build\gtk\x64\release\lib\glib-2.0\include;" + $env:INCLUDE | |
$env:PKG_CONFIG_PATH="C:\gtk-build\gtk\x64\release\lib\pkgconfig;" + $env:PKG_CONFIG_PATH | |
cargo build -p testangel --bin testangel --release | |
cargo build -p testangel --bin testangel-executor --no-default-features --features cli --release | |
cargo build -p testangel-arithmetic --release | |
cargo build -p testangel-compare --release | |
cargo build -p testangel-convert --release | |
cargo build -p testangel-date --release | |
cargo build -p testangel-evidence --release | |
cargo build -p testangel-rand --release | |
cargo build -p testangel-regex --release | |
cargo build -p testangel-user-interaction --release | |
mkdir build | |
copy target/release/testangel.exe build/ | |
cargo build -p testangel --bin testangel --release --features windows-keep-console-window | |
copy target/release/testangel.exe build/testangel-dbg.exe | |
copy target/release/testangel-executor.exe build/ | |
copy C:\gtk-build\gtk\x64\release\bin\*.dll build/ | |
mkdir build/engines | |
copy target/release/testangel_arithmetic.dll build/engines/ | |
copy target/release/testangel_compare.dll build/engines/ | |
copy target/release/testangel_convert.dll build/engines/ | |
copy target/release/testangel_date.dll build/engines/ | |
copy target/release/testangel_evidence.dll build/engines/ | |
copy target/release/testangel_rand.dll build/engines/ | |
copy target/release/testangel_regex.dll build/engines/ | |
copy target/release/testangel_user_interaction.dll build/engines/ | |
# GSchemas for FileChooser | |
mkdir -p build/share/glib-2.0/schemas | |
copy C:\gtk-build\gtk\x64\release\share\glib-2.0\schemas\gschemas.compiled build/share/glib-2.0/schemas/ | |
# SVG loader for icons | |
mkdir -p build/lib/gdk-pixbuf-2.0/2.10.0/loaders | |
copy C:\gtk-build\gtk\x64\release\lib\gdk-pixbuf-2.0\2.10.0\loaders.cache build/lib/gdk-pixbuf-2.0/2.10.0/ | |
copy C:\gtk-build\gtk\x64\release\lib\gdk-pixbuf-2.0\2.10.0\loaders\libpixbufloader-svg.dll build/lib/gdk-pixbuf-2.0/2.10.0/loaders/ | |
- name: Save Cargo cache | |
uses: actions/cache/save@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Archive Release | |
uses: thedoctor0/[email protected] | |
with: | |
type: zip | |
path: build | |
filename: release-win.zip | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: release-win.zip | |
tag_name: ${{ needs.create-release.outputs.CARGO_PKG_VERSION }} | |
prerelease: ${{ needs.create-release.outputs.CARGO_PKG_PRERELEASE }} | |
build-mac: | |
name: Build for Mac | |
runs-on: macos-latest | |
needs: create-release | |
permissions: write-all | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v1 | |
- name: Restore Cargo cache | |
uses: actions/cache/restore@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Install dependencies | |
run: brew install gtk4 libadwaita | |
- name: Build for mac | |
run: | | |
# Build | |
cargo build -p testangel --bin testangel --release | |
cargo build -p testangel --bin testangel-executor --no-default-features --features cli --release | |
cargo build -p testangel-arithmetic --release | |
cargo build -p testangel-compare --release | |
cargo build -p testangel-convert --release | |
cargo build -p testangel-date --release | |
cargo build -p testangel-evidence --release | |
cargo build -p testangel-rand --release | |
cargo build -p testangel-regex --release | |
cargo build -p testangel-user-interaction --release | |
# Prepare output dir | |
mkdir -p build || exit 1 | |
cp target/release/testangel build/ | |
cp target/release/testangel-executor build/ | |
# Prepare engines | |
mkdir -p build/engines || exit 1 | |
cp target/release/libtestangel_arithmetic.dylib build/engines | |
cp target/release/libtestangel_compare.dylib build/engines | |
cp target/release/libtestangel_convert.dylib build/engines | |
cp target/release/libtestangel_date.dylib build/engines | |
cp target/release/libtestangel_evidence.dylib build/engines | |
cp target/release/libtestangel_rand.dylib build/engines | |
cp target/release/libtestangel_regex.dylib build/engines | |
cp target/release/libtestangel_user_interaction.dylib build/engines | |
- name: Save Cargo cache | |
uses: actions/cache/save@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Archive Release | |
uses: thedoctor0/[email protected] | |
with: | |
type: tar | |
path: build | |
filename: release-darwin.tar.gz | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: release-darwin.tar.gz | |
tag_name: ${{ needs.create-release.outputs.CARGO_PKG_VERSION }} | |
prerelease: ${{ needs.create-release.outputs.CARGO_PKG_PRERELEASE }} |