Skip to content

Commit

Permalink
fix: update builds to use bare-make
Browse files Browse the repository at this point in the history
  • Loading branch information
gmaclennan committed Dec 18, 2024
1 parent 2614634 commit 1c8d55d
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 96 deletions.
106 changes: 24 additions & 82 deletions .github/workflows/prebuilds.yml
Original file line number Diff line number Diff line change
@@ -1,93 +1,35 @@
name: Generate prebuilds

on:
push:
branches: [main]
tags:
- "*"

env:
NODE_VERSION: 18
MODULE_NAME: "simdle-native"
MODULE_VERSION: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'latest' }}
workflow_dispatch:
inputs:
module_version:
description: "Module version"
required: true
default: "latest"
type: string
publish_release:
description: "Publish release"
required: false
default: true
type: boolean

jobs:
build:
runs-on: ubuntu-20.04
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
target: ["android-arm", "android-arm64", "android-x64"]

steps:
- 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
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
platform: [android]
arch: [arm64, x64, arm]
uses: digidem/nodejs-mobile-bare-prebuilds/.github/workflows/prebuild.yml@main
with:
module_name: "simdle-native"
module_version: ${{ inputs.module_version }}
platform: ${{ matrix.platform }}
arch: ${{ matrix.arch }}

release:
if: ${{ startsWith(github.ref, 'refs/tags') }}
if: ${{ inputs.publish_release }}
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
uses: digidem/nodejs-mobile-bare-prebuilds/.github/workflows/release.yml@main
with:
module_version: ${{ needs.build.outputs.module_version }}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Digital Democracy
Copyright (c) 2024 Awana Digital

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
51 changes: 38 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,55 @@
# simdle-native-nodejs-mobile

[NodeJS Mobile](https://github.com/nodejs-mobile/nodejs-mobile) prebuilds for [`simdle-native`](https://github.com/holepunchto/simdle-native).
[NodeJS Mobile](https://github.com/nodejs-mobile/nodejs-mobile) prebuilds for [`simdle-native`](https://github.com/holepunchto/simdle-native)

## Working locally

### Requirements

- Node 18
- Android NDK 24.0.8215888
- (optional) exported `ANDROID_NDK_PATH` environment variable
- Android NDK (CI uses version 27.2.12479018)
- (optional) exported `ANDROID_NDK_HOME` environment variable

### General steps

Should be clear enough to follow the workflow steps but in summary:

1. Download the npm tarball package and unzip e.g. `npm pack simdle-native@latest | xargs tar -zxvf`

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
- 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`
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:

1. Download the npm tarball package and unzip e.g.
```
npm pack simdle-native@latest | xargs tar -zxvf
```
2. Navigate to unzipped directory:
```
cd package
```
3. Install dependencies:
```
npm install
```
4. Install [patched `cmake-napi`](https://github.com/digidem/cmake-napi-nodejs-mobile):
```
npm install cmake-napi@github:digidem/cmake-napi-nodejs-mobile
```
5. Install [bare-make](https://github.com/holepunchto/bare-make) globally:
```
npm install -g bare-make@latest
```
6. Generate, build and install:
```
bare-make generate --platform android --arch arm64
bare-make build
bare-make install
```
## Creating a release
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`
1. Navigate to the [Generate Prebuilds workflow](https://github.com/digidem/simdle-native-nodejs-mobile/actions/workflows/prebuilds.yml)
2. Manually dispatch the worflow with the version you want to build, ensuring that "Publish Release" is checked.
## Contributing
2. Push the tag to the remote e.g. `git push origin 1.0.0`
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.
3. The workflow uses the tag version to create the prebuilds and then publish a release with those prebuilds.
## License
4. The relevant artifacts will show up in GitHub Releases. Each artifact is a tarball containing the `.node` files for the target-specific prebuild.
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.

0 comments on commit 1c8d55d

Please sign in to comment.