-
Notifications
You must be signed in to change notification settings - Fork 22
128 lines (116 loc) · 3.88 KB
/
build-artifacts.yml
File metadata and controls
128 lines (116 loc) · 3.88 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
name: Build Artifacts
on:
workflow_call:
inputs:
runner:
description: GitHub-hosted runner label
required: true
type: string
toolchain:
description: Rust toolchain channel to install
required: true
type: string
artifact_glob:
description: Glob pattern for build artifacts produced by build.sh
required: true
type: string
artifact_name:
description: Name to use when uploading artifacts
required: true
type: string
upload_artifact:
description: Whether to upload build artifacts
required: true
type: boolean
run_tests:
description: Run cargo test before building
required: false
type: boolean
default: false
allow_failure:
description: Treat build/test failures as non-fatal
required: false
type: boolean
default: false
rpm:
description: Generate an RPM artifact (Linux only)
required: false
type: boolean
default: false
release_version:
description: Release version to prepare with semantic-release-cargo
required: false
type: string
default: ""
fetch_depth:
description: Fetch depth for the checkout step
required: false
type: string
default: "0"
jobs:
build:
runs-on: ${{ inputs.runner }}
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: ${{ inputs.fetch_depth }}
- name: Setup Rust
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master
with:
toolchain: ${{ inputs.toolchain }}
- name: Rust Cache
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- name: Install musl toolchain
if: ${{ inputs.rpm }}
run: |
set -euxo pipefail
sudo apt-get update
sudo apt-get install -y musl-tools
rustup target add x86_64-unknown-linux-musl
echo "CARGO_BUILD_TARGET=x86_64-unknown-linux-musl" >> $GITHUB_ENV
- name: Run tests
if: ${{ inputs.run_tests }}
continue-on-error: ${{ inputs.allow_failure }}
run: cargo test --all-features
- name: Install cargo-get
run: cargo install --locked cargo-get
- name: Install semantic-release-cargo
if: ${{ inputs.release_version != '' }}
run: cargo install --locked semantic-release-cargo
- name: Install cargo-generate-rpm
if: ${{ inputs.rpm }}
run: cargo install --locked cargo-generate-rpm
- name: Prepare release version
if: ${{ inputs.release_version != '' }}
run: semantic-release-cargo prepare ${{ inputs.release_version }}
- name: Build artifacts
id: build
continue-on-error: ${{ inputs.allow_failure }}
run: ./build.sh
env:
RUNNER: ${{ inputs.runner }}
- name: Generate RPM
if: ${{ inputs.rpm && steps.build.outcome == 'success' }}
run: |
cargo generate-rpm --target ${CARGO_BUILD_TARGET}
- name: Collect archives
if: ${{ steps.build.outcome == 'success' }}
run: |
set -euxo pipefail
rm -rf dist
mkdir dist
mv ${{ inputs.artifact_glob }} dist/
- name: Collect RPM
if: ${{ inputs.rpm && steps.build.outcome == 'success' }}
run: |
set -euxo pipefail
find target/ -name "floki*.rpm" -exec cp -v "{}" dist/ \;
- name: Upload artifacts
if: ${{ inputs.upload_artifact && steps.build.outcome == 'success' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ${{ inputs.artifact_name }}
path: dist