Skip to content

Commit

Permalink
Release 0.1.1 and general upkeep (#13)
Browse files Browse the repository at this point in the history
1. Release 0.1.1 with nexe 4.0.0-beta.19 and node versions 12.21.0, 12.22.6, 14.16.0, 14.18.0, 16.11.0
2. Updated all Node package dependency versions.
3. Updated all GitHub Actions versions.
4. Fixed build bug of not creating `./RELEASE_ID` file for new release versions.
5. Added documentation on script calls.
  • Loading branch information
code-ape authored Oct 14, 2021
1 parent 552b275 commit e5bc120
Show file tree
Hide file tree
Showing 10 changed files with 2,298 additions and 114 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/nexe-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ jobs:
shell: bash
strategy:
matrix:
os: [ubuntu-18.04, windows-latest, macos-latest]
node_version: ['12.21.0', '14.16.0']
os: [ubuntu-latest, windows-latest, macos-latest]
node_version: ['12.21.0', '12.22.6', '14.16.0', '14.18.0', '16.11.0']

steps:
- uses: actions/checkout@v2
- name: Get node details via .npmrc
id: get_node_details
run: echo "::set-output name=version::$(cat .nvmrc)"
- name: Use Node.js from .nvmrc
uses: actions/setup-node@v2.1.5
uses: actions/setup-node@v2.4.1
with:
node-version: ${{ steps.get_node_details.outputs.version }}
- name: Declare caches for build
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: |
~/.ccache/
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/nexe-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ jobs:
shell: bash
strategy:
matrix:
os: [ubuntu-18.04, windows-latest, macos-latest]
node_version: ['12.21.0', '14.16.0']
os: [ubuntu-latest, windows-latest, macos-latest]
node_version: ['12.21.0', '12.22.6', '14.16.0', '14.18.0', '16.11.0']

steps:
- uses: actions/checkout@v2
- name: Get node details via .npmrc
id: get_node_details
run: echo "::set-output name=version::$(cat .nvmrc)"
- name: Use Node.js from .nvmrc
uses: actions/setup-node@v2.1.5
uses: actions/setup-node@v2.4.1
with:
node-version: ${{ steps.get_node_details.outputs.version }}
- name: Declare caches for build
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: |
~/.ccache/
Expand Down
52 changes: 49 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Nexe Builds

> Current version `0.1.0`. Current remote URL: `https://github.com/urbdyn/nexe_builds/releases/download/0.1.0/`
> Current version `0.1.1`. Current remote URL: `https://github.com/urbdyn/nexe_builds/releases/download/0.1.1/`
[Nexe] is a fantastic tool for turning Node.js applications into single binaries.
This repository provides automation to pre-build and distribute the node binaries, so you don't have to!


## How to Use

To use the pre-built binaries with nexe just add `--remote https://github.com/urbdyn/nexe_builds/releases/download/0.1.0/`
To use the pre-built binaries with nexe just add `--remote https://github.com/urbdyn/nexe_builds/releases/download/0.1.1/`

Script example:

```bash
# Install Nexe
npm install nexe
# Save remote URL as variable
NEXE_REMOTE="https://github.com/urbdyn/nexe_builds/releases/download/0.1.0/"
NEXE_REMOTE="https://github.com/urbdyn/nexe_builds/releases/download/0.1.1/"
# Do nexe build
npx nexe ./myScript.js --remote "$NEXE_REMOTE"
```
Expand All @@ -42,3 +42,49 @@ Urban Dynamics makes use of [Nexe](https://github.com/nexe/nexe) for a number of
It's a great tool but the pre-built binaries are becoming a bit stale compared to the Node.js release schedule.
So, we decided to open source our build automation which was creating and publishing prebuilt binaries.
Enjoy 🚀

## Build Call Flow

1. `bin/run_cd`: Gets the prior git commit, calls `bin/check_assets`, and then calls `bin/install_dependencies` plus `bin/build_nexe` if a build is needed.
1. Args: None
2. Environmental Variables:
1. `NODE_VERSION`: Version of Node.js to build for. [required]
2. `CREATE_RELEASE`: Whether to actually do the compilation or dry run. [optional]
3. Files created:
1. Those created by scripts invoked (see below).
4. Exit codes:
1. `0`: Success
2. `1`: `check_asset` script failed.
3. `2`: `install_dependencies` script failed.
4. `3`: `build_nexe` script failed.
2. `bin/check_assets`: Checks if target build has been published and lazily creates release if it doesn't exist.
1. Args:
1. Node.js version to target.
2. Repo commit to create release for.
3. `--no-create-release` flag (optional)
2. Environmental Variables:
1. `GITHUB_TOKEN`: Token to use for querying github and creating release if needed. [required]
3. Files created:
1. `$repo_base/NEXE_ASSET_NAME`: Name of the nexe asset to create. (integer)
2. `$repo_base/RELEASE_ID`: The ID of the Github Release to publish assets to. (`${targetOs}-${targetArch}-${targetNodeVersion}`)
4. Exit codes:
1. `0`: Build not needed
2. `1`: Error occurred
3. `10`: Build needed.
2. `bin/install_dependencies`: Installs proper dependencies for each OS.
1. Args: None
2. Environmental Variables: None
3. Files created: None
4. Exit codes:
1. `0`: Success
2. `*`: Failure
3. `bin/build_nexe`: Performs nexe build based on given node version.
1. Args:
1. Command (`build` or `build-check`)
2. Node.js version to build for.
2. Environmental Variables: None
3. Files created:
1. Nexe build artifact (`$repo_dir/dist/$os_env-$os_arch-$node_target`)
4. Exit codes:
1. `0`: Success
2. `*`: Failure
9 changes: 9 additions & 0 deletions RELEASE_LOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# urbdyn/nexe_builds release log

## 0.1.1

* Created on: 2021-10-10
* Nexe version: 4.0.0-beta.19
* Initial release.
* Build matrix:
* OS: `linux`, `macos`, `windows`
* Node Version: `12.21.0`, `12.22.6`, `14.16.0`, `14.18.0`, `16.11.0`

## 0.1.0

* Created on: 2021-03-17
Expand Down
6 changes: 4 additions & 2 deletions bin/build_nexe
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ function main(){
nexe_cmd="$nexe_cmd -o $nexe_no_mangle_path '$repo_dir/index.js'"

echo "console.log()" > "$repo_dir/index.js"
echo "Building $nexe_no_mange_name"
echo "Building $nexe_no_mangle_name"
echo " $nexe_cmd"
time npx $nexe_cmd
rm "$repo_dir/index.js"
# Not compressing right now because nexe currently doesn't support downloading
# compressed prebuilt binaries.
#echo "Compressing outputted file ..."
#cd "$build_dir"
#gzip -1 "./$nexe_no_mange_name"
#gzip -1 "./$nexe_no_mangle_name"
;;
*)
echo "Command is not supported: $cmd"
Expand Down
18 changes: 13 additions & 5 deletions bin/check_asset
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ async function main() {
console.log(`nexeAssetName = ${nexeAssetName}`);

console.log(`Writing nexe asset name (${nexeAssetName}) to file: NEXE_ASSET_NAME`);
const releaseIdPath = path.join(__dirname, '../NEXE_ASSET_NAME');
fs.writeFileSync(releaseIdPath, nexeAssetName);
const assetNamePath = path.join(__dirname, '../NEXE_ASSET_NAME');
fs.writeFileSync(assetNamePath, nexeAssetName);

// Generate asset data
const assetData = genAssetData(packageData.version, targetOs);
Expand All @@ -98,14 +98,16 @@ async function main() {
const existingAsset = releaseAssetsNames.includes(nexeAssetName);
if (existingAsset) {
console.log(`Existing asset found: ${existingAsset}`);
console.log(`Build NOT needed. Exiting cleanly.`)
console.log(`Build NOT needed. Exiting cleanly.`);
process.exit(0);
} else {
console.log(`Existing asset NOT found.`);
console.log(`Build needed! Exiting with error code 10.`)
console.log(`Build needed! Exiting with error code 10.`);
process.exit(10);
}
} else {
let releaseId = 'none'; // Default to none unless release is created

console.log(`No existing release version '${packageData.version}' found.`);
console.log(`Creating release '${packageData.version}' ...`)
const releaseBody = `Release of pre-built nexe binaries using nexe version: ${nexeVersion}`;
Expand All @@ -122,10 +124,16 @@ async function main() {
);
console.log('Release created.');
console.log(createResponse);
releaseId = createResponse.id;
} else {
console.log('Skipping creating release due to --no-create-release flag.');
}
console.log(`Build needed! Exiting with error code 10.`)

console.log(`Writing new release ID (${releaseId}) to file: RELEASE_ID`);
const releaseIdPath = path.join(__dirname, '../RELEASE_ID');
fs.writeFileSync(releaseIdPath, 'none');

console.log(`Build needed! Exiting with error code 10.`);
process.exit(10);
}

Expand Down
2 changes: 1 addition & 1 deletion bin/install_dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ case "$os_env" in
sudo apt-get install -y ccache
set +x
;;
# Temporarily disabling to see if build works
# Temporarily disabling as it was causing build to fail for unknown reasons
#"macos")
# echo "Installing macos dependencies ..."
# set -x
Expand Down
6 changes: 3 additions & 3 deletions bin/run_cd
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ case "$exit_code" in
;;
"10")
echo "Running: bin/install_dependencies"
$script_dir/install_dependencies
$script_dir/install_dependencies || exit 2
echo "Running: bin/build_nexe build $NODE_VERSION"
$script_dir/build_nexe build "$NODE_VERSION"
$script_dir/build_nexe build "$NODE_VERSION" || exit 3
;;
*)
echo "Error exit code detected ($exit_code)! Crashing."
echo "Error exit code detected ($exit_code) from check_asset script! Crashing."
exit 1
;;
esac
Loading

0 comments on commit e5bc120

Please sign in to comment.