-
Notifications
You must be signed in to change notification settings - Fork 182
85 lines (77 loc) · 2.73 KB
/
Copy pathbuild-binaries.yml
File metadata and controls
85 lines (77 loc) · 2.73 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
83
84
85
name: Build Binaries
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: 'Version tag (e.g. v0.8.1-beta.5)'
required: true
type: string
jobs:
build:
strategy:
matrix:
include:
- { target: x86_64-unknown-linux-gnu, runner: ubuntu-latest, os: linux, arch: x64, ext: "", archive: tar.gz }
- { target: aarch64-unknown-linux-gnu, runner: ubuntu-24.04-arm, os: linux, arch: arm64, ext: "", archive: tar.gz }
- { target: x86_64-pc-windows-msvc, runner: windows-latest, os: windows, arch: x64, ext: ".exe", archive: zip }
- { target: aarch64-pc-windows-msvc, runner: windows-latest, os: windows, arch: arm64, ext: ".exe", archive: zip }
runs-on: ${{ matrix.runner }}
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Resolve tag
id: tag
shell: bash
env:
INPUT_TAG: ${{ inputs.tag }}
run: |
if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then
TAG="$INPUT_TAG"
else
TAG="${GITHUB_REF_NAME}"
fi
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
- name: Install Rust target
run: rustup target add ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Package
shell: bash
env:
VERSION: ${{ steps.tag.outputs.version }}
run: |
NAME="openab-${VERSION}-${{ matrix.os }}-${{ matrix.arch }}"
mkdir -p dist
cp target/${{ matrix.target }}/release/openab${{ matrix.ext }} dist/
cp config.toml.example dist/
cd dist
if [ "${{ matrix.archive }}" = "zip" ]; then
7z a ../${NAME}.zip *
else
tar czf ../${NAME}.tar.gz *
fi
- name: Upload to release
if: github.event_name == 'push'
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.tag.outputs.version }}
TAG: ${{ steps.tag.outputs.tag }}
shell: bash
run: |
NAME="openab-${VERSION}-${{ matrix.os }}-${{ matrix.arch }}.${{ matrix.archive }}"
# Helm release uses openab-X.Y.Z tag, binary release uses vX.Y.Z tag
# Try both — one will exist
gh release upload "openab-${VERSION}" "$NAME" --clobber 2>/dev/null \
|| gh release upload "$TAG" "$NAME" --clobber \
|| true
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: openab-${{ matrix.os }}-${{ matrix.arch }}
path: openab-*.${{ matrix.archive }}
retention-days: 7