-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (64 loc) · 1.98 KB
/
build.yml
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
name: build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_TERM_COLOR: always
on:
workflow_call:
inputs:
path:
default: 'Cargo.toml'
required: true
type: string
target:
default: 'x86_64-unknown-linux-gnu'
required: true
type: string
platform:
default: 'ubuntu-latest'
required: true
type: string
jobs:
ready:
uses: ./.github/workflows/parse-info.yml
with:
path: ${{ inputs.path }}
cross-build:
name: publish - ${{ inputs.target }}
runs-on: ${{ inputs.platform }}
needs:
- ready
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: 'true'
- name: Set LTO to true (Windows)
if: runner.os == 'Windows'
run: |
$fileContent = Get-Content ./Cargo.toml
$fileContent = $fileContent -replace 'lto = false', 'lto = true'
Set-Content ./Cargo.toml $fileContent
- name: Set LTO to true (Linux/macOS)
if: runner.os != 'Windows'
run: perl -pi -e 's/lto = false/lto = true/g' ./Cargo.toml
- uses: taiki-e/github-actions/install-rust@main
with:
toolchain: nightly
- name: Install cross-compilation tools
uses: taiki-e/[email protected]
with:
target: ${{ inputs.target }}
if: contains(inputs.target, 'linux-musl')
- run: echo "RUSTFLAGS=${RUSTFLAGS} -C target-feature=+crt-static" >> "${GITHUB_ENV}"
if: endsWith(inputs.target, 'windows-msvc')
- uses: taiki-e/[email protected]
with:
bin: ${{ needs.ready.outputs.name }}
target: ${{ inputs.target }}
ref: refs/tags/${{ needs.ready.outputs.version }}
tar: all
zip: windows
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 1
CARGO_PROFILE_RELEASE_LTO: true