Skip to content

Commit

Permalink
workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
alshdavid committed Mar 10, 2024
1 parent 599d569 commit c5a2a65
Show file tree
Hide file tree
Showing 4 changed files with 228 additions and 8 deletions.
217 changes: 217 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
name: Release

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

on:
push:
branches:
- 'main'
pull_request:
branches:
- '*'

env:
PUBLISH_NPM: "dummy"
PUBLISH_BIN: "dummy"
BIN_CODENAME: dummy""

jobs:
vars:
name: Generate Variables
runs-on: ubuntu-latest
outputs:
BRANCH_NAME: ${{ steps.step1.outputs.BRANCH_NAME }}
NPM_TAG: ${{ steps.step1.outputs.NPM_TAG }}
NEXT_NPM_VERSION: ${{ steps.step1.outputs.NEXT_NPM_VERSION }}
NEXT_BIN_VERSION: ${{ steps.step1.outputs.NEXT_BIN_VERSION }}
steps:
- uses: actions/checkout@v4
- id: step1
run: |
npm install -g pnpm && pnpm i
export BRANCH_NAME=${GITHUB_REF##*/}
export NPM_TAG=$BRANCH_NAME
if [ $NPM_TAG = "main" ]; then
export NPM_TAG="latest"
fi
if [ "$PUBLISH_NPM" = "true" ]; then
NEXT_NPM_VERSION="$(node .github/scripts/ci/next-npm-version.mjs)"
echo "NEXT_NPM_VERSION=$NEXT_NPM_VERSION" >> $GITHUB_OUTPUT
echo NEXT_NPM_VERSION = $NEXT_NPM_VERSION
fi
if [ "$PUBLISH_BIN" = "true" ]; then
NEXT_BIN_VERSION="$(node .github/scripts/ci/next-github-release.mjs)"
echo "NEXT_BIN_VERSION=$NEXT_BIN_VERSION" >> $GITHUB_OUTPUT
echo NEXT_BIN_VERSION = $NEXT_BIN_VERSION
fi
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_OUTPUT
echo "NPM_TAG=$NPM_TAG" >> $GITHUB_OUTPUT
linux-amd64:
name: "Build: linux-amd64"
runs-on: ubuntu-latest
needs: [vars]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20 }

- name: Setup Dependencies
run: |
sudo apt-get update
npm install -g npm pnpm
pnpm install
rustup target add x86_64-unknown-linux-gnu
- name: Build
env:
BIN_VERSION: ${{ needs.vars.outputs.NEXT_BIN_VERSION }}
run: |
node .github/scripts/run.mjs build --profile release-lto --target x86_64-unknown-linux-gnu
linux-arm64:
name: "Build: linux-arm64"
runs-on: ubuntu-latest
needs: [vars]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20 }

- name: Setup Dependencies
run: |
sudo apt-get update
npm install -g npm pnpm
pnpm install
sudo apt-get install gcc-aarch64-linux-gnu build-essential
rustup target add aarch64-unknown-linux-gnu
aarch64-linux-gnu-gcc --version
- name: Build
env:
BIN_VERSION: ${{ needs.vars.outputs.NEXT_BIN_VERSION }}
run: |
export CC=aarch64-linux-gnu-gcc
node .github/scripts/run.mjs build --profile release-lto --target aarch64-unknown-linux-gnu
macos-amd64:
name: "Build: macos-amd64"
runs-on: macos-13
needs: [vars]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20 }

- name: Setup Dependencies
run: |
npm install -g npm pnpm
pnpm install
rustup target add x86_64-apple-darwin
- name: Build
env:
BIN_VERSION: ${{ needs.vars.outputs.NEXT_BIN_VERSION }}
run: |
node .github/scripts/run.mjs build --profile release-lto --target x86_64-apple-darwin
macos-arm64:
name: "Build: macos-arm64"
runs-on: macos-13
needs: [vars]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20 }

- name: Setup Dependencies
run: |
npm install -g npm pnpm
pnpm install
rustup target add aarch64-apple-darwin
- name: Build
env:
BIN_VERSION: ${{ needs.vars.outputs.NEXT_BIN_VERSION }}
run: |
node .github/scripts/run.mjs build --profile release-lto --target aarch64-apple-darwin
windows-amd64:
name: "Build: windows-amd64"
runs-on: windows-latest
needs: [vars]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20 }

- name: Setup Dependencies
run: |
npm install -g npm pnpm
pnpm install
rustup target add x86_64-pc-windows-msvc
- name: Build
env:
BIN_VERSION: ${{ needs.vars.outputs.NEXT_BIN_VERSION }}
run: |
node .github/scripts/run.mjs build --profile release-lto --target x86_64-pc-windows-msvc
windows-arm64:
name: "Build: windows-arm64"
runs-on: windows-latest
needs: [vars]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20 }

- name: Setup Dependencies
run: |
npm install -g npm pnpm
pnpm install
rustup target add aarch64-pc-windows-msvc
- name: Build
env:
BIN_VERSION: ${{ needs.vars.outputs.NEXT_BIN_VERSION }}
run: |
node .github/scripts/run.mjs build --profile release-lto --target aarch64-pc-windows-msvc
npm-package:
name: "Build: NPM"
runs-on: ubuntu-latest
needs: [vars]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20 }
- name: Build NPM
env:
BIN_VERSION: ${{ needs.vars.outputs.NEXT_BIN_VERSION }}
NPM_VERSION: ${{ needs.vars.outputs.NEXT_NPM_VERSION }}
NPM_BIN_TARGET: ${{ needs.vars.outputs.BRANCH_NAME }}
run: |
if [ "$PUBLISH_NPM" != "true" ]; then
exit 0
fi
npm install -g npm pnpm
pnpm install
node .github/scripts/run.mjs build
echo "NPM_VERSION = $NPM_VERSION"
echo "NPM_BIN_TARGET = $NPM_BIN_TARGET"
cd npm/mach
node ./_scripts/prepack/prepack.mjs
rm -rf ./_scripts/prepack
npm pack
mv *.tgz ../../mach-npm.tgz
7 changes: 0 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,6 @@ jobs:
if-no-files-found: error
retention-days: 1

- uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}
path: target/macos-arm64/mach-macos-arm64.tar.gz
if-no-files-found: error
retention-days: 1

windows-amd64:
name: "Build: windows-amd64"
runs-on: windows-latest
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"rust-toolchain": true,
"rustfmt.toml": true,
"Cargo.toml": true,
".npmrc": true,
"package.json": true
},
"deno.enablePaths": [
Expand Down
11 changes: 10 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ three-js:
cp ./target/.cargo/{{profile}}/mach ./target/{{profile}}/bin

@_build_npm:
{{ if `node .github/scripts/ci/package-sha.mjs read` == "true" { "cd npm/node-adapter && pnpm run build && node ../../.github/scripts/ci/package-sha.mjs set" } else { "echo skip npm build" } }}
@just {{ if `node .github/scripts/ci/package-sha.mjs read` == "true" { "_build_npm_actions" } else { "_skip" } }}

@_build_npm_actions:
echo building npm packages
pnpm install
cd npm/node-adapter && pnpm run build
cp -r npm/node-adapter/lib ./target/{{profile}}/lib/node-adapter
cp -r npm/node-adapter/types ./target/{{profile}}/lib/node-adapter
node .github/scripts/ci/package-sha.mjs set

@_skip:
echo skip

0 comments on commit c5a2a65

Please sign in to comment.