1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g. v0.1.1)'
required: true
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
target: aarch64-apple-darwin
archive: tar
- os: macos-latest
target: x86_64-apple-darwin
archive: tar
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
archive: tar
- os: windows-latest
target: x86_64-pc-windows-msvc
archive: zip
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('Cargo.lock') }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Package
shell: bash
run: |
TAG="${{ github.event.inputs.tag || github.ref_name }}"
BIN_DIR="target/${{ matrix.target }}/release"
if [ "${{ matrix.archive }}" = "zip" ]; then
ARCHIVE="hypha-${TAG}-${{ matrix.target }}.zip"
cd "$BIN_DIR" && 7z a "../../../$ARCHIVE" hypha.exe && cd -
else
ARCHIVE="hypha-${TAG}-${{ matrix.target }}.tar.gz"
tar -czf "$ARCHIVE" -C "$BIN_DIR" hypha
fi
sha256sum "$ARCHIVE" > "${ARCHIVE}.sha256" 2>/dev/null || shasum -a 256 "$ARCHIVE" > "${ARCHIVE}.sha256"
echo "TAG=$TAG" >> "$GITHUB_ENV"
echo "ARCHIVE=$ARCHIVE" >> "$GITHUB_ENV"
- name: Upload to release
shell: bash
run: gh release upload "$TAG" "$ARCHIVE" "${ARCHIVE}.sha256" --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}