From 65dd9da5af9380d6fa4413788df307206cd1d5e9 Mon Sep 17 00:00:00 2001 From: Roy Razon Date: Tue, 9 Jan 2024 16:56:48 +0200 Subject: [PATCH] switch from pkg to oclif pack --- .github/workflows/gh-release.yaml | 125 ++++++++++++++++++------------ packages/cli/package.json | 17 +++- patches/oclif+4.1.3.patch | 100 ++++++++++++++++++++++++ yarn.lock | 51 ++++++------ 4 files changed, 218 insertions(+), 75 deletions(-) create mode 100644 patches/oclif+4.1.3.patch diff --git a/.github/workflows/gh-release.yaml b/.github/workflows/gh-release.yaml index 9376a0aa..b0a9f93a 100644 --- a/.github/workflows/gh-release.yaml +++ b/.github/workflows/gh-release.yaml @@ -9,70 +9,93 @@ on: jobs: build-binaries: - runs-on: macos-latest + runs-on: ubuntu-latest permissions: contents: read id-token: write - strategy: - matrix: - arch: [x64,arm64] - platform: [linux,macos,win] - exclude: - - platform: win - arch: arm64 + # strategy: + # matrix: + # arch: [x64,arm64] + # platform: [linux,macos,win] + # exclude: + # - platform: win + # arch: arm64 steps: - name: Checkout uses: actions/checkout@v4 - - uses: depot/setup-action@v1 - with: - oidc: true - - name: Build using Docker (with depot) - run: mkdir preevy-bin && depot build --project ${{ vars.DEPOT_PROJECT_ID }} --build-arg CLI_TARGET=${{ matrix.platform }}-${{ matrix.arch }} -f Dockerfile.cli --target=cli --output=type=tar,dest=./preevy-bin/preevy-${{ matrix.platform }}-${{ matrix.arch }}.tar --progress=plain --platform=linux/${{ matrix.arch == 'x64' && 'amd64' || matrix.arch }} . + - uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_ROLE }} + aws-region: us-west-2 - - uses: apple-actions/import-codesign-certs@v2 - if: ${{ matrix.platform == 'macos' }} + - uses: actions/setup-node@v4 with: - p12-file-base64: ${{ secrets.APPLE_CERT_DATA }} - p12-password: ${{ secrets.APPLE_CERT_PASS }} + node-version: '18.x' + cache: yarn + + - run: yarn + - run: yarn build - - name: Sign mac binaries - if: ${{ matrix.platform == 'macos' }} + - name: pack and upload tarballs + working-directory: packages/cli env: - CERT_CN: ${{ vars.APPLE_CERT_CN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TARGETS: linux-x64,linux-arm64,darwin-x64,darwin-arm64,win32-x64 run: | - tar -xf ./preevy-bin/preevy-${{ matrix.platform }}-${{ matrix.arch }}.tar - codesign --remove-signature ./preevy - security find-identity -v - codesign --verbose=4 --sign "$CERT_CN" ./preevy - tar -cf ./preevy-bin/preevy-${{ matrix.platform }}-${{ matrix.arch }}.tar ./preevy + yarn oclif pack tarballs --parallel --no-xz --targets $TARGETS + yarn upload tarballs --no-xz --targets $TARGETS - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: preevy-bin-${{ matrix.platform }}-${{ matrix.arch }} - path: ./preevy-bin/** + # - uses: depot/setup-action@v1 + # with: + # oidc: true - release: - runs-on: ubuntu-latest - needs: build-binaries - steps: - - name: Checkout - uses: actions/checkout@v4 - - uses: depot/setup-action@v1 - - name: Download artifacts - uses: actions/download-artifact@v4 - with: - pattern: preevy-bin-* - path: ./preevy-bin - merge-multiple: true + # - name: Build using Docker (with depot) + # run: mkdir preevy-bin && depot build --project ${{ vars.DEPOT_PROJECT_ID }} --build-arg CLI_TARGET=${{ matrix.platform }}-${{ matrix.arch }} -f Dockerfile.cli --target=cli --output=type=tar,dest=./preevy-bin/preevy-${{ matrix.platform }}-${{ matrix.arch }}.tar --progress=plain --platform=linux/${{ matrix.arch == 'x64' && 'amd64' || matrix.arch }} . - - name: Release - uses: softprops/action-gh-release@v1 - with: - generate_release_notes: true - draft: ${{ !startsWith(github.ref, 'refs/tags/') }} - prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }} - files: | - ./preevy-bin/** + # - uses: apple-actions/import-codesign-certs@v2 + # if: ${{ matrix.platform == 'macos' }} + # with: + # p12-file-base64: ${{ secrets.APPLE_CERT_DATA }} + # p12-password: ${{ secrets.APPLE_CERT_PASS }} + + # - name: Sign mac binaries + # if: ${{ matrix.platform == 'macos' }} + # env: + # CERT_CN: ${{ vars.APPLE_CERT_CN }} + # run: | + # tar -xf ./preevy-bin/preevy-${{ matrix.platform }}-${{ matrix.arch }}.tar + # codesign --remove-signature ./preevy + # security find-identity -v + # codesign --verbose=4 --sign "$CERT_CN" ./preevy + # tar -cf ./preevy-bin/preevy-${{ matrix.platform }}-${{ matrix.arch }}.tar ./preevy + + # - name: Upload artifacts + # uses: actions/upload-artifact@v4 + # with: + # name: preevy-bin-${{ matrix.platform }}-${{ matrix.arch }} + # path: ./preevy-bin/** + + # release: + # runs-on: ubuntu-latest + # needs: build-binaries + # steps: + # - name: Checkout + # uses: actions/checkout@v4 + # - uses: depot/setup-action@v1 + # - name: Download artifacts + # uses: actions/download-artifact@v4 + # with: + # pattern: preevy-bin-* + # path: ./preevy-bin + # merge-multiple: true + + # - name: Release + # uses: softprops/action-gh-release@v1 + # with: + # generate_release_notes: true + # draft: ${{ !startsWith(github.ref, 'refs/tags/') }} + # prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }} + # files: | + # ./preevy-bin/** diff --git a/packages/cli/package.json b/packages/cli/package.json index d3100227..43063d35 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -63,7 +63,7 @@ "eslint-plugin-react": "^7.32.2", "jest": "29.7.0", "lint-staged": "^15.2.0", - "oclif": "^4.1.0", + "oclif": "^4.1.3", "pkg": "^5.8.1", "shx": "^0.3.3", "ts-node": "^10.9.1", @@ -92,7 +92,20 @@ "./dist/hooks/postrun/telemetry.js" ] }, - "topicSeparator": " " + "topicSeparator": " ", + "update": { + "node": { + "version": "18.17.1", + "options": [ + "--no-warnings=ExperimentalWarning" + ] + }, + "s3": { + "bucket": "releases.preevy.dev", + "host": "https://releases.preevy.dev", + "acl": "public-read" + } + } }, "pkg": { "assets": [ diff --git a/patches/oclif+4.1.3.patch b/patches/oclif+4.1.3.patch new file mode 100644 index 00000000..c5dae456 --- /dev/null +++ b/patches/oclif+4.1.3.patch @@ -0,0 +1,100 @@ +diff --git a/node_modules/oclif/lib/tarballs/bin.d.ts b/node_modules/oclif/lib/tarballs/bin.d.ts +index f8bc8c5..47111b8 100644 +--- a/node_modules/oclif/lib/tarballs/bin.d.ts ++++ b/node_modules/oclif/lib/tarballs/bin.d.ts +@@ -1,6 +1,7 @@ + import { Interfaces } from '@oclif/core'; +-export declare function writeBinScripts({ baseWorkspace, config, nodeVersion, }: { ++export declare function writeBinScripts({ baseWorkspace, config, nodeOptions, nodeVersion, }: { + baseWorkspace: string; + config: Interfaces.Config; ++ nodeOptions: string[]; + nodeVersion: string; + }): Promise; +diff --git a/node_modules/oclif/lib/tarballs/bin.js b/node_modules/oclif/lib/tarballs/bin.js +index f05f8a1..5f84952 100644 +--- a/node_modules/oclif/lib/tarballs/bin.js ++++ b/node_modules/oclif/lib/tarballs/bin.js +@@ -6,7 +6,7 @@ const fs = require("node:fs"); + const path = require("node:path"); + const node_util_1 = require("node:util"); + const exec = (0, node_util_1.promisify)(node_child_process_1.exec); +-async function writeBinScripts({ baseWorkspace, config, nodeVersion, }) { ++async function writeBinScripts({ baseWorkspace, config, nodeOptions, nodeVersion, }) { + const binPathEnvVar = config.scopedEnvVarKey('BINPATH'); + const redirectedEnvVar = config.scopedEnvVarKey('REDIRECTED'); + const clientHomeEnvVar = config.scopedEnvVarKey('OCLIF_CLIENT_HOME'); +@@ -21,12 +21,13 @@ if not "%${redirectedEnvVar}%"=="1" if exist "%LOCALAPPDATA%\\${bin}\\client\\bi + ) + + if not defined ${binPathEnvVar} set ${binPathEnvVar}="%~dp0${bin}.cmd" ++ + if exist "%~dp0..\\bin\\node.exe" ( +- "%~dp0..\\bin\\node.exe" "%~dp0..\\bin\\run" %* ++ "%~dp0..\\bin\\node.exe" ${`${nodeOptions.join(' ')} `}"%~dp0..\\bin\\run" %* + ) else if exist "%LOCALAPPDATA%\\oclif\\node\\node-${nodeVersion}.exe" ( +- "%LOCALAPPDATA%\\oclif\\node\\node-${nodeVersion}.exe" "%~dp0..\\bin\\run" %* ++ "%LOCALAPPDATA%\\oclif\\node\\node-${nodeVersion}.exe" ${`${nodeOptions.join(' ')} `}"%~dp0..\\bin\\run" %* + ) else ( +- node "%~dp0..\\bin\\run" %* ++ node ${`${nodeOptions.join(' ')} `}"%~dp0..\\bin\\run" %* + ) + `); + }; +@@ -73,9 +74,9 @@ else + exit 1 + fi + if [ "\$DEBUG" == "*" ]; then +- echoerr ${binPathEnvVar}="\$${binPathEnvVar}" "\$NODE" "\$DIR/run" "\$@" ++ echoerr ${binPathEnvVar}="\$${binPathEnvVar}" "\$NODE" ${`${nodeOptions.join(' ')} `}"\$DIR/run" "\$@" + fi +- "\$NODE" "\$DIR/run" "\$@" ++ "\$NODE" ${`${nodeOptions.join(' ')} `}"\$DIR/run" "\$@" + fi + `, { mode: 0o755 }); + }; +diff --git a/node_modules/oclif/lib/tarballs/build.js b/node_modules/oclif/lib/tarballs/build.js +index 89d6b65..874f27b 100644 +--- a/node_modules/oclif/lib/tarballs/build.js ++++ b/node_modules/oclif/lib/tarballs/build.js +@@ -201,7 +201,7 @@ async function build(c, options = {}) { + await extractCLI(options.tarball ?? (await packCLI())); + await updatePJSON(); + await addDependencies(); +- await (0, bin_1.writeBinScripts)({ baseWorkspace: c.workspace(), config, nodeVersion: c.nodeVersion }); ++ await (0, bin_1.writeBinScripts)({ baseWorkspace: c.workspace(), config, nodeOptions: c.nodeOptions, nodeVersion: c.nodeVersion }); + await pretarball(); + const targetsToBuild = c.targets.filter((t) => !options.platform || options.platform === t.platform); + if (options.parallel) { +diff --git a/node_modules/oclif/lib/tarballs/config.d.ts b/node_modules/oclif/lib/tarballs/config.d.ts +index 5523aa2..ed24112 100644 +--- a/node_modules/oclif/lib/tarballs/config.d.ts ++++ b/node_modules/oclif/lib/tarballs/config.d.ts +@@ -4,6 +4,7 @@ export interface BuildConfig { + config: Interfaces.Config; + dist(input: string): string; + gitSha: string; ++ nodeOptions: string[]; + nodeVersion: string; + root: string; + s3Config: BuildConfig['updateConfig']['s3'] & { +diff --git a/node_modules/oclif/lib/tarballs/config.js b/node_modules/oclif/lib/tarballs/config.js +index d567378..a1c19cf 100644 +--- a/node_modules/oclif/lib/tarballs/config.js ++++ b/node_modules/oclif/lib/tarballs/config.js +@@ -31,6 +31,7 @@ async function buildConfig(root, options = {}) { + const updateConfig = config.pjson.oclif.update || {}; + updateConfig.s3 = updateConfig.s3 || {}; + const nodeVersion = updateConfig.node.version || process.versions.node; ++ const nodeOptions = (0, util_1.castArray)(updateConfig.node.options ?? []); + const targets = (0, util_1.compact)(options.targets || updateConfig.node.targets || exports.TARGETS) + .filter((t) => { + if (t === 'darwin-arm64' && semver.lt(nodeVersion, '16.0.0')) { +@@ -47,6 +48,7 @@ async function buildConfig(root, options = {}) { + config, + dist: (...args) => path.join(config.root, 'dist', ...args), + gitSha: _gitSha, ++ nodeOptions, + nodeVersion, + root, + s3Config: updateConfig.s3, diff --git a/yarn.lock b/yarn.lock index 6e36ef59..51bb9b89 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2577,7 +2577,7 @@ resolved "https://registry.npmjs.org/@nx/nx-win32-x64-msvc/-/nx-win32-x64-msvc-17.2.6.tgz#07fde42a0fe1f8f103aa7afd1db83cb76a72951f" integrity sha512-LrJySMWrO5oWMrP4VOWM1hr3c4rtxHGCcRy19VwqvaAPDrnsg0qfPjv4q1C9YyIU8sj+T3oJs1yZdnNntlN8ew== -"@oclif/core@^2.15.0", "@oclif/core@^3.0.4", "@oclif/core@^3.11.0", "@oclif/core@^3.15.1": +"@oclif/core@^2.15.0", "@oclif/core@^3.15.1", "@oclif/core@^3.16.0": version "3.15.1" resolved "https://registry.npmjs.org/@oclif/core/-/core-3.15.1.tgz#e03fa775d658e76056150ac0c7b8097b6f51ab9c" integrity sha512-d4457zVo2agLoJG97CmdY6M3BeP5sogBP3BtP65hUvJH6wA6Us1hdY3UiPPtD/ZzZImq7cATVMABuCF9tM+rWA== @@ -2610,28 +2610,35 @@ wordwrap "^1.0.0" wrap-ansi "^7.0.0" -"@oclif/plugin-help@^5", "@oclif/plugin-help@^5.2.14": +"@oclif/plugin-help@^5": version "5.2.20" resolved "https://registry.yarnpkg.com/@oclif/plugin-help/-/plugin-help-5.2.20.tgz#4035a0ac231f95fb8e334da342175e3ca00f6abc" integrity sha512-u+GXX/KAGL9S10LxAwNUaWdzbEBARJ92ogmM7g3gDVud2HioCmvWQCDohNRVZ9GYV9oKwZ/M8xwd6a1d95rEKQ== dependencies: "@oclif/core" "^2.15.0" -"@oclif/plugin-not-found@^2.3.32": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@oclif/plugin-not-found/-/plugin-not-found-2.4.3.tgz#3d24095adb0f3876cb4bcfdfdcb775086cf6d4b5" - integrity sha512-nIyaR4y692frwh7wIHZ3fb+2L6XEecQwRDIb4zbEam0TvaVmBQWZoColQyWA84ljFBPZ8XWiQyTz+ixSwdRkqg== +"@oclif/plugin-help@^6.0.9": + version "6.0.10" + resolved "https://registry.npmjs.org/@oclif/plugin-help/-/plugin-help-6.0.10.tgz#3a38e94a3f431a2b398679a433ace76a2d0c320d" + integrity sha512-vgAcEVtwsI49H/TllBL/7YlQvUSjR3+nVxb0ipSmbHbEUw5p5q6fcNc3R+N9JHvaa4tc8tjyg35APZAKSaM6xw== dependencies: - "@oclif/core" "^2.15.0" - chalk "^4" + "@oclif/core" "^3.16.0" + +"@oclif/plugin-not-found@^3.0.7": + version "3.0.8" + resolved "https://registry.npmjs.org/@oclif/plugin-not-found/-/plugin-not-found-3.0.8.tgz#d694a9308993703a1cbacbab7f5625315f0169ea" + integrity sha512-sfh7jFc+1vFsF/+9ghF3pVul9xFJ4Hu1JI+KzkDjgWkfVSyPSEE+s6Hfn2z6lCXkwSKQ5lJATuZmafnGes7NGg== + dependencies: + "@oclif/core" "^3.16.0" + chalk "^5.3.0" fast-levenshtein "^3.0.0" -"@oclif/plugin-warn-if-update-available@^3.0.0": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@oclif/plugin-warn-if-update-available/-/plugin-warn-if-update-available-3.0.3.tgz#0609096a5272ffc97124111453825a33e899ae6f" - integrity sha512-p9Ai5olqj52NTndtntFbVreRCtJg9dgnfAl5Zi6hmIpgzVtPYDxLwa3PnMufKFc3fUkno5xnJ0TsKfxt0QruDw== +"@oclif/plugin-warn-if-update-available@^3.0.8": + version "3.0.9" + resolved "https://registry.npmjs.org/@oclif/plugin-warn-if-update-available/-/plugin-warn-if-update-available-3.0.9.tgz#f4346f4040adf71d0a120381de2fe4c8411896fd" + integrity sha512-6XjYNJWWu6B4LyW73hzuM9Ihb23WamrABZhwYVJTVMBHdU30pRa1i3rvHCPfmn5c4iv8ZXudS/0zCNuhR121ng== dependencies: - "@oclif/core" "^3.11.0" + "@oclif/core" "^3.16.0" chalk "^5.3.0" debug "^4.1.0" http-call "^5.2.2" @@ -5448,7 +5455,7 @@ chalk@4.1.0: ansi-styles "^4.1.0" supports-color "^7.1.0" -chalk@4.1.2, chalk@^4, chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2: +chalk@4.1.2, chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== @@ -10985,15 +10992,15 @@ obliterator@^2.0.1: resolved "https://registry.yarnpkg.com/obliterator/-/obliterator-2.0.4.tgz#fa650e019b2d075d745e44f1effeb13a2adbe816" integrity sha512-lgHwxlxV1qIg1Eap7LgIeoBWIMFibOjbrYPIPJZcI1mmGAI2m3lNYpK12Y+GBdPQ0U1hRwSord7GIaawz962qQ== -oclif@^4.1.0: - version "4.1.0" - resolved "https://registry.npmjs.org/oclif/-/oclif-4.1.0.tgz#486004caf6da8af9f5bdda681a616b5b2c180b45" - integrity sha512-4E6z1HOdUYXHu/cbbSv0gnbFJfR9BGc9Oa+e9l8SkRoicGnrEPMpuZyY2vxWPGwMndN6ijxxuFlVmw1/j+MJpg== +oclif@^4.1.3: + version "4.1.3" + resolved "https://registry.npmjs.org/oclif/-/oclif-4.1.3.tgz#07d3a6b16ff7e2e7c3fd06117fd745655c44abce" + integrity sha512-9OmzHaOmn58BZZt8S2USh1gW5RFfa69cDfOtXCWUyYrcRdO4wIJ3DPb0xZ3UxHHbPZKsDImuP/A54weFMH2izw== dependencies: - "@oclif/core" "^3.0.4" - "@oclif/plugin-help" "^5.2.14" - "@oclif/plugin-not-found" "^2.3.32" - "@oclif/plugin-warn-if-update-available" "^3.0.0" + "@oclif/core" "^3.16.0" + "@oclif/plugin-help" "^6.0.9" + "@oclif/plugin-not-found" "^3.0.7" + "@oclif/plugin-warn-if-update-available" "^3.0.8" async-retry "^1.3.3" aws-sdk "^2.1231.0" change-case "^4"