Skip to content

0.21.0 (#229)

0.21.0 (#229) #90

Workflow file for this run

name: Build Rust Applications
on:
push:
branches:
- main
- next
jobs:
establish-version:
name: Establish Version
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
check-branch:
name: Check branch
runs-on: ubuntu-latest
needs: establish-version
steps:
- name: Check only release version on the 'main' branch
if: github.ref == 'refs/heads/main'
run: |
if [[ "${{ needs.establish-version.outputs.CARGO_PKG_PRERELEASE }}" == "true" ]]; then exit 1; fi
- name: Check only pre-release version on the 'next' branch
if: github.ref == 'refs/heads/next'
run: |
if [[ "${{ needs.establish-version.outputs.CARGO_PKG_PRERELEASE }}" == "false" ]]; then exit 1; fi
create-release:
name: Create Release
runs-on: ubuntu-latest
needs:
- establish-version
- check-branch
permissions: write-all
steps:
- name: Create Tag and Release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.establish-version.outputs.CARGO_PKG_VERSION }}
release_name: v${{ needs.establish-version.outputs.CARGO_PKG_VERSION }}
prerelease: ${{ needs.establish-version.outputs.CARGO_PKG_PRERELEASE }}
build:
name: Build for Linux
runs-on: ubuntu-latest
needs:
- establish-version
- 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 gtksourceview5-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-evidence --release
cargo build -p testangel-rand --release
cargo build -p testangel-time --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_evidence.so build/engines
cp target/release/libtestangel_rand.so build/engines
cp target/release/libtestangel_time.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.establish-version.outputs.CARGO_PKG_VERSION }}
prerelease: ${{ needs.establish-version.outputs.CARGO_PKG_PRERELEASE }}
build-win:
name: Build for Windows
runs-on: windows-latest
needs:
- establish-version
- 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: Get latest Win-GTK4 build
id: wingtk-install
shell: bash
run: |
REPO_OWNER="wingtk" # Replace with the owner of the repository
REPO_NAME="gvsbuild" # Replace with the name of the repository
ASSET_PREFIX="GTK4" # The prefix of the asset you want to download
mkdir -p "${ASSET_PREFIX}"
cd "${ASSET_PREFIX}" || exit 1
# Get the latest release
RELEASE_INFO=$(curl -s \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/releases/latest")
# Extract the asset URL that starts with the specified prefix
ASSET_URL=$(echo "$RELEASE_INFO" | jq -r --arg ASSET_PREFIX "$ASSET_PREFIX" \
'.assets[] | select(.name | startswith($ASSET_PREFIX)) | .url')
if [ -z "$ASSET_URL" ]; then
echo "No asset found starting with '$ASSET_PREFIX'!"
exit 1
fi
# Download the asset
curl -L \
-H "Accept: application/octet-stream" \
"$ASSET_URL" -o "${ASSET_PREFIX}_asset.zip"
echo "Downloaded asset: ${ASSET_PREFIX}_asset.zip"
unzip "${ASSET_PREFIX}_asset.zip"
rm -f "${ASSET_PREFIX}_asset.zip"
rm -rf "include/" "python/" "wheels/"
BASE_DIR=$(pwd)
echo "BASE_DIR=${BASE_DIR}" >> $GITHUB_OUTPUT
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Build
shell: bash
run: |
PATH="${{ steps.wingtk-install.outputs.BASE_DIR }}/bin:$PATH"
LIB="${{ steps.wingtk-install.outputs.BASE_DIR }}/lib:$LIB"
INCLUDE="${{ steps.wingtk-install.outputs.BASE_DIR }}/include:${{ steps.wingtk-install.outputs.BASE_DIR }}/include/cairo:${{ steps.wingtk-install.outputs.BASE_DIR }}/include/glib-2.0:${{ steps.wingtk-install.outputs.BASE_DIR }}/include/gobject-introspection-1.0:${{ steps.wingtk-install.outputs.BASE_DIR }}/lib/glib-2.0/include:$INCLUDE"
PKG_CONFIG_PATH="${{ steps.wingtk-install.outputs.BASE_DIR }}/lib/pkgconfig:$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-evidence --release
cargo build -p testangel-rand --release
cargo build -p testangel-time --release
cargo build -p testangel-user-interaction --release
mkdir -p build/bin
cp target/release/testangel.exe build/bin/
cargo build -p testangel --bin testangel --release --features windows-keep-console-window
cp target/release/testangel.exe build/bin/testangel-dbg.exe
cp target/release/testangel-executor.exe build/
mkdir build/engines
cp target/release/testangel_evidence.dll build/engines/
cp target/release/testangel_rand.dll build/engines/
cp target/release/testangel_time.dll build/engines/
cp target/release/testangel_user_interaction.dll build/engines/
rm -rf ${{ steps.wingtk-install.outputs.BASE_DIR }}/include
cp -r ${{ steps.wingtk-install.outputs.BASE_DIR }}/* build/
- 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.establish-version.outputs.CARGO_PKG_VERSION }}
prerelease: ${{ needs.establish-version.outputs.CARGO_PKG_PRERELEASE }}