forked from astriaorg/astria
-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (67 loc) · 2.57 KB
/
reusable-build.yml
File metadata and controls
72 lines (67 loc) · 2.57 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
name: Reusable Binary Build && Push Workflow
on:
workflow_call:
inputs:
package-name:
required: true
type: string
tag:
required: false
type: string
env:
REGISTRY: ghcr.io
FULL_REF: ${{ inputs.tag && format('refs/tags/{0}', inputs.tag) || github.ref }}
# This must match the entry in rust-toolchain.toml at the repository root
RUSTUP_TOOLCHAIN: "1.83.0"
jobs:
upload-binaries:
if: startsWith(github.ref, format('refs/tags/{0}-v', inputs.package-name)) || !inputs.tag && github.event_name == 'workflow_dispatch' || startsWith(inputs.tag, inputs.package-name)
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: depot-ubuntu-24.04-4
build-tool: cargo
platform: linux-x86_64
- target: aarch64-apple-darwin
os: macos-latest
build-tool: cargo
platform: darwin-arm64
- target: x86_64-apple-darwin
os: macos-latest
build-tool: cargo
platform: darwin-x86_64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUSTUP_TOOLCHAIN }}
- uses: arduino/setup-protoc@v3
with:
version: "24.4"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from tag
id: version
shell: bash
run: |
TAG_NAME="${{ inputs.tag || github.ref_name }}"
# Remove the component prefix and 'v' (e.g., "sequencer-relayer-v1.0.3" -> "1.0.3")
VERSION=$(echo "$TAG_NAME" | sed 's/.*-v//')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
- uses: taiki-e/upload-rust-binary-action@v1
with:
ref: ${{ env.FULL_REF }}
bin: astria-${{ inputs.package-name }}
# Custom archive name: astria-composer-1.0.5-darwin-arm64.tar.gz
archive: astria-${{ inputs.package-name }}-${{ steps.version.outputs.version }}-${{ matrix.platform }}
dry-run: ${{ !startsWith(env.FULL_REF, format('refs/tags/{0}-v', inputs.package-name)) }}
# (optional) Target triple, default is host triple.
target: ${{ matrix.target }}
# (optional) Tool to build binaries (cargo, cross, or cargo-zigbuild)
build-tool: ${{ matrix.build-tool }}
# (required) GitHub token for uploading assets to GitHub Releases.
token: ${{ secrets.GITHUB_TOKEN }}