forked from indygreg/PyOxidizer
-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (149 loc) · 5.21 KB
/
build-exe.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
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
name: Build a binary
on:
workflow_call:
inputs:
bin:
description: Name of binary to build
required: true
type: string
extra_build_args_linux:
description: Extra argumnets to pass to `cargo build` on Linux
required: false
type: string
extra_build_args_macos:
description: Extra arguments to pass to `cargo build` on Windows
required: false
type: string
extra_build_args_windows:
description: Extra arguments to pass to `cargo build` on macOS
required: false
type: string
secrets:
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
jobs:
build:
strategy:
fail-fast: false
matrix:
target:
- os: 'ubuntu-22.04'
triple: 'aarch64-unknown-linux-musl'
cross: true
- os: 'ubuntu-22.04'
triple: 'x86_64-unknown-linux-musl'
- os: 'macos-12'
triple: 'aarch64-apple-darwin'
- os: 'macos-12'
triple: 'x86_64-apple-darwin'
- os: 'windows-2022'
triple: 'i686-pc-windows-msvc'
- os: 'windows-2022'
triple: 'x86_64-pc-windows-msvc'
runs-on: ${{ matrix.target.os }}
env:
IN_CI: '1'
AWS_REGION: us-west-2
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SCCACHE_BUCKET: 'pyoxidizer-sccache'
SCCACHE_S3_USE_SSL: '1'
# Prevent sccache server from stopping due to inactivity.
SCCACHE_IDLE_TIMEOUT: '0'
RUSTC_WRAPPER: sccache
CARGO_INCREMENTAL: '0'
# PYOXIDIZER_BUILD_FORCE_GIT_SOURCE is set to prevent pyoxidizer's build.rs from
# writing the filesystem path to the Git checkout in the built binary. With the
# filesystem path embedded in the binary, pyoxidizer will probe for that path
# at run-time and will attempt to use it for the location of the pyembed crate.
# With the filesystem path not set, pyoxidizer will use the canonical github.com
# repository for any Git references.
PYOXIDIZER_BUILD_FORCE_GIT_SOURCE: '1'
# This forces the lzma-sys crate to link liblzma statically. Ideally we'd do
# this with a crate feature. But the xz2 crate didn't expose that feature at the
# time this workaround was introduced.
LZMA_API_STATIC: '1'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/rust-bootstrap
with:
rust_toolchain: stable
rust_target: ${{ matrix.target.triple }}
- uses: actions-rs/[email protected]
if: matrix.target.cross
with:
crate: cross
version: latest
- name: Build
shell: bash
run: |
if [ "${{ matrix.target.triple }}" = "aarch64-apple-darwin" ]; then
export MACOSX_DEPLOYMENT_TARGET=11.0
elif [ "${{ matrix.target.triple }}" = "x86_64-apple-darwin" ]; then
export MACOSX_DEPLOYMENT_TARGET=10.9
fi
if [ -n "${{ matrix.target.cross }}" ]; then
CARGO=cross
else
CARGO=cargo
fi
case "${{ matrix.target.triple }}" in
*linux*)
EXTRA_BUILD_ARGS=${{ inputs.extra_build_args_linux }}
;;
*apple-darwin*)
EXTRA_BUILD_ARGS=${{ inputs.extra_build_args_macos }}
;;
*windows*)
EXTRA_BUILD_ARGS=${{ inputs.extra_build_args_windows }}
;;
*)
;;
esac
$CARGO build --release --bin ${{ inputs.bin }} --target ${{ matrix.target.triple }} ${EXTRA_BUILD_ARGS}
mkdir upload
cp target/${{ matrix.target.triple }}/release/${{ inputs.bin }}* upload/
sccache --stop-server
- name: Upload (non-Windows)
if: runner.os != 'Windows'
uses: actions/upload-artifact@v3
with:
name: exe-${{ inputs.bin }}-${{ matrix.target.triple }}
path: upload/${{ inputs.bin }}
- name: Upload (Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v3
with:
name: exe-${{ inputs.bin }}-${{ matrix.target.triple }}
path: upload/${{ inputs.bin }}.exe
macos-universal:
needs:
- build
runs-on: 'macos-12'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/install-just
- name: Download aarch64 executable
uses: actions/download-artifact@v3
with:
name: exe-${{ inputs.bin }}-aarch64-apple-darwin
path: ${{ inputs.bin }}-aarch64
- name: Download x86-64 executable
uses: actions/download-artifact@v3
with:
name: exe-${{ inputs.bin }}-x86_64-apple-darwin
path: ${{ inputs.bin }}-x86-64
- name: Produce Universal Binary
run: |
just actions-macos-universal ${{ inputs.bin }}
- name: Upload Universal Executable
uses: actions/upload-artifact@v3
with:
name: exe-${{ inputs.bin }}-macos-universal
path: uploads/${{ inputs.bin }}