Skip to content

Release

Release #6

Workflow file for this run

name: Release
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
tag:
description: "Tag to release"
required: false
default: "v0.0.0"
permissions:
contents: write
jobs:
release:
name: release-${{ matrix.platform.asset_name }}
runs-on: ${{ matrix.platform.os }}
strategy:
matrix:
platform:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
asset_name: linux
arch: x86_64
- os: macos-latest
target: x86_64-apple-darwin
asset_name: darwin
arch: x86_64
- os: macos-latest
target: aarch64-apple-darwin
asset_name: darwin
arch: aarch64
- os: windows-latest
target: x86_64-pc-windows-msvc
asset_name: windows
arch: x86_64
env:
BINARY_NAME: keywatch-${{ matrix.platform.asset_name }}-${{ matrix.platform.arch }}${{ matrix.platform.os == 'windows-latest' && '.exe' || '' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract Release Notes
id: release-notes
if: matrix.platform.os == 'ubuntu-latest'
run: |
VERSION=${GITHUB_REF#refs/tags/}
NOTES=$(awk -v ver="$VERSION" '
/^## \[/ { if (p) { exit }; if ($2 == "['ver']") { p=1; next } }
p { print }
' CHANGELOG.md)
echo "NOTES<<EOF" >> $GITHUB_OUTPUT
echo "$NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.target }}
- name: Add aarch64 Apple target
if: matrix.platform.target == 'aarch64-apple-darwin'
run: rustup target add aarch64-apple-darwin
# Build the specific package
- name: Build Binary
run: |
cargo build --release --target ${{ matrix.platform.target }}
env:
CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER: aarch64-apple-darwin-gcc
- name: Prepare Asset
shell: bash
run: |
mkdir -p release
cp target/${{ matrix.platform.target }}/release/key-watch${{ matrix.platform.os == 'windows-latest' && '.exe' || '' }} \
release/${{ env.BINARY_NAME }}
# Windows: Generate checksum using cmd and Windows syntax.
- name: Generate SHA-256 (Windows)
if: matrix.platform.os == 'windows-latest'
shell: cmd
run: |
cd release
certutil -hashfile %BINARY_NAME% SHA256 | findstr /V "hash" > %BINARY_NAME%.sha256
# Unix (macOS/Ubuntu): Generate checksum using bash.
- name: Generate SHA-256 (Unix)
if: matrix.platform.os != 'windows-latest'
shell: bash
run: |
cd release
shasum -a 256 "$BINARY_NAME" > "$BINARY_NAME".sha256
# Create Release
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: "KeyWatch ${{ github.ref_name }}"
files: |
release/${{ env.BINARY_NAME }}
release/${{ env.BINARY_NAME }}.sha256
body: ${{ steps.release-notes.outputs.NOTES }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}