name: Release
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: write
env:
PROJECT_NAME: waywarp
jobs:
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
artifact_name: waywarp-linux-x86_64
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
artifact_name: waywarp-linux-aarch64
steps:
- uses: actions/checkout@v4
- name: Install System Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libwayland-dev libxkbcommon-dev libcairo2-dev libpango1.0-dev
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build release binary
shell: bash
run: |
cargo build --release --target ${{ matrix.target }}
- name: Rename release binary
shell: bash
run: |
cp target/${{ matrix.target }}/release/waywarp ${{ matrix.artifact_name }}
chmod +x ${{ matrix.artifact_name }}
- name: Package archive
shell: bash
run: |
cd target/${{ matrix.target }}/release
tar czf ../../../${{ env.PROJECT_NAME }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz \
${{ env.PROJECT_NAME }}
- name: Generate SHA256 checksum
shell: bash
run: |
sha256sum ${{ env.PROJECT_NAME }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz \
> ${{ env.PROJECT_NAME }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz.sha256
- name: Package for Linux distributions
shell: bash
run: |
ARCH_TYPE=$(uname -m)
if [ "$ARCH_TYPE" = "aarch64" ]; then
NFPM_ARCH="arm64"
ARCH="arm64"
PKG_ARCH="aarch64"
else
NFPM_ARCH="x86_64"
ARCH="amd64"
PKG_ARCH="x86_64"
fi
# Download nFPM based on runner architecture
curl -sL https://github.com/goreleaser/nfpm/releases/download/v2.37.1/nfpm_2.37.1_Linux_${NFPM_ARCH}.tar.gz | tar xz nfpm
# Prepare binary for nFPM
cp target/${{ matrix.target }}/release/waywarp ./waywarp
chmod +x ./waywarp
# Extract version robustly
VERSION=${GITHUB_REF_NAME#v}
if [ -z "$VERSION" ]; then
VERSION="0.1.0"
fi
export VERSION
export ARCH
export BINARY_SRC="./waywarp"
./nfpm pkg --config packaging/nfpm.yaml --packager deb --target waywarp-linux-${PKG_ARCH}.deb
./nfpm pkg --config packaging/nfpm.yaml --packager rpm --target waywarp-linux-${PKG_ARCH}.rpm
./nfpm pkg --config packaging/nfpm.yaml --packager archlinux --target waywarp-linux-${PKG_ARCH}.pkg.tar.zst
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.target }}
path: |
${{ env.PROJECT_NAME }}-*.tar.gz
${{ env.PROJECT_NAME }}-*.zip
${{ env.PROJECT_NAME }}-*.sha256
waywarp-linux-*
*.deb
*.rpm
*.pkg.tar.zst
if-no-files-found: error
release:
name: GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: build-*
merge-multiple: true
- name: Create release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-crates:
name: Publish to crates.io
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install System Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libwayland-dev libxkbcommon-dev libcairo2-dev libpango1.0-dev
- uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
shell: bash
run: |
VERSION=$(grep '^version =' Cargo.toml | head -n1 | cut -d'"' -f2)
STATUS=$(curl -sI -o /dev/null -w "%{http_code}" -H "User-Agent: waywarp-release-agent (xuepoo@gmail.com)" "https://crates.io/api/v1/crates/waywarp/$VERSION")
if [ "$STATUS" = "200" ]; then
echo "Version $VERSION of waywarp is already published on crates.io. Skipping publish."
else
cargo publish
fi
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
publish-aur:
name: Update AUR Package
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download Linux artifact checksum
uses: actions/download-artifact@v4
with:
name: build-x86_64-unknown-linux-gnu
path: artifacts
- name: Publish waywarp (source) to AUR
uses: KSXGitHub/github-actions-deploy-aur@v3
with:
pkgname: waywarp
pkgbuild: ./packaging/waywarp/PKGBUILD
commit_username: Xuepoo
commit_email: xuepoo@users.noreply.github.com
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: "chore: update to ${{ github.ref_name }}"
- name: Publish waywarp-bin to AUR
uses: KSXGitHub/github-actions-deploy-aur@v3
with:
pkgname: waywarp-bin
pkgbuild: ./packaging/waywarp-bin/PKGBUILD
commit_username: Xuepoo
commit_email: xuepoo@users.noreply.github.com
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: "chore: update to ${{ github.ref_name }}"