-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (67 loc) · 2.63 KB
/
release.yml
File metadata and controls
82 lines (67 loc) · 2.63 KB
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
75
76
77
78
79
80
81
82
# Release workflow for opencode-mem
# Triggers on version tags (e.g., v1.0.0).
# Builds the CLI binary for multiple targets, checksums them, and publishes a GitHub Release.
name: Release
on:
push:
tags:
- "v*"
# Required to create the GitHub release
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build-release:
name: Build for ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
# We define our build targets and whether they require `cross`
matrix:
include:
# Native Linux target (does not require cross)
- target: x86_64-unknown-linux-gnu
use_cross: false
# Static Linux binary (musl)
- target: x86_64-unknown-linux-musl
use_cross: true
# ARM64 Linux target
- target: aarch64-unknown-linux-gnu
use_cross: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install stable Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Setup Rust caching
uses: Swatinem/rust-cache@v2
- name: Install cross
if: matrix.use_cross == true
uses: taiki-e/install-action@cross
- name: Build binary (cargo)
if: matrix.use_cross == false
# Build specifically the opencode-mem-cli package
run: cargo build --release -p opencode-mem-cli --target ${{ matrix.target }}
- name: Build binary (cross)
if: matrix.use_cross == true
run: cross build --release -p opencode-mem-cli --target ${{ matrix.target }}
- name: Prepare artifact and calculate checksum
# The compiled binary is simply 'opencode-mem'
# We rename it to include the target architecture (e.g., 'opencode-mem-x86_64-unknown-linux-musl')
run: |
BIN_NAME="opencode-mem-${{ matrix.target }}"
# Move binary to the working directory with the target name attached
cp target/${{ matrix.target }}/release/opencode-mem $BIN_NAME
# Compute the SHA256 checksum for verification
sha256sum $BIN_NAME > $BIN_NAME.sha256
# Set an environment variable so the subsequent step can read the dynamically created filename
echo "ARTIFACT_NAME=$BIN_NAME" >> $GITHUB_ENV
- name: Upload binaries to GitHub Release
uses: softprops/action-gh-release@v2
with:
# Append the compiled binaries and checksums to the release created by the tag
files: |
${{ env.ARTIFACT_NAME }}
${{ env.ARTIFACT_NAME }}.sha256