diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml new file mode 100644 index 00000000..a2983a35 --- /dev/null +++ b/.github/workflows/pr.yaml @@ -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 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index fd4ab874..ff4fcf65 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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 diff --git a/.vscode/settings.json b/.vscode/settings.json index efad8aad..32c2e98d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -23,6 +23,7 @@ "rust-toolchain": true, "rustfmt.toml": true, "Cargo.toml": true, + ".npmrc": true, "package.json": true }, "deno.enablePaths": [ diff --git a/justfile b/justfile index 441f7c70..029f133e 100644 --- a/justfile +++ b/justfile @@ -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 \ No newline at end of file