diff --git a/ci/release/README.md b/ci/release/README.md index 8833ecd0e..4530983e4 100644 --- a/ci/release/README.md +++ b/ci/release/README.md @@ -23,6 +23,8 @@ it depends on from ../sub/lib. > variables as we must compile d2 directly on each release target to include dagre. > See https://github.com/terrastruct/d2/issues/31 +Use `--host-only` to build only the release for the host's OS-ARCH pair. + ### build_docker.sh Helper script called by build.sh to build D2 on each linux runner inside Docker. diff --git a/ci/release/_install.sh b/ci/release/_install.sh index 08611160e..dd0f92f05 100755 --- a/ci/release/_install.sh +++ b/ci/release/_install.sh @@ -6,4 +6,71 @@ cd -- "$(dirname "$0")/../.." . ./ci/sub/lib/flag.sh cd - -doing installation here +help() { + arg0="$0" + if [ "$0" = sh ]; then + arg0="curl -fsSL https://d2lang.com/install.sh | sh -s --" + fi + + cat </d2-.tar.gz @@ -14,15 +14,24 @@ commit if available. Flags: ---rebuild: By default build.sh will avoid rebuilding finished assets if they - already exist but if you changed something and need to force rebuild, use - this flag. ---local: By default build.sh uses \$TSTRUCT_MACOS_AMD64_BUILDER, - \$TSTRUCT_MACOS_ARM64_BUILDER, \$TSTRUCT_LINUX_AMD64_BUILDER and - \$TSTRUCT_LINUX_ARM64_BUILDER to build the release archives. It's required for - now due to the following issue: https://github.com/terrastruct/d2/issues/31 - With --local, build.sh will cross compile locally. - warning: This is only for testing purposes, do not use in production! +--rebuild + By default build.sh will avoid rebuilding finished assets if they already exist but if you + changed something and need to force rebuild, use this flag. + +--local + By default build.sh uses \$TSTRUCT_MACOS_AMD64_BUILDER, \$TSTRUCT_MACOS_ARM64_BUILDER, + \$TSTRUCT_LINUX_AMD64_BUILDER and \$TSTRUCT_LINUX_ARM64_BUILDER to build the release + archives. It's required for now due to the following issue: + https://github.com/terrastruct/d2/issues/31 With --local, build.sh will cross compile + locally. warning: This is only for testing purposes, do not use in production! + +--host-only + Use to build the release archive for the host OS-ARCH only. All logging is done to stderr + so in a script you can read from stdout to get the path to the release archive. + +--run=regex + Use to run only the OS-ARCH jobs that match the given regex. e.g. --run=linux only runs + the linux jobs. --run=linux-amd64 only runs the linux-amd64 job. EOF } @@ -52,6 +61,10 @@ main() { flag_reqarg && shift "$FLAGSHIFT" JOBFILTER="$FLAGARG" ;; + host-only) + flag_noarg && shift "$FLAGSHIFT" + HOST_ONLY=1 + ;; '') shift "$FLAGSHIFT" break @@ -66,6 +79,12 @@ main() { flag_errusage "no arguments are accepted" fi + if [ -n "${HOST_ONLY-}" ]; then + runjob $(os)-$(arch) "OS=$(os) ARCH=$(arch) build" & + waitjobs + return 0 + fi + runjob linux-amd64 'OS=linux ARCH=amd64 build' & runjob linux-arm64 'OS=linux ARCH=arm64 build' & runjob macos-amd64 'OS=macos ARCH=amd64 build' & @@ -99,13 +118,13 @@ build() { RHOST=$TSTRUCT_LINUX_ARM64_BUILDER build_rhost ;; *) - COLOR=3 logp warn "no builder for OS=$OS, building locally..." + warn "no builder for OS=$OS, building locally..." build_local ;; esac ;; *) - COLOR=3 logp warn "no builder for OS=$OS, building locally..." + warn "no builder for OS=$OS, building locally..." build_local ;; esac diff --git a/ci/sub b/ci/sub index d064c179a..30d7e137c 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit d064c179a5c102c4f54cf63be058461b21b8e28a +Subproject commit 30d7e137c97f2d2e2960a52adadc5019a02bfa30 diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index e8f5cf3c4..958ed355b --- a/install.sh +++ b/install.sh @@ -152,6 +152,14 @@ logcat() { COLOR=5 catp log "$@" >&2 } +warn() { + COLOR=3 logp warn "$@" +} + +warnf() { + COLOR=3 logfp warn "$@" +} + sh_c() { COLOR=3 logp exec "$*" if [ -z "${DRYRUN-}" ]; then @@ -347,4 +355,71 @@ EOF set -eu -doing installation here +help() { + arg0="$0" + if [ "$0" = sh ]; then + arg0="curl -fsSL https://d2lang.com/install.sh | sh -s --" + fi + + cat <