Skip to content

Commit e2237fe

Browse files
committed
fix: fix builds for bare-make
1 parent 8efb015 commit e2237fe

File tree

3 files changed

+63
-96
lines changed

3 files changed

+63
-96
lines changed

.github/workflows/prebuilds.yml

Lines changed: 24 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,35 @@
11
name: Generate prebuilds
22

33
on:
4-
push:
5-
branches: [main]
6-
tags:
7-
- "*"
8-
9-
env:
10-
NODE_VERSION: 18
11-
MODULE_NAME: "fs-native-extensions"
12-
MODULE_VERSION: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'latest' }}
4+
workflow_dispatch:
5+
inputs:
6+
module_version:
7+
description: "Module version"
8+
required: true
9+
default: "latest"
10+
type: string
11+
publish_release:
12+
description: "Publish release"
13+
required: false
14+
default: true
15+
type: boolean
1316

1417
jobs:
1518
build:
16-
runs-on: ubuntu-20.04
17-
timeout-minutes: 10
1819
strategy:
19-
fail-fast: false
2020
matrix:
21-
target: ["android-arm", "android-arm64", "android-x64"]
22-
23-
steps:
24-
- name: Assert env.MODULE_VERSION is set
25-
if: ${{ env.MODULE_VERSION == '' }}
26-
run: echo "env.MODULE_VERSION must be set" && exit 1
27-
28-
- uses: actions/checkout@v4
29-
30-
- name: Setup NDK
31-
uses: nttld/setup-ndk@v1
32-
id: setup-ndk
33-
with:
34-
ndk-version: r24 # https://github.com/android/ndk/wiki/Unsupported-Downloads#r24
35-
add-to-path: false
36-
37-
- name: Use Node.js ${{ env.NODE_VERSION }}
38-
uses: actions/setup-node@v3
39-
with:
40-
node-version: ${{ env.NODE_VERSION }}
41-
42-
- name: Download npm package and unpack
43-
run: npm pack ${{ env.MODULE_NAME }}@${{ env.MODULE_VERSION }} | xargs tar -zxvf
44-
45-
- name: Install deps for package
46-
working-directory: ./package
47-
run: npm install
48-
49-
- name: Generate prebuild for ${{ matrix.target }}
50-
working-directory: ./package
51-
env:
52-
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
53-
run: npx --yes [email protected] ${{ matrix.target }} --verbose
54-
55-
- name: Upload original prebuild artifacts # mostly for debugging purposes
56-
uses: actions/upload-artifact@v3
57-
with:
58-
name: ${{ matrix.target }}
59-
path: ./package/prebuilds/${{ matrix.target }}
60-
61-
# The below steps are needed for the release job
62-
63-
- name: Derive release artifact name
64-
id: artifact-name
65-
run: echo "NAME=${{ env.MODULE_NAME }}-${{ env.MODULE_VERSION }}-${{ matrix.TARGET }}" >> "$GITHUB_OUTPUT"
66-
67-
- name: Prepare release artifact
68-
run: tar -czf ${{ steps.artifact-name.outputs.NAME }}.tar.gz --directory=./package/prebuilds/${{ matrix.TARGET }} .
69-
70-
- name: Upload release artifact
71-
uses: actions/upload-artifact@v3
72-
with:
73-
name: ${{ steps.artifact-name.outputs.NAME }}
74-
path: ./${{ steps.artifact-name.outputs.NAME }}.tar.gz
21+
platform: [android]
22+
arch: [arm64, x64, arm]
23+
uses: digidem/nodejs-mobile-bare-prebuilds/.github/workflows/prebuild.yml@main
24+
with:
25+
module_name: "fs-native-extensions"
26+
module_version: ${{ inputs.module_version }}
27+
platform: ${{ matrix.platform }}
28+
arch: ${{ matrix.arch }}
7529

