-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (80 loc) · 3.39 KB
/
release.yml
File metadata and controls
96 lines (80 loc) · 3.39 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
86
87
88
89
90
91
92
93
94
95
96
# .github/workflows/release.yml
name: Build Release Binaries
on:
workflow_dispatch:
inputs:
release_tag:
description: 'Release tag (e.g., v1.0.0)'
required: true
default: 'v0.0.0-snapshot'
env:
CARGO_TERM_COLOR: always
MAIN_BINARY_NAME: serval
CHECK_BINARY_NAME: serval-check
XMP_EXTRACT_BINARY_NAME: serval-xmp-extract
RELEASE_PROFILE_NAME: release-lto
jobs:
build_release:
name: Build for ${{ matrix.os }} (${{ matrix.artifact_suffix }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_suffix: linux-amd64
binary_ext: ""
- os: macos-latest
target: x86_64-apple-darwin
artifact_suffix: macos-amd64
binary_ext: ""
- os: macos-latest
target: aarch64-apple-darwin
artifact_suffix: macos-arm64
binary_ext: ""
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_suffix: windows-amd64
binary_ext: ".exe"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ env.RELEASE_PROFILE_NAME }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-cargo-${{ env.RELEASE_PROFILE_NAME }}-
- name: Build all binaries in release mode
run: cargo build --profile ${{ env.RELEASE_PROFILE_NAME }} --bins --target ${{ matrix.target }}
- name: Prepare artifacts for ${{ matrix.os }} (${{ matrix.artifact_suffix }})
shell: bash
run: |
# The output directory for a custom profile is target/<target_triple>/<profile_name>
SOURCE_RELEASE_DIR="target/${{ matrix.target }}/${{ env.RELEASE_PROFILE_NAME }}"
STAGING_DIR="staging/${{ env.MAIN_BINARY_NAME }}-${{ github.event.inputs.release_tag }}-${{ matrix.artifact_suffix }}"
mkdir -p "${STAGING_DIR}"
echo "Source release directory: ${SOURCE_RELEASE_DIR}"
echo "Staging directory: ${STAGING_DIR}"
echo "Binary extension: ${{ matrix.binary_ext }}"
cp "${SOURCE_RELEASE_DIR}/${{ env.MAIN_BINARY_NAME }}${{ matrix.binary_ext }}" "${STAGING_DIR}/"
cp "${SOURCE_RELEASE_DIR}/${{ env.CHECK_BINARY_NAME }}${{ matrix.binary_ext }}" "${STAGING_DIR}/"
cp "${SOURCE_RELEASE_DIR}/${{ env.XMP_EXTRACT_BINARY_NAME }}${{ matrix.binary_ext }}" "${STAGING_DIR}/"
ls -R "${STAGING_DIR}"
- name: Upload artifact for ${{ matrix.os }} (${{ matrix.artifact_suffix }})
uses: actions/upload-artifact@v4
with:
name: ${{ env.MAIN_BINARY_NAME }}-${{ github.event.inputs.release_tag }}-${{ matrix.artifact_suffix }}
path: staging/${{ env.MAIN_BINARY_NAME }}-${{ github.event.inputs.release_tag }}-${{ matrix.artifact_suffix }}
compression-level: 9
if-no-files-found: error