-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI Napi multiple workers
- Loading branch information
Showing
41 changed files
with
559 additions
and
464 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
name: 'alshdavid/build' | ||
description: "Build Project" | ||
|
||
inputs: | ||
os: | ||
description: 'target operating system' | ||
default: ${{ runner.os == 'Linux' && 'linux' || runner.os == 'macOS' && 'macos' || runner.os == 'Windows' && 'windows' }} | ||
arch: | ||
description: 'target CPU architecture' | ||
default: ${{ runner.arch == 'ARM64' && 'arm64' || runner.arch == 'X64' && 'amd64' }} | ||
profile: | ||
description: 'Build profile' | ||
default: "release" | ||
mach_version: | ||
description: 'prepare packages for publishing' | ||
default: '' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
# Builds for Native Hosts | ||
- name: "Build Mach (native host - Unix)" | ||
if: | | ||
(runner.os == 'Linux' && runner.arch == 'X64' && | ||
inputs.os == 'linux' && inputs.arch == 'amd64') || | ||
(runner.os == 'Linux' && runner.arch == 'ARM64' && | ||
inputs.os == 'linux' && inputs.arch == 'arm64') || | ||
(runner.os == 'macOS' && runner.arch == 'X64' && | ||
inputs.os == 'macos' && inputs.arch == 'amd64') || | ||
(runner.os == 'macOS' && runner.arch == 'ARM64' && | ||
inputs.os == 'macos' && inputs.arch == 'arm64') | ||
shell: bash | ||
env: | ||
os: "${{inputs.os}}" | ||
arch: "${{inputs.arch}}" | ||
MACH_VERSION: "${{inputs.mach_version}}" | ||
profile: "${{inputs.profile}}" | ||
run: | | ||
source .github/actions/setup-env/setup-env.bash | ||
bash .github/actions/build-mach/build.bash | ||
- name: "Build Mach (native host - Windows)" | ||
if: | | ||
(runner.os == 'Windows' && runner.arch == 'X64' && | ||
inputs.os == 'windows' && inputs.arch == 'amd64') || | ||
(runner.os == 'Windows' && runner.arch == 'ARM64' && | ||
inputs.os == 'windows' && inputs.arch == 'arm64') | ||
shell: powershell | ||
env: | ||
os: "${{inputs.os}}" | ||
arch: "${{inputs.arch}}" | ||
MACH_VERSION: "${{inputs.mach_version}}" | ||
profile: "${{inputs.profile}}" | ||
run: | | ||
. .github/actions/setup-env/setup-env.ps1 | ||
. .github/actions/build-mach/build.ps1 | ||
# Cross Compilation | ||
- name: "Build Mach (cross build - Linux arm64 on amd64)" | ||
if: | | ||
(runner.os == 'Linux' && runner.arch == 'X64' && | ||
inputs.os == 'linux' && inputs.arch == 'arm64') | ||
shell: bash | ||
env: | ||
os: "${{inputs.os}}" | ||
arch: "${{inputs.arch}}" | ||
MACH_VERSION: "${{inputs.mach_version}}" | ||
profile: "${{inputs.profile}}" | ||
run: | | ||
source .github/actions/setup-env/setup-env.bash | ||
export CC=aarch64-linux-gnu-gcc | ||
export MACH_SKIP_POST_INSTALL="true" | ||
sudo apt-get update | ||
sudo apt-get install gcc-aarch64-linux-gnu build-essential | ||
rustup target add aarch64-unknown-linux-gnu | ||
aarch64-linux-gnu-gcc --version | ||
bash .github/actions/build-mach/build.bash | ||
- name: "Build Mach (cross build - MacOS amd64 on arm64)" | ||
if: | | ||
(runner.os == 'macOS' && runner.arch == 'ARM64' && | ||
inputs.os == 'macos' && inputs.arch == 'amd64') | ||
shell: bash | ||
env: | ||
os: "${{inputs.os}}" | ||
arch: "${{inputs.arch}}" | ||
MACH_VERSION: "${{inputs.mach_version}}" | ||
profile: "${{inputs.profile}}" | ||
run: | | ||
source .github/actions/setup-env/setup-env.bash | ||
rustup target add x86_64-apple-darwin | ||
bash .github/actions/build-mach/build.bash | ||
- name: "Build Mach (cross build - MacOS arm64 on amd64)" | ||
if: | | ||
(runner.os == 'macOS' && runner.arch == 'ARM64' && | ||
inputs.os == 'macos' && inputs.arch == 'amd64') | ||
shell: bash | ||
env: | ||
os: "${{inputs.os}}" | ||
arch: "${{inputs.arch}}" | ||
MACH_VERSION: "${{inputs.mach_version}}" | ||
profile: "${{inputs.profile}}" | ||
run: | | ||
source .github/actions/setup-env/setup-env.bash | ||
rustup aarch64-apple-darwin | ||
bash .github/actions/build-mach/build.bash | ||
- name: "Build Mach (cross build - Windows arm64 on amd64)" | ||
if: | | ||
(runner.os == 'Windows' && runner.arch == 'X64' && | ||
inputs.os == 'windows' && inputs.arch == 'arm64') | ||
shell: powershell | ||
env: | ||
os: "${{inputs.os}}" | ||
arch: "${{inputs.arch}}" | ||
MACH_VERSION: "${{inputs.mach_version}}" | ||
profile: "${{inputs.profile}}" | ||
run: | | ||
. .github/actions/setup-env/setup-env.ps1 | ||
rustup target add aarch64-pc-windows-msvc | ||
. .github/actions/build-mach/build.ps1 | ||
# Copy Artifacts | ||
- name: "Copy Artifacts (Unix)" | ||
if: runner.os != 'Windows' | ||
shell: bash | ||
env: | ||
os: "${{inputs.os}}" | ||
arch: "${{inputs.arch}}" | ||
run: | | ||
source .github/actions/setup-env/setup-env.bash | ||
if [ "$MACH_VERSION" = "" ]; then | ||
exit 0 | ||
fi | ||
export ROOT_DIR="$(pwd)" | ||
export JOB_NAME="${os}-${arch}" | ||
mkdir $ROOT_DIR/artifacts | ||
cd $ROOT_DIR/target/$JOB_NAME | ||
mv release mach | ||
tar -czvf mach-$JOB_NAME.tar.gz mach | ||
mv mach-$JOB_NAME.tar.gz $ROOT_DIR/artifacts | ||
cd $ROOT_DIR/npm/mach-os-arch | ||
npm pack | ||
mv *.tgz npm-mach-$JOB_NAME.tgz | ||
mv *.tgz $ROOT_DIR/artifacts/npm-mach-$JOB_NAME.tgz | ||
ls -l $ROOT_DIR/artifacts | ||
- name: "Copy Files (Windows)" | ||
if: runner.os == 'Windows' | ||
shell: powershell | ||
env: | ||
os: "${{inputs.os}}" | ||
arch: "${{inputs.arch}}" | ||
run: | | ||
. .github/actions/setup-env/setup-env.ps1 | ||
if ("$env:MACH_VERSION" -eq "") { | ||
exit 0 | ||
} | ||
$env:RootPath = (Get-Location).Path | ||
$env:Job = "${env:os}-${env:arch}" | ||
New-Item -ItemType "directory" -Force -Path "${env:RootPath}/artifacts" | ||
echo "${env:RootPath}/target/${env:Job}" | ||
cd "${env:RootPath}/target/${env:Job}" | ||
mv release mach | ||
tar -czvf "mach-${env:Job}.tar.gz" mach | ||
Move-Item "mach-${env:Job}.tar.gz" -Destination "${env:RootPath}/artifacts" | ||
cd "${env:RootPath}/npm/mach-os-arch" | ||
npm pack | ||
Move-Item *.tgz -Destination "npm-mach-${env:Job}.tgz" | ||
Move-Item *.tgz -Destination "${env:RootPath}/artifacts/npm-mach-${env:Job}.tgz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
set -e | ||
|
||
if ! [ "$MACH_VERSION" = "" ]; then | ||
echo "Building with version $MACH_VERSION" | ||
just build-publish | ||
else | ||
echo "Building untagged local version" | ||
just build | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
if ("${env:MACH_VERSION}" -ne "") { | ||
just build-publish | ||
} else { | ||
just build | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: 'alshdavid/build-npm' | ||
description: "Build Project" | ||
|
||
inputs: | ||
os: | ||
description: 'target operating system' | ||
default: ${{ runner.os == 'Linux' && 'linux' || runner.os == 'macOS' && 'macos' || runner.os == 'Windows' && 'windows' }} | ||
arch: | ||
description: 'target CPU architecture' | ||
default: ${{ runner.arch == 'ARM64' && 'arm64' || runner.arch == 'X64' && 'amd64' }} | ||
profile: | ||
description: 'Build profile' | ||
default: "release" | ||
mach_version: | ||
description: 'prepare packages for publishing' | ||
default: '' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: "Build Project" | ||
shell: bash | ||
env: | ||
os: "${{inputs.os}}" | ||
arch: "${{inputs.arch}}" | ||
MACH_VERSION: "${{inputs.mach_version}}" | ||
profile: "${{inputs.profile}}" | ||
run: | | ||
source .github/actions/setup-env/setup-env.bash | ||
bash .github/actions/build-npm/build.bash | ||
- name: "Copy Artifacts" | ||
shell: bash | ||
env: | ||
os: "${{inputs.os}}" | ||
arch: "${{inputs.arch}}" | ||
MACH_VERSION: "${{inputs.mach_version}}" | ||
profile: "${{inputs.profile}}" | ||
run: | | ||
source .github/actions/setup-env/setup-env.bash | ||
bash .github/actions/build-npm/copy.bash | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
set -e | ||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
ROOT_DIR=$(dirname $(dirname $(dirname $SCRIPT_DIR))) | ||
|
||
if ! [ "$MACH_VERSION" = "" ]; then | ||
echo "Building with version $MACH_VERSION" | ||
just build-publish | ||
else | ||
echo "Building untagged local version" | ||
just build | ||
fi |
10 changes: 1 addition & 9 deletions
10
.github/workflows/release/npm-package.bash → .github/actions/build-npm/copy.bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: 'alshdavid/setup-env' | ||
description: "Generate Vars" | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: "Generate Vars" | ||
shell: bash | ||
run: "bash .github/actions/setup-env/generate.bash" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
ROOT_DIR=$(dirname $(dirname $(dirname $SCRIPT_DIR))) | ||
|
||
cd $ROOT_DIR | ||
|
||
# Just | ||
export PATH="${HOME}/.local/just:$PATH" | ||
|
||
# Rust | ||
export RUSTUP_HOME="${HOME}/.local/rust/rustup" | ||
export CARGO_HOME="${HOME}/.local/rust/cargo" | ||
export PATH="${HOME}/.local/rust/cargo/bin:$PATH" | ||
|
||
# Nodejs | ||
export PATH="${HOME}/.local/nodejs/bin:$PATH" | ||
export PATH="${HOME}/.local/nodejs/prefix/bin:$PATH" | ||
export NPM_CONFIG_PREFIX="${HOME}/.local/nodejs/prefix" | ||
pnpm config set store-dir $HOME/.local/nodejs/pnpm-store | ||
|
||
ENV_PATH="${ROOT_DIR}/.env" | ||
|
||
if [ -f "$ENV_PATH" ]; then | ||
echo "Reading $ENV_PATH" | ||
while read -r LINE; do | ||
# Remove leading and trailing whitespaces, and carriage return | ||
CLEANED_LINE=$(echo "$LINE" | awk '{$1=$1};1' | tr -d '\r') | ||
|
||
if [[ $CLEANED_LINE != '#'* ]] && [[ $CLEANED_LINE == *'='* ]]; then | ||
echo "Setting: $CLEANED_LINE" | ||
export "$CLEANED_LINE" | ||
fi | ||
done < "$ENV_PATH" | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Project Root | ||
$env:RootPath = "$PSScriptRoot\..\..\.." | ||
|
||
# Just | ||
$env:Path = "${HOME}\.local\just;${env:Path}" | ||
|
||
# Rust | ||
$env:RUSTUP_HOME = "${HOME}\.local\rust\rustup" | ||
$env:CARGO_HOME = "${HOME}\.local\rust\cargo" | ||
$env:Path = "${env:USERPROFILE}\.cargo\bin;${env:Path}" | ||
|
||
# Nodejs | ||
$env:Path = "${HOME}\.local\nodejs;${env:Path}" | ||
$env:Path = "${HOME}\.local\nodejs\prefix\bin;${env:Path}" | ||
$env:NPM_CONFIG_PREFIX = "${HOME}\.local\nodejs\prefix" | ||
pnpm config set store-dir "${HOME}\.local\nodejs\pnpm-store" | ||
|
||
if (Test-Path "${env:RootPath}\.env") { | ||
echo "Loading .env" | ||
Get-Content "${env:RootPath}\.env" | foreach { | ||
$name, $value = $_.split('=') | ||
if ([string]::IsNullOrWhiteSpace($name) -and $name.Contains('#')) { | ||
continue | ||
} | ||
echo "Setting $name = $value" | ||
Set-Item "env:$name" "$value" | ||
} | ||
} |
Oops, something went wrong.