7630
release:
77-
if: ${{ startsWith(github.ref, 'refs/tags') }}
31+
if: ${{ inputs.publish_release }}
7832
needs: build
79-
runs-on: ubuntu-latest
80-
timeout-minutes: 10
81-
steps:
82-
- uses: actions/checkout@v4
83-
84-
- name: Download artifacts
85-
uses: actions/download-artifact@v3
86-
87-
- name: Create GitHub Release
88-
uses: ncipollo/release-action@v1
89-
with:
90-
artifacts: "${{ env.MODULE_NAME }}-${{ env.MODULE_VERSION }}-*/*.tar.gz"
91-
artifactErrorsFailBuild: true
92-
allowUpdates: true
93-
replacesArtifacts: true
33+
uses: digidem/nodejs-mobile-bare-prebuilds/.github/workflows/release.yml@main
34+
with:
35+
module_version: ${{ needs.build.outputs.module_version }}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Digital Democracy
3+
Copyright (c) 2024 Awana Digital
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,55 @@
11
# fs-native-extensions-nodejs-mobile
22

3-
[NodeJS Mobile](https://github.com/nodejs-mobile/nodejs-mobile) prebuilds for [`fs-native-extensions`](https://github.com/holepunchto/fs-native-extensions).
3+
[NodeJS Mobile](https://github.com/nodejs-mobile/nodejs-mobile) prebuilds for [`fs-native-extensions`](https://github.com/holepunchto/fs-native-extensions)
44

55
## Working locally
66

77
### Requirements
88

99
- Node 18
10-
- Android NDK 24.0.8215888
11-
- (optional) exported `ANDROID_NDK_PATH` environment variable
10+
- Android NDK (CI uses version 27.2.12479018)
11+
- (optional) exported `ANDROID_NDK_HOME` environment variable
1212

1313
### General steps
1414

15-
Should be clear enough to follow the workflow steps but in summary:
16-
17-
1. Download the npm tarball package and unzip e.g. `npm pack fs-native-extensions@latest | xargs tar -zxvf`
18-
19-
2. Navigate to unzipped directory and run `npx prebuild-for-nodejs-mobile TARGET`, where `TARGET` is an accepted value from the [`prebuild-for-nodejs-mobile`](https://github.com/staltz/prebuild-for-nodejs-mobile) CLI
20-
- if you don't have the `ANDROID_NDK_PATH` environment variable exported, you may run the command like so: `ANDROID_NDK_HOME=/path/to/ndk npx prebuild-for-nodejs-mobile TARGET`
15+
Should be clear enough to follow the [reusable workflow steps](https://github.com/digidem/nodejs-mobile-bare-prebuilds/blob/main/.github/workflows/prebuild.yml) but in summary:
16+
17+
1. Download the npm tarball package and unzip e.g.
18+
```
19+
npm pack fs-native-extensions@latest | xargs tar -zxvf
20+
```
21+
2. Navigate to unzipped directory:
22+
```
23+
cd package
24+
```
25+
3. Install dependencies:
26+
```
27+
npm install
28+
```
29+
4. Install [patched `cmake-napi`](https://github.com/digidem/cmake-napi-nodejs-mobile):
30+
```
31+
npm install cmake-napi@github:digidem/cmake-napi-nodejs-mobile
32+
```
33+
5. Install [bare-make](https://github.com/holepunchto/bare-make) globally:
34+
```
35+
npm install -g bare-make@latest
36+
```
37+
6. Generate, build and install:
38+
```
39+
bare-make generate --platform android --arch arm64
40+
bare-make build
41+
bare-make install
42+
```
2143
2244
## Creating a release
2345
24-
1. Create a git tag that matches the version of the module you want to create prebuilds for e.g. `git tag 1.0.0`
46+
1. Navigate to the [Generate Prebuilds workflow](https://github.com/digidem/fs-native-extensions-nodejs-mobile/actions/workflows/prebuilds.yml)
47+
2. Manually dispatch the worflow with the version you want to build, ensuring that "Publish Release" is checked.
48+
49+
## Contributing
2550
26-
2. Push the tag to the remote e.g. `git push origin 1.0.0`
51+
We welcome contributions to this repository. If you have an idea for a new feature or have found a bug, please open an issue or submit a pull request.
2752
28-
3. The workflow uses the tag version to create the prebuilds and then publish a release with those prebuilds.
53+
## License
2954
30-
4. The relevant artifacts will show up in GitHub Releases. Each artifact is a tarball containing the `.node` files for the target-specific prebuild.
55+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.

0 commit comments

Comments
 (0)