Skip to content

release v0.1.9

release v0.1.9 #10

Workflow file for this run

name: release
on:
push:
tags:
- "v*"
workflow_dispatch:
jobs:
build:
name: build-${{ matrix.label }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
label: linux-x86_64
archive_ext: tar.gz
# `macos-13` is not available in every GitHub Actions environment.
# Build the Intel binary on a supported Apple Silicon runner instead.
- os: macos-14
target: x86_64-apple-darwin
label: macos-x86_64
archive_ext: tar.gz
- os: macos-14
target: aarch64-apple-darwin
label: macos-aarch64
archive_ext: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
label: windows-x86_64
archive_ext: zip
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build release binary
run: cargo build --locked --release --target ${{ matrix.target }}
- name: Package archive (Unix)
if: runner.os != 'Windows'
id: package-unix
shell: bash
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME}"
if [[ "${GITHUB_REF_TYPE}" != "tag" ]]; then
VERSION="manual-${GITHUB_RUN_NUMBER}"
fi
PKG="sqtop-${VERSION}-${{ matrix.label }}"
mkdir -p "dist/${PKG}"
cp "target/${{ matrix.target }}/release/sqtop" "dist/${PKG}/sqtop"
cp README.md README.zh-CN.md LICENSE config.example.toml "dist/${PKG}/"
tar -C dist -czf "dist/${PKG}.tar.gz" "${PKG}"
echo "asset_path=dist/${PKG}.tar.gz" >> "$GITHUB_OUTPUT"
echo "asset_name=${PKG}.tar.gz" >> "$GITHUB_OUTPUT"
- name: Package archive (Windows)
if: runner.os == 'Windows'
id: package-windows
shell: pwsh
run: |
$version = $env:GITHUB_REF_NAME
if ($env:GITHUB_REF_TYPE -ne "tag") {
$version = "manual-$env:GITHUB_RUN_NUMBER"
}
$pkg = "sqtop-$version-${{ matrix.label }}"
New-Item -ItemType Directory -Path "dist/$pkg" -Force | Out-Null
Copy-Item "target/${{ matrix.target }}/release/sqtop.exe" "dist/$pkg/sqtop.exe"
Copy-Item README.md, README.zh-CN.md, LICENSE, config.example.toml "dist/$pkg/"
Compress-Archive -Path "dist/$pkg/*" -DestinationPath "dist/$pkg.zip" -Force
"asset_path=dist/$pkg.zip" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
"asset_name=$pkg.zip" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Upload packaged artifact (Unix)
if: runner.os != 'Windows'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.label }}
path: ${{ steps.package-unix.outputs.asset_path }}
- name: Upload packaged artifact (Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.label }}
path: ${{ steps.package-windows.outputs.asset_path }}
release:
name: publish-release
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts
merge-multiple: true
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: release-artifacts/*