Skip to content

Release

Release #5

Workflow file for this run

name: Release
on:
workflow_dispatch:
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
WINDIVERT_VERSION: "2.2.2"
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.meta.outputs.release_tag }}
release_name: ${{ steps.meta.outputs.release_name }}
prerelease: ${{ steps.meta.outputs.prerelease }}
steps:
- uses: actions/checkout@v4
- name: Prepare release metadata
id: meta
shell: bash
run: |
set -euo pipefail
version="$(python3 - <<'PY'
import tomllib
with open("Cargo.toml", "rb") as cargo_toml:
manifest = tomllib.load(cargo_toml)
print(manifest["workspace"]["package"]["version"])
PY
)"
timestamp="$(date -u +%Y%m%dT%H%M%SZ)"
unique="$(git rev-parse --short=12 HEAD)"
release_tag="v${version}-${timestamp}-${unique}"
release_name="ZeroDPI ${release_tag}"
prerelease=false
if [[ "$version" == *-* ]]; then
prerelease=true
fi
{
echo "release_tag=$release_tag"
echo "release_name=$release_name"
echo "prerelease=$prerelease"
} >> "$GITHUB_OUTPUT"
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install Linux build dependencies
run: sudo apt-get update && sudo apt-get install -y libnetfilter-queue-dev
- name: Build Linux package
run: python3 build.py --platform linux
- name: Verify Linux installer script
run: test -x dist/linux/install-systemd.sh
- name: Archive Linux package
run: tar -C dist/linux -czf zerodpi-linux-x86_64.tar.gz .
- uses: actions/upload-artifact@v4
with:
name: zerodpi-linux-x86_64
path: zerodpi-linux-x86_64.tar.gz
if-no-files-found: error
windows:
runs-on: windows-latest
env:
WINDIVERT_PATH: ${{ github.workspace }}\windivert
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Download WinDivert
shell: pwsh
run: |
$ver = $env:WINDIVERT_VERSION
$url = "https://github.com/basil00/WinDivert/releases/download/v$ver/WinDivert-$ver-A.zip"
Invoke-WebRequest -Uri $url -OutFile "$env:RUNNER_TEMP\windivert.zip"
Expand-Archive -Path "$env:RUNNER_TEMP\windivert.zip" -DestinationPath "$env:RUNNER_TEMP\windivert-extract"
$extracted = Get-ChildItem "$env:RUNNER_TEMP\windivert-extract" -Directory | Select-Object -First 1
$archDir = Join-Path $extracted.FullName "x64"
New-Item -ItemType Directory -Force -Path $env:WINDIVERT_PATH | Out-Null
Copy-Item -Recurse -Force "$archDir\*" $env:WINDIVERT_PATH
Set-Content -Path "$env:WINDIVERT_PATH\.version" -Value $ver -NoNewline
- name: Build Windows package
run: python build.py --platform windows --toolchain ""
- name: Archive Windows package
shell: pwsh
run: Compress-Archive -Path "dist\windows\*" -DestinationPath "zerodpi-windows-x86_64.zip"
- uses: actions/upload-artifact@v4
with:
name: zerodpi-windows-x86_64
path: zerodpi-windows-x86_64.zip
if-no-files-found: error
termux:
runs-on: ubuntu-latest
env:
TERMUX_ARCH: aarch64
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-linux-android
- uses: Swatinem/rust-cache@v2
- name: Build Termux Android package
shell: bash
run: printf '\n' | python3 build.py --platform termux --termux-arch "$TERMUX_ARCH"
- name: Archive Termux Android package
run: tar -C "dist/termux/$TERMUX_ARCH" -czf "zerodpi-termux-$TERMUX_ARCH.tar.gz" .
- uses: actions/upload-artifact@v4
with:
name: zerodpi-termux-aarch64
path: zerodpi-termux-aarch64.tar.gz
if-no-files-found: error
publish:
needs: [prepare, linux, windows, termux]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: dist
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.prepare.outputs.release_tag }}
name: ${{ needs.prepare.outputs.release_name }}
prerelease: ${{ needs.prepare.outputs.prerelease }}
generate_release_notes: true
files: |
dist/zerodpi-linux-x86_64/zerodpi-linux-x86_64.tar.gz
dist/zerodpi-windows-x86_64/zerodpi-windows-x86_64.zip
dist/zerodpi-termux-aarch64/zerodpi-termux-aarch64.tar.gz