Skip to content

Release

Release #20

Workflow file for this run

name: Release
on:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
validate:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v6
- name: Read version from Cargo.toml
id: version
run: |
VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "Releasing version: ${VERSION}"
- name: Check tag does not already exist
run: |
if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
echo "::error::Tag v${{ steps.version.outputs.version }} already exists"
exit 1
fi
build:
needs: validate
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
artifact: linux-x86_64
- target: aarch64-unknown-linux-gnu
os: ubuntu-22.04-arm
artifact: linux-aarch64
- target: x86_64-apple-darwin
os: macos-15-intel
artifact: macos-x86_64
- target: aarch64-apple-darwin
os: macos-15
artifact: macos-aarch64
- target: x86_64-pc-windows-msvc
os: windows-latest
artifact: windows-x86_64
- target: aarch64-pc-windows-msvc
os: windows-11-arm
artifact: windows-aarch64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Install protobuf compiler
uses: ./.github/actions/setup-protoc
- name: Add Rust target
run: rustup target add ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Package .deb
if: runner.os == 'Linux'
run: |
cargo install cargo-deb --locked
cargo deb --no-build --target ${{ matrix.target }}
- name: Package .rpm
if: runner.os == 'Linux'
run: |
cargo install cargo-generate-rpm --locked
cargo generate-rpm --target ${{ matrix.target }}
- name: Package .msi
if: runner.os == 'Windows' && matrix.target != 'aarch64-pc-windows-msvc'
run: |
cargo install cargo-wix --locked
cargo wix --no-build --nocapture --target ${{ matrix.target }}
- name: Determine file extensions
id: ext
shell: bash
run: |
case "${{ runner.os }}" in
macOS) echo "lib=libleech2.dylib" >> "$GITHUB_OUTPUT"; echo "bin=lch" >> "$GITHUB_OUTPUT" ;;
Windows) echo "lib=leech2.dll" >> "$GITHUB_OUTPUT"; echo "bin=lch.exe" >> "$GITHUB_OUTPUT" ;;
*) echo "lib=libleech2.so" >> "$GITHUB_OUTPUT"; echo "bin=lch" >> "$GITHUB_OUTPUT" ;;
esac
- name: Create tarball
if: runner.os != 'Windows'
run: |
DIR="leech2-${{ needs.validate.outputs.version }}-${{ matrix.artifact }}"
mkdir -p "dist/${DIR}"
cp "target/${{ matrix.target }}/release/${{ steps.ext.outputs.bin }}" "dist/${DIR}/"
cp "target/${{ matrix.target }}/release/${{ steps.ext.outputs.lib }}" "dist/${DIR}/"
cp include/leech2.h "dist/${DIR}/"
cp README.md "dist/${DIR}/"
cp LICENSE "dist/${DIR}/"
cp "target/${{ matrix.target }}/release/man/lch.1" "target/${{ matrix.target }}/release/man/libleech2.3" "dist/${DIR}/"
tar czf "dist/${DIR}.tar.gz" -C dist "${DIR}"
- name: Create zip
if: runner.os == 'Windows'
shell: bash
run: |
DIR="leech2-${{ needs.validate.outputs.version }}-${{ matrix.artifact }}"
mkdir -p "dist/${DIR}"
cp "target/${{ matrix.target }}/release/${{ steps.ext.outputs.bin }}" "dist/${DIR}/"
cp "target/${{ matrix.target }}/release/${{ steps.ext.outputs.lib }}" "dist/${DIR}/"
cp include/leech2.h "dist/${DIR}/"
cp README.md "dist/${DIR}/"
cp LICENSE "dist/${DIR}/"
cd dist && 7z a "${DIR}.zip" "${DIR}"
- name: Upload tarball
if: runner.os != 'Windows'
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact }}-tarball
path: dist/*.tar.gz
- name: Upload zip
if: runner.os == 'Windows'
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact }}-zip
path: dist/*.zip
- name: Upload .deb
if: runner.os == 'Linux'
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact }}-deb
path: target/${{ matrix.target }}/debian/*.deb
- name: Upload .rpm
if: runner.os == 'Linux'
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact }}-rpm
path: target/${{ matrix.target }}/generate-rpm/*.rpm
- name: Upload .msi
if: runner.os == 'Windows' && matrix.target != 'aarch64-pc-windows-msvc'
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact }}-msi
path: target/wix/*.msi
release:
needs: [validate, build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: release-assets
merge-multiple: true
- name: Scan release assets for viruses
run: |
sudo apt-get update
sudo apt-get install -y clamav
sudo systemctl stop clamav-freshclam
sudo freshclam
clamscan --recursive --infected release-assets/
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "v${{ needs.validate.outputs.version }}" \
--title "leech2 v${{ needs.validate.outputs.version }}" \
--generate-notes \
release-assets/*