109 lines
3.7 KiB
YAML
109 lines
3.7 KiB
YAML
name: Release Smoke Test
|
|
on:
|
|
push:
|
|
tags:
|
|
- '[0-9]+.[0-9]+.[0-9]+'
|
|
- 'v[0-9]+.[0-9]+.[0-9]+'
|
|
release:
|
|
types: [published]
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: 'Version to publish (e.g. 0.3.4)'
|
|
required: true
|
|
permissions:
|
|
contents: write
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
jobs:
|
|
smoke-test:
|
|
name: Smoke Test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
- name: Set up Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: rustfmt, clippy
|
|
- name: Check formatting
|
|
run: cargo fmt --all -- --check
|
|
- name: Run Clippy Lints
|
|
run: cargo clippy -- -D warnings
|
|
- name: Build release
|
|
run: cargo build --release --verbose
|
|
- name: Run tests
|
|
run: cargo test --verbose
|
|
- name: Smoke test — binary runs
|
|
run: ./target/release/lapctl --version
|
|
- name: Upload release artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: lapctl-${{ github.ref_name }}
|
|
path: ./target/release/lapctl
|
|
- name: Publish to crates.io
|
|
continue-on-error: true
|
|
env:
|
|
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
|
run: cargo publish
|
|
publish-aur:
|
|
name: Publish to AUR
|
|
needs: smoke-test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
- name: Set up Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
- name: Get version
|
|
id: version
|
|
run: echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
env:
|
|
VERSION: ${{ github.event.inputs.version || github.ref_name }}
|
|
- name: Download release binary
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: lapctl-${{ github.ref_name }}
|
|
path: .
|
|
- name: Create tarball with binary
|
|
run: |
|
|
tar czf "lapctl-${{ steps.version.outputs.version }}-x86_64.tar.gz" \
|
|
--transform="s/^.*\///" lapctl
|
|
- name: Generate PKGBUILD with cargo-aur
|
|
run: |
|
|
cargo install cargo-aur
|
|
mkdir -p aur-pkg
|
|
cargo aur --output aur-pkg
|
|
- name: Update PKGBUILD checksums
|
|
run: |
|
|
SHA=$(sha256sum "lapctl-${{ steps.version.outputs.version }}-x86_64.tar.gz" | cut -d' ' -f1)
|
|
sed -i "s/sha256sums=([^)]*)/sha256sums=('$SHA')/" aur-pkg/PKGBUILD
|
|
- name: Generate .SRCINFO
|
|
run: |
|
|
docker run --rm -v "$(pwd)/aur-pkg:/build" archlinux:latest \
|
|
bash -c "
|
|
useradd -m builder
|
|
chown -R builder:builder /build
|
|
cd /build && su builder -c 'makepkg --printsrcinfo > .SRCINFO'
|
|
"
|
|
- name: Push to AUR
|
|
uses: KSXGitHub/github-actions-deploy-aur@v2.5.0
|
|
with:
|
|
pkgname: lapctl-bin
|
|
pkgbuild: aur-pkg/PKGBUILD
|
|
assets: aur-pkg/.SRCINFO
|
|
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
|
ssh_keyscan_types: rsa,ecdsa,ed25519
|
|
commit_username: ${{ github.actor }}
|
|
commit_email: ${{ github.actor }}@users.noreply.github.com
|
|
- name: Upload tarball to release
|
|
if: github.ref_type == 'tag'
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
gh release upload "${{ github.ref_name }}" \
|
|
"lapctl-${{ steps.version.outputs.version }}-x86_64.tar.gz" --clobber 2>/dev/null ||
|
|
gh release create "${{ github.ref_name }}" --title "${{ github.ref_name }}" --notes "" &&
|
|
gh release upload "${{ github.ref_name }}" \
|
|
"lapctl-${{ steps.version.outputs.version }}-x86_64.tar.gz" --clobber
|