Repository navigation
141 lines (126 loc) · 4.85 KB
/
Copy pathplatform.yml
File metadata and controls
141 lines (126 loc) · 4.85 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
# Single platform matrix. Callers cannot invent a second copy.
#
# with.mode: rehearsal — fixture binary, stage + bundle (PR)
# with.mode: release — cargo build, stage, bundle, upload (master)
name: Platform
on:
workflow_call:
inputs:
mode:
description: rehearsal or release
required: true
type: string
permissions: {}
jobs:
platform:
name: ${{ inputs.mode }} · ${{ matrix.suffix }}
runs-on: ${{ matrix.runner }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
suffix: linux-x64
runner: ubuntu-latest
bin: comment-checker
- target: aarch64-unknown-linux-gnu
suffix: linux-arm64
runner: ubuntu-24.04-arm
bin: comment-checker
- target: x86_64-pc-windows-msvc
suffix: win32-x64
runner: windows-2022
bin: comment-checker.exe
steps:
- name: Reject unknown mode
shell: bash
run: |
case "${{ inputs.mode }}" in
rehearsal|release) exit 0 ;;
*)
echo "platform.yml: mode must be rehearsal or release, got '${{ inputs.mode }}'" >&2
exit 1
;;
esac
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions-rust-lang/setup-rust-toolchain@c8ff772090ab9d00f7f7bd7b388f3c3032282e3b # v1
if: inputs.mode == 'release'
with:
toolchain: stable
target: ${{ matrix.target }}
- name: Linux arm64 cross-linker
if: >-
inputs.mode == 'release'
&& matrix.target == 'aarch64-unknown-linux-gnu'
&& matrix.runner == 'ubuntu-latest'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
{
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc"
echo "AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar"
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc"
} >> "$GITHUB_ENV"
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
if: inputs.mode == 'release'
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('Cargo.lock') }}
- name: Build release binary
if: inputs.mode == 'release'
run: cargo build --release --target ${{ matrix.target }}
- uses: denoland/setup-deno@22d081ff2d3a40755e97629de92e3bcbfa7cf2ed # v2
- name: Fixture binary
if: inputs.mode == 'rehearsal'
shell: bash
run: |
mkdir -p "target/${{ matrix.target }}/release"
printf '%s\n' fixture > "target/${{ matrix.target }}/release/${{ matrix.bin }}"
- name: Stage platform package
shell: bash
run: |
./scripts/tools/stage-platform-package.ts \
--target ${{ matrix.target }} \
--suffix ${{ matrix.suffix }} \
--stage dist/staging/platform-${{ matrix.suffix }} \
--bin-dir target/${{ matrix.target }}/release
- name: Bundle tarball
shell: bash
run: |
./scripts/tools/bundle-release-tarball.ts \
--target ${{ matrix.target }} \
--bin-dir target/${{ matrix.target }}/release \
--out-dir dist/release-tarball-${{ matrix.suffix }}
- name: Verify this runner produced its outputs
shell: bash
run: |
set -euo pipefail
for f in \
"dist/staging/platform-${{ matrix.suffix }}/package.json" \
"dist/staging/platform-${{ matrix.suffix }}/binarySha256" \
"dist/release-tarball-${{ matrix.suffix }}/comment-checker-${{ matrix.target }}.tar.gz"; do
test -s "$f" || { echo "missing or empty: $f" >&2; exit 1; }
echo "ok $f"
done
tar -tzf "dist/release-tarball-${{ matrix.suffix }}/comment-checker-${{ matrix.target }}.tar.gz" \
| grep -Fx "${{ matrix.bin }}"
- name: Upload artifacts
if: inputs.mode == 'release'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: release-${{ matrix.suffix }}
path: dist/release-tarball-${{ matrix.suffix }}/comment-checker-${{ matrix.target }}.tar.gz
if-no-files-found: error
- name: Upload staged platform package
if: inputs.mode == 'release'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: platform-stage-${{ matrix.suffix }}
path: dist/staging/platform-${{ matrix.suffix }}
if-no-files-found: error