From a131c7784776651e3b5b45b78687274a0a3e07fe Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Thu, 14 Mar 2024 12:24:36 -0400 Subject: [PATCH] v5 (#9) * push up some prelim tests * push up some prelim tests 2 * push up some prelim tests 3 * first pass on only emulate if needed * arch mismatch tests * arch mismatch tests 2 * arch mismatch tests 3 * arm native test * arm native test 2 * readme * release tag --- .DS_Store | Bin 0 -> 6148 bytes .github/workflows/pr-armed-tests.yml | 45 ++++++++++++++++++++++++ .github/workflows/pr-func-tests.yml | 11 +++--- .github/workflows/pr-test-inputs.yml | 47 ++++++++++++++----------- .github/workflows/release.yml | 2 +- CHANGELOG.md | 10 ++++++ README.md | 10 +++--- action.yml | 50 +++++++++++++++++++++------ package.json | 8 +++++ 9 files changed, 142 insertions(+), 41 deletions(-) create mode 100644 .DS_Store create mode 100644 .github/workflows/pr-armed-tests.yml diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..8b70a6efebbca978bf799f64e9352efd53a18940 GIT binary patch literal 6148 zcmeHKy-EW?5S~pAJXFxaLJQ?eK@d~fSez2UJ`Z3xBSy&O0x^Y!aFwNkVDB>szJc0m zrHJogDSorNCc9n|EJQ?RVE5abpPji6Zs(SW)K;%iA(|zk5Q8z8#56?M&Z8hDtC<5T z-lKI;sqJNHr{F0HVL%x8iwy9$8_+5p&>@zyj=ZOV{)pLQwLs~)xR)cx}2kK=sZy6$gY4^K^9BlmXe{Eoj{x9Lw@y2uYQ zfS%0~P8pP07!U@8fj$F#K13LdvBlh=J~}YzD*!NnS_{^?w*ezo0Aq`}L1-Y#gaS>d zvR4dc!l93>Uu-cqXu?V9%-F|fR`!OXbav#Xdv<< NplOgv82D8NJ^*sdrvLx| literal 0 HcmV?d00001 diff --git a/.github/workflows/pr-armed-tests.yml b/.github/workflows/pr-armed-tests.yml new file mode 100644 index 0000000..f129644 --- /dev/null +++ b/.github/workflows/pr-armed-tests.yml @@ -0,0 +1,45 @@ +name: ARMed Tests + +on: + pull_request: + +jobs: + basic-arm-test: + runs-on: macos-14 + steps: + - name: Checkout action code + uses: actions/checkout@v3 + - name: Run Pkg Action + uses: ./ + with: + entrypoint: bin/test + upload: false + - name: Test Bin + run: | + chmod +x dist/@lando/pkg-action + dist/@lando/pkg-action --version + file dist/@lando/pkg-action | grep "Mach-O 64-bit executable arm64" + + basic-cross-os-armed-tests: + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + runner: + - macos-14 + - ubuntu-22.04 + os: + - linux + - macos + - win + + steps: + - name: Checkout action code + uses: actions/checkout@v3 + - name: Run Pkg Action + uses: ./ + with: + entrypoint: bin/test + arch: arm64 + os: ${{ matrix.os }} + upload: false diff --git a/.github/workflows/pr-func-tests.yml b/.github/workflows/pr-func-tests.yml index 8dcfeed..7bfa815 100644 --- a/.github/workflows/pr-func-tests.yml +++ b/.github/workflows/pr-func-tests.yml @@ -5,7 +5,7 @@ on: jobs: basic-func-test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout action code uses: actions/checkout@v3 @@ -21,8 +21,9 @@ jobs: fail-fast: false matrix: os: - - macos-11 - - ubuntu-20.04 + - macos-13 + - macos-14 + - ubuntu-22.04 - windows-2022 steps: - name: Checkout action code @@ -35,7 +36,7 @@ jobs: upload: false basic-cross-everything-test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: @@ -51,7 +52,7 @@ jobs: pkg: - "pkg@5.8.0" - "pkg@5.8.1" - - "@yao-pkg/pkg@5.10.0" + - "@yao-pkg/pkg@5.11.5" steps: - name: Checkout action code uses: actions/checkout@v3 diff --git a/.github/workflows/pr-test-inputs.yml b/.github/workflows/pr-test-inputs.yml index abd4711..1b9fcee 100644 --- a/.github/workflows/pr-test-inputs.yml +++ b/.github/workflows/pr-test-inputs.yml @@ -5,7 +5,7 @@ on: jobs: test-default-inputs: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout action code uses: actions/checkout@v3 @@ -29,7 +29,7 @@ jobs: - name: "TEST: should set the correct artifact-key" if: always() run: | - if [ "${{ steps.default-input-tests.outputs.artifact-key }}" == "pkg-action-node16-linux-x64-${{ github.sha }}" ]; then + if [ "${{ steps.default-input-tests.outputs.artifact-key }}" == "pkg-action-node20-linux-x64-${{ github.sha }}" ]; then echo "::notice title=TEST PASSED::Output artifact key set from defaults correctly" else echo "::error title=TEST FAILED!::Output artifact key not set correctly" @@ -38,12 +38,17 @@ jobs: shell: bash test-arch-inputs: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: + fail-fast: false matrix: arch: + - X86 + - X64 - amd64 - x64 + - ARM + - ARM64 - aarch64 - arm64 steps: @@ -60,29 +65,29 @@ jobs: - name: "TEST: should map ${{ matrix.arch }} to x64 or arm64 as needed" if: always() run: | - if [ "${{ matrix.arch }}" == "x64" ]; then - if [ "${{ steps.arch-input-tests.outputs.artifact-key }}" == "pkg-action-node16-linux-x64-${{ github.sha }}" ]; then + if [ "${{ matrix.arch }}" == "X86" ] || [ "${{ matrix.arch }}" == "X64" ]; then + if [ "${{ steps.arch-input-tests.outputs.artifact-key }}" == "pkg-action-node20-linux-x64-${{ github.sha }}" ]; then echo "::notice title=TEST PASSED::Arch mapping from ${{ matrix.arch }} to x64 correctly" else echo "::error title=TEST FAILED!::Arch not mapping from ${{ matrix.arch }} to x64 correctly" exit 1 fi - elif [ "${{ matrix.arch }}" == "amd64" ]; then - if [ "${{ steps.arch-input-tests.outputs.artifact-key }}" == "pkg-action-node16-linux-x64-${{ github.sha }}" ]; then + elif [ "${{ matrix.arch }}" == "amd64" ] || [ "${{ matrix.arch }}" == "x64" ]; then + if [ "${{ steps.arch-input-tests.outputs.artifact-key }}" == "pkg-action-node20-linux-x64-${{ github.sha }}" ]; then echo "::notice title=TEST PASSED::Arch mapping from ${{ matrix.arch }} to x64 correctly" else echo "::error title=TEST FAILED!::Arch not mapping from ${{ matrix.arch }} to x64 correctly" exit 2 fi - elif [ "${{ matrix.arch }}" == "arm64" ]; then - if [ "${{ steps.arch-input-tests.outputs.artifact-key }}" == "pkg-action-node16-linux-arm64-${{ github.sha }}" ]; then + elif [ "${{ matrix.arch }}" == "ARM" ] || [ "${{ matrix.arch }}" == "ARM64" ]; then + if [ "${{ steps.arch-input-tests.outputs.artifact-key }}" == "pkg-action-node20-linux-arm64-${{ github.sha }}" ]; then echo "::notice title=TEST PASSED::Arch mapping from ${{ matrix.arch }} to arm64 correctly" else echo "::error title=TEST FAILED!::Arch not mapping from ${{ matrix.arch }} to arm64 correctly" exit 3 fi - elif [ "${{ matrix.arch }}" == "aarch64" ]; then - if [ "${{ steps.arch-input-tests.outputs.artifact-key }}" == "pkg-action-node16-linux-arm64-${{ github.sha }}" ]; then + elif [ "${{ matrix.arch }}" == "arm64" ] || [ "${{ matrix.arch }}" == "aarch64" ]; then + if [ "${{ steps.arch-input-tests.outputs.artifact-key }}" == "pkg-action-node20-linux-arm64-${{ github.sha }}" ]; then echo "::notice title=TEST PASSED::Arch mapping from ${{ matrix.arch }} to arm64 correctly" else echo "::error title=TEST FAILED!::Arch not mapping from ${{ matrix.arch }} to arm64 correctly" @@ -95,10 +100,11 @@ jobs: test-runner-os: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: - - macos-11 - - ubuntu-20.04 + - macos-13 + - ubuntu-22.04 - windows-2022 steps: @@ -115,21 +121,21 @@ jobs: if: always() run: | if [ "${{ runner.os }}" == "Linux" ]; then - if [ "${{ steps.runner-os-tests.outputs.artifact-key }}" == "pkg-action-node16-linux-x64-${{ github.sha }}" ]; then + if [ "${{ steps.runner-os-tests.outputs.artifact-key }}" == "pkg-action-node20-linux-x64-${{ github.sha }}" ]; then echo "::notice title=TEST PASSED::Runner OS mapping to linux correctly" else echo "::error title=TEST FAILED!::Runner OS mapping not mapping to linux correctly" exit 1 fi elif [ "${{ runner.os }}" == "macOS" ]; then - if [ "${{ steps.runner-os-tests.outputs.artifact-key }}" == "pkg-action-node16-macos-x64-${{ github.sha }}" ]; then + if [ "${{ steps.runner-os-tests.outputs.artifact-key }}" == "pkg-action-node20-macos-x64-${{ github.sha }}" ]; then echo "::notice title=TEST PASSED::Runner OS mapping to macos correctly" else echo "::error title=TEST FAILED!::Runner OS mapping not mapping to macos correctly" exit 2 fi elif [ "${{ runner.os }}" == "Windows" ]; then - if [ "${{ steps.runner-os-tests.outputs.artifact-key }}" == "pkg-action-node16-win-x64-${{ github.sha }}" ]; then + if [ "${{ steps.runner-os-tests.outputs.artifact-key }}" == "pkg-action-node20-win-x64-${{ github.sha }}" ]; then echo "::notice title=TEST PASSED::Runner OS mapping to win correctly" else echo "::error title=TEST FAILED!::Runner OS mapping not mapping to win correctly" @@ -139,8 +145,9 @@ jobs: shell: bash test-os-input: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: + fail-fast: false matrix: os: - macos @@ -162,21 +169,21 @@ jobs: if: always() run: | if [ "${{ matrix.os }}" == "linux" ]; then - if [ "${{ steps.os-input-tests.outputs.artifact-key }}" == "pkg-action-node16-linux-x64-${{ github.sha }}" ]; then + if [ "${{ steps.os-input-tests.outputs.artifact-key }}" == "pkg-action-node20-linux-x64-${{ github.sha }}" ]; then echo "::notice title=TEST PASSED::OS input ${{ matrix.os }} being used correctly" else echo "::error title=TEST FAILED!::OS input not being using ${{ matrix.os }} correctly" exit 1 fi elif [ "${{ matrix.os }}" == "macos" ]; then - if [ "${{ steps.os-input-tests.outputs.artifact-key }}" == "pkg-action-node16-macos-x64-${{ github.sha }}" ]; then + if [ "${{ steps.os-input-tests.outputs.artifact-key }}" == "pkg-action-node20-macos-x64-${{ github.sha }}" ]; then echo "::notice title=TEST PASSED::OS input ${{ matrix.os }} being used correctly" else echo "::error title=TEST FAILED!::OS input not being using ${{ matrix.os }} correctly" exit 2 fi elif [ "${{ matrix.os }}" == "win" ]; then - if [ "${{ steps.os-input-tests.outputs.artifact-key }}" == "pkg-action-node16-win-x64-${{ github.sha }}" ]; then + if [ "${{ steps.os-input-tests.outputs.artifact-key }}" == "pkg-action-node20-win-x64-${{ github.sha }}" ]; then echo "::notice title=TEST PASSED::OS input ${{ matrix.os }} being used correctly" else echo "::error title=TEST FAILED!::OS input not being using ${{ matrix.os }} correctly" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 44b1c7c..7d6b49b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,4 +14,4 @@ jobs: - name: Prepare release uses: lando/prepare-release-action@v2 with: - sync-tags: v4 + sync-tags: v5 diff --git a/CHANGELOG.md b/CHANGELOG.md index bba7dbb..210616a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## v5.0.0 - [March 14, 2023](https://github.com/lando/pkg-action/releases/tag/v5.0.0) + +### **BREAKING CHANGES** + +* Added support for `node20` +* Changed default `node` version to `node20` +* Changed default `arch` to `${{ runner.arch }}` +* Improved `arch` behavior so emulation is only used if needed +* Updated default `pkg` package to `@yao-pkg/pkg@5.11.5` since `vercel/pkg` is **DEPRECATED** + ## v4.0.0 - [December 4, 2023](https://github.com/lando/pkg-action/releases/tag/v4.0.0) ### **BREAKING CHANGES** diff --git a/README.md b/README.md index d2b709b..acc73a9 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Pkg Action -This is a GitHub action that allows you to "compile" node projects with [pkg](https://github.com/vercel/pkg). It supports: +This is a GitHub action that allows you to "compile" node projects with [@yao-pkg/pkg](https://github.com/yao-pkg/pkg). It supports: -* All `pkg` supported node versions +* All `@yao-pkg/pkg` supported node versions * `x64|amd64` and `aarch64|arm64` * `macos|linux|windows`. @@ -29,12 +29,12 @@ These keys are set to sane defaults but can be modified as needed. | Name | Description | Default | Example | |---|---|---|---| -| `arch` | The architecture to build for. | `amd64` | `x64` \| `amd64` \| `aarch64` \| `arm64` | +| `arch` | The architecture to build for. | `${{ runner.arch }}` | `x64` \| `amd64` \| `aarch64` \| `arm64` | | `config` | The config file to use. | `package.json` | `config.json` | -| `node-version` | The node version to package with. | `16` | `8` \| `10` \| `12` \| `14` \| `16` | +| `node-version` | The node version to package with. | `20` | `8` \| `10` \| `12` \| `14` \| `16` \| `18` \| `20` | | `options` | Additional options and flags to pass into pkg. | `null` | Additional [pkg options](https://github.com/vercel/pkg#usage) | | `os` | The operating system to build for. | `${{ runner.os }}` | `linux` \| `macos` \| `win` | -| `pkg` | The `pkg` package` to use. | `pkg@5.8.1` | `latest` | +| `pkg` | The `pkg` package` to use. | `@yao-pkg/pkg@5.11.5` | `pkg@5.8.1` | | `upload` | Upload the artifacts. Useful if you need to grab them for downstream for things like code signing. | `true` | `false` \| `true` | ## Outputs diff --git a/action.yml b/action.yml index cbb0547..b4fd3c6 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ name: "Pkg Action" -description: "A GitHub Action for 'compiling' node projects into binaries using vercel/pkg." +description: "A GitHub Action for 'compiling' node projects into binaries using vercel/pkg or equivalent" branding: color: purple icon: package @@ -13,7 +13,7 @@ inputs: arch: description: "The architecture to build for x64|amd64|aarch64|arm64" required: false - default: amd64 + default: ${{ runner.arch }} config: description: "The config file to use" required: false @@ -21,7 +21,7 @@ inputs: node-version: description: "The node version to package with" required: false - default: 16 + default: "20" options: description: "Additional options and flags to pass into pkg" required: false @@ -30,9 +30,9 @@ inputs: required: false default: ${{ runner.os }} pkg: - description: "The version on @vercel/pkg to use" + description: "The version of pkg to use" required: false - default: "pkg@5.8.1" + default: "@yao-pkg/pkg@5.11.5" test: description: "Hidden flag for input testing" default: false @@ -78,8 +78,28 @@ runs: echo "target-os=${{ inputs.os }}" >> $GITHUB_OUTPUT fi - if [ "${{ inputs.arch }}" == "amd64" ]; then + if [ "${{ runner.arch }}" == "X86" ]; then + echo "runner-arch=x64" >> $GITHUB_OUTPUT + elif [ "${{ runner.arch }}" == "X64" ]; then + echo "runner-arch=x64" >> $GITHUB_OUTPUT + elif [ "${{ runner.arch }}" == "ARM" ]; then + echo "runner-arch=arm64" >> $GITHUB_OUTPUT + elif [ "${{ runner.arch }}" == "ARM64" ]; then + echo "runner-arch=arm64" >> $GITHUB_OUTPUT + else + echo "runner-arch=${{ runner.arch }}" >> $GITHUB_OUTPUT + fi + + if [ "${{ inputs.arch }}" == "X86" ]; then echo "target-arch=x64" >> $GITHUB_OUTPUT + elif [ "${{ inputs.arch }}" == "X64" ]; then + echo "target-arch=x64" >> $GITHUB_OUTPUT + elif [ "${{ inputs.arch }}" == "amd64" ]; then + echo "target-arch=x64" >> $GITHUB_OUTPUT + elif [ "${{ inputs.arch }}" == "ARM" ]; then + echo "target-arch=arm64" >> $GITHUB_OUTPUT + elif [ "${{ inputs.arch }}" == "ARM64" ]; then + echo "target-arch=arm64" >> $GITHUB_OUTPUT elif [ "${{ inputs.arch }}" == "aarch64" ]; then echo "target-arch=arm64" >> $GITHUB_OUTPUT else @@ -89,6 +109,16 @@ runs: echo "target-node=node${{ inputs.node-version }}" >> $GITHUB_OUTPUT echo "::endgroup::" + - name: Validate arch emulation requirements + shell: bash + run: | + if [ "${{ steps.pkg-action-internal.outputs.target-arch }}" != "${{ steps.pkg-action-internal.outputs.runner-arch }}" ]; then + if [ "${{ runner.os }}" != "Linux" ]; then + echo "::error title=Emulation only possible on Linux!::Emulating ${{ steps.pkg-action-internal.outputs.target-arch }} is only possible on Linux runners!" + exit 48 + fi + fi + - name: Install node ${{ inputs.node-version }} uses: actions/setup-node@v3 with: @@ -119,8 +149,8 @@ runs: echo "artifact-key=${{ github.event.repository.name }}-${{ steps.pkg-action-internal.outputs.target-node }}-${{ steps.pkg-action-internal.outputs.target-os }}-${{ steps.pkg-action-internal.outputs.target-arch }}-${{ github.sha }}" >> $GITHUB_OUTPUT echo "::endgroup::" - - name: Run x64 pkg command - if: inputs.test != 'true' && steps.pkg-action-internal.outputs.target-arch == 'x64' + - name: Run native ${{ steps.pkg-action-internal.outputs.target-arch }} pkg command + if: inputs.test != 'true' && steps.pkg-action-internal.outputs.target-arch == steps.pkg-action-internal.outputs.runner-arch shell: bash env: RUNNER_DEBUG: ${{ env.RUNNER_DEBUG }} @@ -143,8 +173,8 @@ runs: fi stat ${{ steps.pkg-action.outputs.file }} - - name: Run arm64 pkg command - if: inputs.test != 'true' && steps.pkg-action-internal.outputs.target-arch == 'arm64' + - name: Run emulated ${{ steps.pkg-action-internal.outputs.target-arch }} pkg command + if: inputs.test != 'true' && steps.pkg-action-internal.outputs.target-arch == 'arm64' && steps.pkg-action-internal.outputs.runner-arch == 'x64' uses: uraimo/run-on-arch-action@v2 with: arch: aarch64 diff --git a/package.json b/package.json index 49d8f95..2556009 100644 --- a/package.json +++ b/package.json @@ -19,5 +19,13 @@ ], "engines": { "node": ">=18.0.0" + }, + "pkg": { + "assets": [ + "package.json" + ], + "scripts": [ + "bin/*.js" + ] } }