Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
113 lines (103 loc) · 3.7 KB
/
Copy pathaction.yml
File metadata and controls
113 lines (103 loc) · 3.7 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
name: Set up cgo cross compilation
description: Installs the C cross compiler of a Go target of Nginx UI and sets CC, CXX and CGO_ENABLED.
author: nginxui
branding:
icon: cpu
color: blue
inputs:
goos:
description: GOOS of the target, linux, windows or darwin.
required: true
goarch:
description: GOARCH of the target.
required: true
goarm:
description: GOARM of a linux/arm target, 5, 6 or 7. Go's default 7 when empty.
required: false
default: ''
outputs:
cc:
description: The C compiler, also exported as CC.
value: ${{ steps.done.outputs.cc }}
cxx:
description: The C++ compiler, also exported as CXX.
value: ${{ steps.done.outputs.cxx }}
extldflags:
description: Flags for the external linker, -static on Linux, empty elsewhere. Pass them as -ldflags "-extldflags '...'".
value: ${{ steps.done.outputs.extldflags }}
triple:
description: The target triple of the toolchain.
value: ${{ steps.target.outputs.triple }}
runs:
using: composite
steps:
- id: target
shell: bash
env:
GOOS: ${{ inputs.goos }}
GOARCH: ${{ inputs.goarch }}
GOARM: ${{ inputs.goarm }}
run: '"${GITHUB_ACTION_PATH}/target.sh"'
# The musl toolchains come from GitHub release assets that answer 5xx at
# times, so the download is tried three times with a growing pause.
- id: musl
if: steps.target.outputs.kind == 'linux'
continue-on-error: true
uses: nginxui/musl-cross-compilers@8f83e180fec1779fd14f7aa9834d83525187a317 # v1
with:
target: ${{ steps.target.outputs.triple }}
variant: ${{ steps.target.outputs.variant }}
- if: steps.target.outputs.kind == 'linux' && steps.musl.outcome == 'failure'
shell: bash
run: sleep 30
- id: musl_retry1
if: steps.target.outputs.kind == 'linux' && steps.musl.outcome == 'failure'
continue-on-error: true
uses: nginxui/musl-cross-compilers@8f83e180fec1779fd14f7aa9834d83525187a317 # v1
with:
target: ${{ steps.target.outputs.triple }}
variant: ${{ steps.target.outputs.variant }}
- if: steps.target.outputs.kind == 'linux' && steps.musl_retry1.outcome == 'failure'
shell: bash
run: sleep 90
- id: musl_retry2
if: steps.target.outputs.kind == 'linux' && steps.musl_retry1.outcome == 'failure'
uses: nginxui/musl-cross-compilers@8f83e180fec1779fd14f7aa9834d83525187a317 # v1
with:
target: ${{ steps.target.outputs.triple }}
variant: ${{ steps.target.outputs.variant }}
- id: windows
if: steps.target.outputs.kind == 'windows'
shell: bash
env:
TRIPLE: ${{ steps.target.outputs.triple }}
run: '"${GITHUB_ACTION_PATH}/windows.sh"'
- id: done
shell: bash
env:
KIND: ${{ steps.target.outputs.kind }}
TRIPLE: ${{ steps.target.outputs.triple }}
MUSL_PATH: ${{ steps.musl.outputs.path || steps.musl_retry1.outputs.path || steps.musl_retry2.outputs.path }}
WINDOWS_CC: ${{ steps.windows.outputs.cc }}
WINDOWS_CXX: ${{ steps.windows.outputs.cxx }}
run: |
set -euo pipefail
extldflags=""
case "${KIND}" in
linux)
test -n "${MUSL_PATH}"
echo "${MUSL_PATH}" >> "${GITHUB_PATH}"
cc="${TRIPLE}-gcc" cxx="${TRIPLE}-g++" extldflags="-static" ;;
windows) cc="${WINDOWS_CC}" cxx="${WINDOWS_CXX}" ;;
darwin) cc=clang cxx=clang++ ;;
esac
{
echo "CC=${cc}"
echo "CXX=${cxx}"
echo "CGO_ENABLED=1"
} >> "${GITHUB_ENV}"
{
echo "cc=${cc}"
echo "cxx=${cxx}"
echo "extldflags=${extldflags}"
} >> "${GITHUB_OUTPUT}"