-
Notifications
You must be signed in to change notification settings - Fork 2
214 lines (210 loc) · 6.8 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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
name: Build
on:
workflow_call:
inputs:
ref:
description: 'The branch, tag, or SHA to check out'
required: true
type: string
update-version:
description: 'Update version before building?'
required: false
type: boolean
default: false
version:
description: 'Version update (ignored if update-version if false)'
required: false
type: string
default: 'patch'
github-release:
description: 'Publish GitHub release?'
required: false
type: boolean
default: false
tag:
description: 'The release tag (ignored if github-release is false)'
required: false
type: string
default: ''
jobs:
matrix:
name: Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.result }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
- name: Setup Neon Environment
uses: ./.github/actions/setup-neon
with:
use-rust: false
- name: Install Dependencies
shell: bash
run: npm ci
- name: Install cargo-messages
shell: bash
run: npm ci
working-directory: ./pkgs/cargo-messages
- name: Look Up Matrix Data
id: matrixData
shell: bash
run: |
echo "json=$(node ../../dist/cli show ci github | jq -rc)" >> "$GITHUB_OUTPUT"
working-directory: ./pkgs/cargo-messages
- name: Compute Matrix
id: matrix
uses: actions/github-script@v7
with:
script: |
const platforms = ${{ steps.matrixData.outputs.json }};
const macOS = platforms.macOS.map(platform => {
return { os: "macos-latest", platform, script: "build" };
});
const windows = platforms.Windows.map(platform => {
return { os: "windows-latest", platform, script: "build" };
});
const linux = platforms.Linux.map(platform => {
return { os: "ubuntu-latest", platform, script: "cross" };
});
return [...macOS, ...windows, ...linux];
binaries:
name: Binaries
needs: [matrix]
strategy:
matrix:
cfg: ${{ fromJSON(needs.matrix.outputs.matrix) }}
runs-on: ${{ matrix.cfg.os }}
permissions:
contents: write
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
- name: Setup Neon Environment
id: neon
uses: ./.github/actions/setup-neon
with:
use-cross: ${{ matrix.cfg.script == 'cross' }}
platform: ${{ matrix.cfg.platform }}
workspace: ./pkgs/cargo-messages
- name: Diagnostics
shell: bash
run: git log -10
- name: Diagnostics Before Installing Dependencies
shell: bash
run: |
for d in `find . -name @cargo-messages -type d`; do
echo "*** $d:"
ls $d
echo '***'
done
- name: Install Dependencies
shell: bash
run: npm ci
- name: Diagnostics After Installing Dependencies
shell: bash
run: |
for d in `find . -name @cargo-messages -type d`; do
echo "*** $d:"
ls $d
echo '***'
done
- name: Update Version
if: ${{ inputs.update-version }}
shell: bash
run: |
git config --global user.name $ACTIONS_USER
git config --global user.email $ACTIONS_EMAIL
npm version ${{ inputs.version }} -m "v%s"
for d in `find . -name @cargo-messages -type d`; do
echo "*** $d:"
ls $d
echo '***'
done
- name: Check Versions
shell: bash
run: ./test/lint/check-versions.sh
- name: Diagnostics
shell: bash
run: |
echo steps.target.outputs.target=${{ steps.neon.outputs.target }}
echo matrix.cfg.platform=${{ matrix.cfg.platform }}
- name: Build
shell: bash
env:
CARGO_BUILD_TARGET: ${{ steps.neon.outputs.target }}
NEON_BUILD_PLATFORM: ${{ matrix.cfg.platform }}
RUSTFLAGS: ${{ (endsWith(matrix.cfg.platform, 'musl') && '-C target-feature=-crt-static') || '' }}
run: npm run ${{ matrix.cfg.script }}
working-directory: ./pkgs/cargo-messages
- name: Pack
id: pack
shell: bash
run: |
mkdir -p dist
echo filename=$(basename $(npm pack ./platforms/${{ matrix.cfg.platform }} --silent --pack-destination=./dist --json | jq -r '.[0].filename')) | tee -a $GITHUB_OUTPUT
working-directory: ./pkgs/cargo-messages
- name: Diagnostics
shell: bash
run: |
echo 'inputs.ref=${{ inputs.ref }}'
echo 'steps.build.outputs.filename=${{ steps.pack.outputs.filename }}'
ls -al ./pkgs/cargo-messages/platforms/${{ matrix.cfg.platform }}
ls -al ./pkgs/cargo-messages/dist/${{ steps.pack.outputs.filename }}
tar tvzf ./pkgs/cargo-messages/dist/${{ steps.pack.outputs.filename }}
find . -name neon-update.log
cat ./pkgs/cargo-messages/neon-update.log || true
- name: Release
if: ${{ inputs.github-release }}
uses: softprops/action-gh-release@v1
with:
files: ./pkgs/cargo-messages/dist/${{ steps.pack.outputs.filename }}
tag_name: ${{ inputs.tag }}
main:
name: Main
needs: [matrix]
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
- name: Diagnostics
shell: bash
run: |
echo 'inputs.ref=${{ inputs.ref }}'
echo 'inputs.tag=${{ inputs.tag }}'
echo "cargo-messages.version=$(jq -r '.version' < ./pkgs/cargo-messages/package.json)"
- name: Setup Neon Environment
uses: ./.github/actions/setup-neon
with:
use-rust: false
- name: Install Dependencies
shell: bash
run: npm ci
- name: Pack
id: pack
shell: bash
run: |
mkdir -p dist
ls -al
ls -al dist
echo "filename=$(npm pack --silent --pack-destination=./dist)" >> $GITHUB_OUTPUT
working-directory: ./pkgs/cargo-messages
- name: Diagnostics
shell: bash
run: |
jq -r .version < package.json
ls -al dist
cat neon-update.log
working-directory: ./pkgs/cargo-messages
- name: Release
if: ${{ inputs.github-release }}
uses: softprops/action-gh-release@v1
with:
files: ./pkgs/cargo-messages/dist/${{ steps.pack.outputs.filename }}
tag_name: ${{ inputs.tag }}