-
Notifications
You must be signed in to change notification settings - Fork 1
104 lines (85 loc) · 3.54 KB
/
prebuilds.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
name: Generate prebuilds
on:
push:
branches: [main]
tags:
- "*"
env:
NODE_VERSION: 18
# (OPTIONAL) Only needed if the module does not use N-API
# Needs to match to the corresponding Node version used by NodeJS Mobile
# NodeJS Mobile runtime version: https://github.com/nodejs-mobile/nodejs-mobile/blob/main/src/node_mobile_version.h
# ABI mapping reference: https://github.com/nodejs-mobile/nodejs-mobile/blob/main/doc/abi_version_registry.json
# NODE_ABI: 108
MODULE_NAME: "" # Update this line with the name of the module as published on npm
MODULE_VERSION: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || '' }}
jobs:
build:
runs-on: ubuntu-20.04
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
target: ["android-arm", "android-arm64", "android-x64"]
steps:
# You can remove this step if you've updated env.MODULE_NAME above!
- name: Assert env.MODULE_NAME is set
if: ${{ env.MODULE_NAME == '' }}
run: echo "env.MODULE_NAME must be set" && exit 1
- name: Assert env.MODULE_VERSION is set
if: ${{ env.MODULE_VERSION == '' }}
run: echo "env.MODULE_VERSION must be set" && exit 1
- uses: actions/checkout@v4
- name: Setup NDK
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r24 # https://github.com/android/ndk/wiki/Unsupported-Downloads#r24
add-to-path: false
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Download npm package and unpack
run: npm pack ${{ env.MODULE_NAME }}@${{ env.MODULE_VERSION }} | xargs tar -zxvf
- name: Install deps for package
working-directory: ./package
run: npm install
- name: Generate prebuild for ${{ matrix.target }}
working-directory: ./package
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
run: npx --yes [email protected] ${{ matrix.target }} --verbose
- name: Upload original prebuild artifacts # mostly for debugging purposes
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}
path: ./package/prebuilds/${{ matrix.target }}
### The below steps are needed for the release job
- name: Derive release artifact name
id: artifact-name
# If you need the node abi version included, add something like node-${{ env.NODE_ABI }} in the string
run: echo "NAME=${{ env.MODULE_NAME }}-${{ env.MODULE_VERSION }}-${{ matrix.TARGET }}" >> "$GITHUB_OUTPUT"
- name: Prepare release artifact
run: tar -czf ${{ steps.artifact-name.outputs.NAME }}.tar.gz --directory=./package/prebuilds/${{ matrix.TARGET }} .
- name: Upload release artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.artifact-name.outputs.NAME }}
path: ./${{ steps.artifact-name.outputs.NAME }}.tar.gz
release:
if: ${{ startsWith(github.ref, 'refs/tags') }}
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
artifacts: "${{ env.MODULE_NAME }}-${{ env.MODULE_VERSION }}-*/*.tar.gz"
artifactErrorsFailBuild: true
allowUpdates: true
replacesArtifacts: true