From f64b37497b5fb4a7c08be17d721334665e40548a Mon Sep 17 00:00:00 2001 From: Korenevskiy Denis Date: Thu, 29 Aug 2024 18:15:49 +0300 Subject: [PATCH] feat: use multiroot package settings --- package-lock.json | 12 +++++----- package.json | 59 +++++++++++++++++++++++++++++++++++++--------- pl.package.yaml | 8 ------- scripts/build.sh | 20 ++++------------ scripts/publish.sh | 43 --------------------------------- 5 files changed, 59 insertions(+), 83 deletions(-) delete mode 100644 pl.package.yaml delete mode 100755 scripts/publish.sh diff --git a/package-lock.json b/package-lock.json index d9f5988..b2d7ab6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@milaboratory/small-binaries", - "version": "1.7.2", + "version": "1.7.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@milaboratory/small-binaries", - "version": "1.7.2", + "version": "1.7.3", "license": "UNLICENSED", "devDependencies": { - "@milaboratory/pl-package-builder": "^2.4.0" + "@milaboratory/pl-package-builder": "^2.6.1" } }, "node_modules/@aws-crypto/crc32": { @@ -1039,9 +1039,9 @@ } }, "node_modules/@milaboratory/pl-package-builder": { - "version": "2.4.0", - "resolved": "https://npm.pkg.github.com/download/@milaboratory/pl-package-builder/2.4.0/454584cc069b28c2034731d3ed2ffd2db12334c0", - "integrity": "sha512-T65FcIWE1sT+3TO164dZ27cH4v43fFH4vxeGrOGqGxn5ttb0xC6BIzqR0PhprbOqFa96xSAyziOPooVagOVSTw==", + "version": "2.6.1", + "resolved": "https://npm.pkg.github.com/download/@milaboratory/pl-package-builder/2.6.1/e06473141c6ec994f922deeb4b710ece9d4287d4", + "integrity": "sha512-a3meDyVIU3zqF0JDta938K1wapPcAZBVMC4Ug8SUFh0YUeRKodBKm9YtECOM6pzKB4u+UwoEk7ZMV6WHBoFq2A==", "dev": true, "dependencies": { "@aws-sdk/client-s3": "^3.623.0", diff --git a/package.json b/package.json index 3be2af4..c34cb3e 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,21 @@ { "name": "@milaboratory/small-binaries", - "version": "1.7.2", + "version": "1.7.3", "description": "Small cross-platform binaries, like 'sleep' or 'hello-world', suitable for test needs", "scripts": { "cleanup": "rm -rf ./pkg-*.tgz && rm -rf ./build/ && rm -rf ./dist/", - "build": "true", + "build": "npm run pkg:build", + "pkg:build": "./scripts/build.sh", - "release:packages": "./scripts/publish.sh", - "release:descriptors": "pl-pkg publish descriptors", - "release": "npm run pkg:build && npm run release:packages && npm run release:descriptors" + "pkg:sign": "pl-pkg sign --all-platforms --sign-util='gcloud-kms-sign'", + "pkg:publish": "pl-pkg publish packages --all-platforms", + "pkg:release": "npm run pkg:build && npm run pkg:sign && npm run pkg:publish", + + "descriptors:build": "pl-pkg build descriptors", + "descriptors:publish": "pl-pkg publish descriptors", + "descriptors:release": "npm run descriptors:build && npm run descriptors:publish", + + "release": "npm run pkg:release && npm run descriptors:release" }, "block-software": { "packages": { @@ -17,7 +24,13 @@ "registry": { "name": "milaboratories" }, "name": "common/hello-world", "version": "1.6.3", - "root": "./nonexistent/", + "roots": { + "linux-x64": "./build/linux-x64/hello-world", + "linux-aarch64": "./build/linux-aarch64/hello-world", + "macosx-x64": "./build/macosx-x64/hello-world", + "macosx-aarch64": "./build/macosx-aarch64/hello-world", + "windows-x64": "./build/windows-x64/hello-world" + }, "entrypoints": { "hello-world": { "cmd": [ "{pkg}/main" ] } } @@ -28,7 +41,13 @@ "registry": { "name": "milaboratories" }, "name": "common/sleep", "version": "1.6.3", - "root": "./nonexistent/", + "roots": { + "linux-x64": "./build/linux-x64/sleep", + "linux-aarch64": "./build/linux-aarch64/sleep", + "macosx-x64": "./build/macosx-x64/sleep", + "macosx-aarch64": "./build/macosx-aarch64/sleep", + "windows-x64": "./build/windows-x64/sleep" + }, "entrypoints": { "sleep": { "cmd": [ "{pkg}/main" ] } } @@ -39,7 +58,13 @@ "registry": { "name": "milaboratories" }, "name": "common/guided-command", "version": "1.6.3", - "root": "./nonexistent/", + "roots": { + "linux-x64": "./build/linux-x64/guided-command", + "linux-aarch64": "./build/linux-aarch64/guided-command", + "macosx-x64": "./build/macosx-x64/guided-command", + "macosx-aarch64": "./build/macosx-aarch64/guided-command", + "windows-x64": "./build/windows-x64/guided-command" + }, "entrypoints": { "guided-command": { "cmd": [ "{pkg}/main" ] } } @@ -50,7 +75,13 @@ "registry": { "name": "milaboratories" }, "name": "common/read-file-to-stdout-with-sleep", "version": "1.6.3", - "root": "./nonexistent/", + "roots": { + "linux-x64": "./build/linux-x64/read-file-to-stdout-with-sleep", + "linux-aarch64": "./build/linux-aarch64/read-file-to-stdout-with-sleep", + "macosx-x64": "./build/macosx-x64/read-file-to-stdout-with-sleep", + "macosx-aarch64": "./build/macosx-aarch64/read-file-to-stdout-with-sleep", + "windows-x64": "./build/windows-x64/read-file-to-stdout-with-sleep" + }, "entrypoints": { "read-file-to-stdout-with-sleep": { "cmd": [ "{pkg}/main" ] } } @@ -62,7 +93,13 @@ "name": "common/runenv-java-stub", "version": "1.0.1", "type": "java", - "root": "./nonexistent/", + "roots": { + "linux-x64": "./build/linux-x64/runenv-java-stub", + "linux-aarch64": "./build/linux-aarch64/runenv-java-stub", + "macosx-x64": "./build/macosx-x64/runenv-java-stub", + "macosx-aarch64": "./build/macosx-aarch64/runenv-java-stub", + "windows-x64": "./build/windows-x64/runenv-java-stub" + }, "binDir": ".", "entrypointName": "runenv-java-stub" } @@ -74,6 +111,6 @@ ], "license": "UNLICENSED", "devDependencies": { - "@milaboratory/pl-package-builder": "^2.4.0" + "@milaboratory/pl-package-builder": "^2.6.1" } } diff --git a/pl.package.yaml b/pl.package.yaml deleted file mode 100644 index 979a370..0000000 --- a/pl.package.yaml +++ /dev/null @@ -1,8 +0,0 @@ -binary: - registry: - name: "milaboratories" - storageURL: s3://milab-euce1-prod-pkgs-s3-platforma-registry/pub/?region=eu-central-1 - - name: "common/sleep" - root: "./build/" - cmd: "main" diff --git a/scripts/build.sh b/scripts/build.sh index 3a2712e..a6776a3 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -17,22 +17,13 @@ build_binary() { local _arch_reg="${5}" local _ext="${6:-}" - local _group="${_os_go}-${_arch_go}" + local _platform="${_os_reg}-${_arch_reg}" printf "## os='%s', arch='%s':\n" "${_os_go}" "${_arch_go}" - env GOOS="${_os_go}" GOARCH="${_arch_go}" \ go build \ - -o "${BUILD_DIR}/${_group}/${_bin_name}/main${_ext}" \ + -o "${BUILD_DIR}/${_platform}/${_bin_name}/main${_ext}" \ "./${_bin_name}.go" - printf "\n" - - pl-pkg build packages \ - --package-id="${_bin_name}" \ - --os="${_os_reg}" \ - --arch="${_arch_reg}" \ - --content-root="${BUILD_DIR}/${_group}/${_bin_name}/" - printf "\n" } build_binaries() { @@ -45,7 +36,7 @@ build_binaries() { # amd64 -> x64 # arm64 -> aarch64 - printf "\n# Building '%s'...\n\n" "${_bin_name}" + printf "\n# Building '%s'...\n" "${_bin_name}" build_binary "${_bin_name}" "windows" "amd64" "windows" "x64" ".exe" @@ -54,9 +45,6 @@ build_binaries() { build_binary "${_bin_name}" "darwin" "amd64" "macosx" "x64" build_binary "${_bin_name}" "darwin" "arm64" "macosx" "aarch64" - - pl-pkg build descriptors \ - --package-id="${_bin_name}" } rm -rf "${script_dir}/${BUILD_DIR}" @@ -67,6 +55,8 @@ build_binaries "guided-command" build_binaries "sleep" build_binaries "read-file-to-stdout-with-sleep" +pl-pkg build packages --all-platforms + echo "" echo "All binaries are saved to '$(pwd)/${BUILD_DIR}'" echo "All packages are saved to '$(pwd)/pkg-*.tgz' archives" diff --git a/scripts/publish.sh b/scripts/publish.sh deleted file mode 100755 index c1def88..0000000 --- a/scripts/publish.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o nounset -set -o pipefail - -: "${RELEASE_DIR:="release"}" - -script_dir="$(cd "$(dirname "${0}")" && pwd)" -cd "${script_dir}/.." - -publish_package() { - local _bin_name="${1}" - local _os="${2}" - local _arch="${3}" - - pl-pkg publish packages \ - --package-id="${_bin_name}" \ - --skip-existing-packages \ - --os="${_os}" \ - --arch="${_arch}" - printf "\n" -} - -publish_packages() { - local _bin_name="${1}" - - printf "Publishing '%s'...\n\n" "${_bin_name}" - - publish_package "${_bin_name}" "windows" "x64" - - publish_package "${_bin_name}" "linux" "x64" - publish_package "${_bin_name}" "linux" "aarch64" - - publish_package "${_bin_name}" "macosx" "x64" - publish_package "${_bin_name}" "macosx" "aarch64" -} - -publish_packages "runenv-java-stub" -publish_packages "hello-world" -publish_packages "guided-command" -publish_packages "sleep" -publish_packages "read-file-to-stdout-with-sleep"