-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (150 loc) · 4.54 KB
/
release-native.yml
File metadata and controls
156 lines (150 loc) · 4.54 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Release Native Binaries
on:
workflow_dispatch:
inputs:
force_rebuild:
description: Force rebuild and overwrite existing release
required: false
default: false
type: boolean
workflow_call:
permissions:
contents: write
env:
LUA_VERSION: 5.4.8
jobs:
native_info:
name: Get Native Info
runs-on: ubuntu-22.04
outputs:
native_version: ${{ steps.read_package.outputs.native_version }}
should_build: ${{ steps.set_should_build.outputs.result }}
steps:
- uses: actions/checkout@v4
- name: Read package.json
id: read_package
run: |
echo "native_version=$(jq -r '.nativeVersion' package.json)" >> $GITHUB_OUTPUT
- name: Check Release Exists
id: release_exists
uses: actions/github-script@v8
env:
NATIVE_VERSION: ${{ steps.read_package.outputs.native_version }}
with:
result-encoding: string
script: |
try {
const tag = `native-v${process.env.NATIVE_VERSION}`;
const release = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag
});
return true;
} catch (error) {
return false;
}
- name: Decide if should build
id: set_should_build
run: |
if [ "${{ inputs.force_rebuild }}" = "true" ]; then
echo "result=true" >> $GITHUB_OUTPUT
elif [ "${{ steps.release_exists.outputs.result }}" = "false" ]; then
echo "result=true" >> $GITHUB_OUTPUT
else
echo "result=false" >> $GITHUB_OUTPUT
fi
build_binaries:
name: Build Native Binaries
runs-on: ${{ matrix.os }}
needs: native_info
if: needs.native_info.outputs.should_build == 'true'
strategy:
fail-fast: true
matrix:
include:
- os: ubuntu-22.04
shell: bash
setup: |
sudo apt update
sudo apt install -y make g++ gcc python3
- os: ubuntu-22.04-arm
shell: bash
setup: |
sudo apt update
sudo apt install -y make g++ gcc python3
- os: ubuntu-22.04
image: node:24.10.0-alpine3.22
shell: sh
setup: |
apk add --no-cache make g++ python3
- os: macos-15
shell: bash
setup: |
brew install python3
- os: windows-2025
shell: bash
setup: |
choco install python3 --no-progress
defaults:
run:
shell: ${{ matrix.shell }}
container:
image: ${{ matrix.image }}
steps:
- name: Setup
run: ${{ matrix.setup }}
- uses: actions/checkout@v4
- name: Install Nodejs
uses: actions/setup-node@v6
if: ${{ ! matrix.image }}
with:
node-version: 24.10.0
- name: Build
env:
LUA_STATE_MODE: download
LUA_STATE_FORCE_BUILD: true
run: |
npm ci
- name: Test
run: |
npm run test
- name: Bench
run: |
npm run bench
- name: Set Binary Name
run: |
echo "BINARY_NAME=$(node build-tools/config.js --native-release-name)" >> $GITHUB_ENV
- name: Archive Binary
run: |
mkdir -p prebuilds
tar -czf prebuilds/$BINARY_NAME -C build/Release lua-state.node
- name: Upload Binary Artifact
uses: actions/upload-artifact@v5
with:
name: ${{ env.BINARY_NAME }}
path: prebuilds
if-no-files-found: error
retention-days: 1
upload_release:
name: Upload Release
runs-on: ubuntu-22.04
needs:
- native_info
- build_binaries
if: needs.native_info.outputs.should_build == 'true' && needs.build_binaries.result == 'success'
steps:
- name: Download All Built Artifacts
uses: actions/download-artifact@v4
with:
path: prebuilds
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: prebuilds/**/*.tar.gz
tag_name: native-v${{ needs.native_info.outputs.native_version }}
name: "lua-state-native-v${{ needs.native_info.outputs.native_version }}-lua-v${{ env.LUA_VERSION }}"
generate_release_notes: true
overwrite_files: true
fail_on_unmatched_files: true
prerelease: true