name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
permissions:
contents: write
jobs:
test:
name: Test & Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --workspace -- -D warnings
- name: Run tests
run: cargo test --workspace
build:
name: Build ${{ matrix.target }}
needs: test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- os: macos-14
target: aarch64-apple-darwin
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install Linux ARM64 linker
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV"
- name: Build release binary
run: cargo build --release --locked -p vessel-pty --target ${{ matrix.target }}
- name: Package archive and checksums
shell: bash
run: |
set -euo pipefail
mkdir -p dist
BIN_PATH="target/${{ matrix.target }}/release/vessel"
ARCHIVE="vessel-${{ matrix.target }}.tar.gz"
tar -C "$(dirname "$BIN_PATH")" -czf "dist/${ARCHIVE}" "vessel"
cd dist && shasum -a 256 "${ARCHIVE}" > "${ARCHIVE}.sha256"
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.target }}
path: dist/*
crates-publish:
name: Publish to crates.io
needs: [test, build]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Publish vessel-pty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
set -euo pipefail
if [ -z "${CARGO_REGISTRY_TOKEN:-}" ]; then
echo "CARGO_REGISTRY_TOKEN is required for tagged releases" >&2
exit 1
fi
published=0
for attempt in 1 2 3; do
if cargo publish -p vessel-pty --locked; then
published=1
break
fi
if [ "${attempt}" -lt 3 ]; then
echo "publish retry ${attempt}/3 after transient failure"
sleep 30
fi
done
if [ "${published}" -ne 1 ]; then
echo "cargo publish -p vessel-pty failed after retries" >&2
exit 1
fi
release:
name: GitHub Release
needs: [build, crates-publish]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
id: changelog
run: |
set -euo pipefail
TAG="${GITHUB_REF#refs/tags/}"
# Find the previous tag
PREV_TAG=$(git tag --sort=-version:refname | grep '^v' | sed -n '2p' || true)
{
echo "body<<CHANGELOG_EOF"
if [ -n "$PREV_TAG" ]; then
echo "## Changes since ${PREV_TAG}"
echo ""
git log "${PREV_TAG}..${TAG}" --pretty=format:"- %s (%h)" --no-merges 2>/dev/null || \
echo "- Initial release"
else
echo "## Initial Release"
echo ""
git log --pretty=format:"- %s (%h)" --no-merges -50
fi
echo ""
echo ""
echo "## Installation"
echo ""
echo '```bash'
echo "# From crates.io"
echo "cargo install vessel-pty"
echo ""
echo "# Or download a binary from the assets below"
echo '```'
echo "CHANGELOG_EOF"
} >> "$GITHUB_OUTPUT"
- name: Download all build artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: List release artifacts
run: ls -la dist/
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/*
body: ${{ steps.changelog.outputs.body }}
draft: false
prerelease: ${{ contains(github.ref, '-rc') || contains(github.ref, '-beta') || contains(github.ref, '-alpha') }}