-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (134 loc) · 4.25 KB
/
build.yml
File metadata and controls
138 lines (134 loc) · 4.25 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
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 is 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@v4
with:
ref: ${{ inputs.ref }}
- name: Setup Neon Environment
uses: ./.github/actions/setup
with:
use-rust: false
- name: Look Up Matrix Data
id: matrixData
shell: bash
run: echo "json=$(npx neon show ci github | jq -rc)" | tee -a $GITHUB_OUTPUT
- 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@v4
with:
ref: ${{ inputs.ref }}
- name: Setup Neon Environment
id: neon
uses: ./.github/actions/setup
with:
use-cross: ${{ matrix.cfg.script == 'cross' }}
platform: ${{ matrix.cfg.platform }}
- 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"
- name: Build
shell: bash
env:
CARGO_BUILD_TARGET: ${{ steps.neon.outputs.target }}
NEON_BUILD_PLATFORM: ${{ matrix.cfg.platform }}
RUSTFLAGS: "-C target-feature=-crt-static"
run: npm run ${{ matrix.cfg.script }}
- 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
- name: Release
if: ${{ inputs.github-release }}
uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 # v2.0.4
with:
files: ./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@v4
with:
ref: ${{ inputs.ref }}
- name: Setup Neon Environment
uses: ./.github/actions/setup
with:
use-rust: false
- name: Pack
id: pack
shell: bash
run: |
mkdir -p dist
echo "filename=$(npm pack --silent --pack-destination=./dist)" | tee -a $GITHUB_OUTPUT
- name: Release
if: ${{ inputs.github-release }}
uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 # v2.0.4
with:
files: ./dist/${{ steps.pack.outputs.filename }}
tag_name: ${{ inputs.tag }}