chessbaseLinux/.github/workflows/release.yml

229 lines
9 KiB
YAML

# Builds release packages on a version tag (v0.1.0, v0.2.0-beta.1, ...) and publishes a GitHub Release.
# Manual runs (workflow_dispatch) build everything and keep it as workflow artifacts only.
name: Release
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
version:
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.v.outputs.version }}
version_code: ${{ steps.release_intent.outputs.version_code }}
android: ${{ steps.release_intent.outputs.android }}
intent: ${{ steps.release_intent.outputs.intent }}
steps:
- uses: actions/checkout@v7
- id: v
name: Read and check the version
run: |
version=$(grep -m1 '^version' Cargo.toml | cut -d'"' -f2)
if [[ "${GITHUB_REF_TYPE}" == "tag" && "${GITHUB_REF_NAME}" != "v${version}" ]]; then
echo "::error::Tag ${GITHUB_REF_NAME} does not match Cargo.toml version ${version}"
exit 1
fi
echo "version=${version}" >> "${GITHUB_OUTPUT}"
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- id: release_intent
name: Validate notes and classify Android release intent
run: |
if [[ "${GITHUB_REF_TYPE}" != "tag" ]]; then
# Manual runs build every platform and therefore always require current notes.
python3 -I androidApp/scripts/check_release_notes.py require-current --repo-root .
fi
python3 -I androidApp/scripts/check_release_notes.py ci-intent --repo-root . >> "${GITHUB_OUTPUT}"
linux:
needs: version
# Oldest supported runner: binaries and the AppImage then run on older glibc too.
runs-on: ubuntu-22.04
env:
VERSION: ${{ needs.version.outputs.version }}
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: System libraries
run: sudo apt-get update && sudo apt-get install -y pkg-config libasound2-dev libxkbcommon-dev libwayland-dev libfuse2
- run: cargo build --release --locked -p chesspenguin
# Stockfish is not bundled here: the program downloads it on request (decision 14).
- name: Tarball
run: |
name="ChessPenguin-${VERSION}-linux-x86_64"
mkdir -p "dist/${name}"
cp target/release/chesspenguin LICENSE README.md THIRD_PARTY_NOTICES.md "dist/${name}/"
cp -r packaging/icons packaging/*.desktop examples "dist/${name}/"
tar -C dist -czf "dist/${name}.tar.gz" "${name}"
rm -rf "dist/${name}"
- name: deb, rpm and Arch Linux packages
run: |
curl -fsSL -o /tmp/nfpm.deb https://github.com/goreleaser/nfpm/releases/download/v2.48.0/nfpm_2.48.0_amd64.deb
sudo dpkg -i /tmp/nfpm.deb
nfpm package -f packaging/nfpm.yaml -p deb -t dist/
nfpm package -f packaging/nfpm.yaml -p rpm -t dist/
nfpm package -f packaging/nfpm.yaml -p archlinux -t dist/
- name: AppImage
run: packaging/build-appimage.sh dist
- uses: actions/upload-artifact@v7
with:
name: linux
path: dist/*
flatpak:
needs: version
runs-on: ubuntu-24.04
container:
image: ghcr.io/flathub-infra/flatpak-github-actions:freedesktop-25.08
options: --privileged
steps:
- uses: actions/checkout@v7
- uses: flatpak/flatpak-github-actions/flatpak-builder@v6
with:
bundle: ChessPenguin-${{ needs.version.outputs.version }}-x86_64.flatpak
manifest-path: packaging/flatpak/io.github.vrubelroman.chessPenguin.yml
cache-key: flatpak-builder-${{ github.sha }}
upload-artifact: false
- uses: actions/upload-artifact@v7
with:
name: flatpak
path: ChessPenguin-*.flatpak
windows:
needs: version
runs-on: windows-latest
env:
VERSION: ${{ needs.version.outputs.version }}
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo build --release --locked -p chesspenguin
- name: Zip
shell: pwsh
run: |
$name = "ChessPenguin-$env:VERSION-windows-x86_64"
New-Item -ItemType Directory -Force -Path "dist/$name" | Out-Null
Copy-Item target/release/chesspenguin.exe "dist/$name/ChessPenguin.exe"
Copy-Item LICENSE, README.md, THIRD_PARTY_NOTICES.md "dist/$name/"
Copy-Item -Recurse examples "dist/$name/"
Compress-Archive -Path "dist/$name" -DestinationPath "dist/$name.zip"
Remove-Item -Recurse "dist/$name"
- uses: actions/upload-artifact@v7
with:
name: windows
path: dist/*
macos:
needs: version
# Apple Silicon (arm64). Not signed by Apple yet: the first start goes through
# "Open" in the context menu (decision 15).
runs-on: macos-15
env:
VERSION: ${{ needs.version.outputs.version }}
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo build --release --locked -p chesspenguin
- name: App bundle and disk image
run: packaging/macos/build-app.sh dist
- uses: actions/upload-artifact@v7
with:
name: macos
path: dist/*
android:
needs: version
if: needs.version.outputs.android == 'true'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "21"
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-linux-android,x86_64-linux-android
- uses: Swatinem/rust-cache@v2
- name: Android NDK and platform, cargo-ndk
run: |
yes | "${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager" --install "ndk;30.0.16248370" "platforms;android-37.0" > /dev/null
cargo install cargo-ndk --version 4.1.2 --locked
# Two APKs: Stockfish built in, and Stockfish downloaded in the app
# (androidApp/scripts/release.sh, which also builds Stockfish from its source).
# The signing key comes from the repository secrets.
- name: Signed APKs
env:
KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
CP_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
CP_KEY_ALIAS: chesspenguin
CP_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
run: |
if [[ -z "${KEYSTORE_BASE64}" ]]; then
echo "::error::The Android signing key is not in the repository secrets"
exit 1
fi
export CP_KEYSTORE="${RUNNER_TEMP}/release.jks"
echo "${KEYSTORE_BASE64}" | base64 -d > "${CP_KEYSTORE}"
export ANDROID_NDK_HOME="${ANDROID_HOME}/ndk/30.0.16248370"
androidApp/scripts/release.sh
rm -f "${CP_KEYSTORE}"
- uses: actions/upload-artifact@v7
with:
name: android
path: androidApp/dist/*.apk
# The RuStore build: uploaded to the store by hand, not a file of the release.
- uses: actions/upload-artifact@v7
with:
name: rustore
path: androidApp/dist-rustore/*.apk
publish:
needs: [version, linux, flatpak, windows, macos, android]
if: >-
${{ always() && github.ref_type == 'tag' &&
needs.version.result == 'success' &&
needs.linux.result == 'success' &&
needs.flatpak.result == 'success' &&
needs.windows.result == 'success' &&
needs.macos.result == 'success' &&
(needs.android.result == 'success' || needs.android.result == 'skipped') }}
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
# The RuStore build stays an artifact of the run (merge-multiple brought it here).
- name: Not the store's build
run: rm -f dist/*-rustore.apk
- name: Stockfish source (GPL-3.0 source offer for the engine bundled in the Flatpak and Android)
run: packaging/stockfish.sh source dist
- name: Checksums
run: cd dist && sha256sum * > SHA256SUMS.txt
# The release page says what is new: the site and the apps' "What's new" lead there.
- name: Release notes (this version's section of CHANGELOG.md)
run: |
v="${GITHUB_REF_NAME#v}"
awk -v h="## [$v]" 'index($0, h) == 1 { f = 1; next } f && /^## \[/ { exit } f' CHANGELOG.md > "${RUNNER_TEMP}/notes.md"
test -s "${RUNNER_TEMP}/notes.md" || echo "See CHANGELOG.md." > "${RUNNER_TEMP}/notes.md"
- uses: softprops/action-gh-release@v3
with:
files: dist/*
body_path: ${{ runner.temp }}/notes.md
generate_release_notes: true
# v1.0.0-beta.1 and similar tags become pre-releases.
prerelease: ${{ contains(github.ref_name, '-') }}