-
Notifications
You must be signed in to change notification settings - Fork 1
177 lines (158 loc) · 5.02 KB
/
release.yml
File metadata and controls
177 lines (158 loc) · 5.02 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Release Build
# Runs when a GitHub Release is published (you create the release for an existing tag, or
# create tag + release together in the UI). Assets are built and attached to that release.
# Optional: workflow_dispatch with a tag for manual builds (creates/updates release assets).
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: "Existing git tag to build (e.g. v1.0.0)"
required: true
type: string
permissions:
contents: write
packages: write
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
metadata:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.meta.outputs.tag }}
version: ${{ steps.meta.outputs.version }}
steps:
- id: meta
run: |
if [ "${{ github.event_name }}" = "release" ]; then
TAG="${{ github.event.release.tag_name }}"
else
TAG="${{ github.event.inputs.tag }}"
fi
if [[ ! "$TAG" =~ ^v ]]; then
echo "::error::Tag must start with v (got: $TAG)"
exit 1
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
build-linux:
needs: metadata
runs-on: blacksmith-2vcpu-ubuntu-2204
container:
image: ubuntu:latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.metadata.outputs.tag }}
- name: Install build dependencies
run: |
apt-get update
apt-get install -y \
build-essential \
curl \
numactl \
pciutils \
ethtool \
dmidecode \
ipmitool \
pkg-config \
libssl-dev
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
target: x86_64-unknown-linux-gnu
- name: Build Release Binary
run: |
cargo build --release --target x86_64-unknown-linux-gnu
mkdir -p build/release
cp target/x86_64-unknown-linux-gnu/release/hardware_report build/release/hardware_report-linux-x86_64
strip build/release/hardware_report-linux-x86_64
- name: Create tarball
run: |
VERSION="${{ needs.metadata.outputs.version }}"
cd build/release
tar czf "hardware_report-linux-x86_64-${VERSION}.tar.gz" hardware_report-linux-x86_64
sha256sum "hardware_report-linux-x86_64-${VERSION}.tar.gz" > "hardware_report-linux-x86_64-${VERSION}.tar.gz.sha256"
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: linux-release
path: |
build/release/*.tar.gz
build/release/*.sha256
build-linux-arm64:
needs: metadata
runs-on: blacksmith-2vcpu-ubuntu-2204-arm
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.metadata.outputs.tag }}
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
curl \
numactl \
pciutils \
ethtool \
dmidecode \
ipmitool \
pkg-config \
libssl-dev
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Build release binary
run: |
cargo build --release
mkdir -p build/release
cp target/release/hardware_report build/release/hardware_report-linux-aarch64
strip build/release/hardware_report-linux-aarch64
- name: Create tarball
run: |
VERSION="${{ needs.metadata.outputs.version }}"
cd build/release
tar czf "hardware_report-linux-aarch64-${VERSION}.tar.gz" hardware_report-linux-aarch64
sha256sum "hardware_report-linux-aarch64-${VERSION}.tar.gz" > "hardware_report-linux-aarch64-${VERSION}.tar.gz.sha256"
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: linux-arm64-release
path: |
build/release/*.tar.gz
build/release/*.sha256
attach-assets:
needs:
- metadata
- build-linux
- build-linux-arm64
runs-on: ubuntu-latest
steps:
- name: Download Linux x86_64 artifacts
uses: actions/download-artifact@v4
with:
name: linux-release
path: dist
- name: Download Linux arm64 artifacts
uses: actions/download-artifact@v4
with:
name: linux-arm64-release
path: dist
- name: Upload release assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.metadata.outputs.tag }}
working_directory: dist
fail_on_unmatched_files: true
files: |
*.tar.gz
*.tar.gz.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}