Skip to content

chore: release termviz 0.2.2 #3

chore: release termviz 0.2.2

chore: release termviz 0.2.2 #3

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Release tag to publish, for example v0.2.0"
required: true
type: string
env:
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }}
LINUX_X64_TARGET: x86_64-unknown-linux-musl
permissions:
contents: read
jobs:
build-linux-x64:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v5
with:
ref: ${{ env.RELEASE_TAG }}
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Install Linux x64 static build target
shell: bash
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y musl-tools binutils file
rustup target add "$LINUX_X64_TARGET"
- name: Validate tag and package versions
id: version
shell: bash
run: |
set -euo pipefail
version="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n 1)"
tag="${RELEASE_TAG#v}"
test "$version" = "$tag"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT"
- run: cargo fmt --check
- run: cargo test --locked
- run: cargo clippy --all-targets --locked -- -D warnings
- run: cargo build --release --locked --target "$LINUX_X64_TARGET"
- name: Package Linux x64 static binary
shell: bash
run: |
set -euo pipefail
mkdir -p dist/termviz-linux-x64
cp "target/$LINUX_X64_TARGET/release/termviz" dist/termviz-linux-x64/
cp "target/$LINUX_X64_TARGET/release/termviz" dist/termviz
cp README.md LICENSE dist/termviz-linux-x64/
file dist/termviz-linux-x64/termviz
if readelf -l dist/termviz-linux-x64/termviz | grep -q "Requesting program interpreter"; then
echo "Expected a static Linux x64 binary without a glibc runtime dependency." >&2
exit 1
fi
dist/termviz-linux-x64/termviz --version
tar -C dist -czf "dist/termviz-linux-x64.tar.gz" termviz-linux-x64
- uses: actions/upload-artifact@v7
with:
name: termviz-linux-x64
path: |
dist/termviz-linux-x64.tar.gz
dist/termviz
github-release:
runs-on: ubuntu-latest
needs: build-linux-x64
permissions:
contents: write
steps:
- uses: actions/checkout@v5
with:
ref: ${{ needs.build-linux-x64.outputs.tag }}
- uses: actions/download-artifact@v8
with:
name: termviz-linux-x64
path: dist
- name: Create checksums
shell: bash
run: |
set -euo pipefail
cd dist
sha256sum termviz-linux-x64.tar.gz > sha256sums.txt
- name: Extract release notes
id: release-notes
env:
TAG: ${{ needs.build-linux-x64.outputs.tag }}
shell: bash
run: |
set -euo pipefail
version="${TAG#v}"
notes_file="$RUNNER_TEMP/release-notes.md"
awk -v version="$version" '
$0 == "## [" version "]" || $0 ~ "^## \\[" version "\\] - " {
found = 1
next
}
found && /^## / {
exit
}
found {
print
}
' CHANGELOG.md > "$notes_file"
if ! grep -q '[^[:space:]]' "$notes_file"; then
echo "CHANGELOG.md is missing a non-empty section for $TAG." >&2
exit 1
fi
echo "file=$notes_file" >> "$GITHUB_OUTPUT"
- name: Publish GitHub Release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
TAG: ${{ needs.build-linux-x64.outputs.tag }}
NOTES_FILE: ${{ steps.release-notes.outputs.file }}
shell: bash
run: |
set -euo pipefail
if gh release view "$TAG" --repo "$GH_REPO" >/dev/null 2>&1; then
gh release edit "$TAG" --repo "$GH_REPO" --notes-file "$NOTES_FILE"
gh release upload "$TAG" dist/termviz-linux-x64.tar.gz dist/sha256sums.txt --clobber --repo "$GH_REPO"
else
gh release create "$TAG" dist/termviz-linux-x64.tar.gz dist/sha256sums.txt \
--repo "$GH_REPO" \
--verify-tag \
--title "$TAG" \
--notes-file "$NOTES_FILE"
fi