From ce0e2b332638a1cc1a1e7789a68d78be4efb9c02 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 19:14:05 -0800 Subject: [PATCH 1/5] release: On windows use .exe and alter README Closes #388 --- ci/release/_build.sh | 16 ++++++++++------ ci/release/template/README.md.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/ci/release/_build.sh b/ci/release/_build.sh index 3f8b1663d..02c58f9db 100755 --- a/ci/release/_build.sh +++ b/ci/release/_build.sh @@ -4,19 +4,23 @@ cd -- "$(dirname "$0")/../.." . ./ci/sub/lib.sh sh_c mkdir -p "$HW_BUILD_DIR" -sh_c rsync --recursive --perms --delete \ - --human-readable --copy-links ./ci/release/template/ "$HW_BUILD_DIR/" -VERSION=$VERSION sh_c eval "'$HW_BUILD_DIR/README.md.sh'" \> "'$HW_BUILD_DIR/README.md'" -sh_c rm -f "$HW_BUILD_DIR/README.md.sh" -sh_c find "$HW_BUILD_DIR" -exec touch {} \\\; +sh_c cp ./ci/release/template/LICENSE.txt "$HW_BUILD_DIR" +sh_c cp ./ci/release/template/Makefile "$HW_BUILD_DIR" +sh_c cp -R ./ci/release/template/man "$HW_BUILD_DIR" +sh_c cp -Rf ./ci/release/template/scripts "$HW_BUILD_DIR" +sh_c VERSION="$VERSION" ./ci/release/template/README.md.sh \> "'$HW_BUILD_DIR/README.md'" ensure_goos ensure_goarch sh_c mkdir -p "$HW_BUILD_DIR/bin" -sh_c CGO_ENABLED=0 go build -trimpath \ +sh_c GOOS="$GOOS" GOARCH="$GOARCH" CGO_ENABLED=0 go build -trimpath \ -ldflags "'-X oss.terrastruct.com/d2/lib/version.Version=$VERSION'" \ -o "$HW_BUILD_DIR/bin/d2" . +if [ "$GOOS" = windows ]; then + sh_c mv "$HW_BUILD_DIR/bin/d2" "$HW_BUILD_DIR/bin/d2.exe" +fi + ARCHIVE=$PWD/$ARCHIVE cd "$(dirname "$HW_BUILD_DIR")" sh_c tar -czf "$ARCHIVE" "$(basename "$HW_BUILD_DIR")" diff --git a/ci/release/template/README.md.sh b/ci/release/template/README.md.sh index 2c0cdfb35..99411d923 100755 --- a/ci/release/template/README.md.sh +++ b/ci/release/template/README.md.sh @@ -1,5 +1,7 @@ #!/bin/sh set -eu +cd -- "$(dirname "$0")/../../.." +. ./ci/sub/lib.sh cat < Date: Wed, 7 Dec 2022 19:27:06 -0800 Subject: [PATCH 2/5] release/next.md: Update --- ci/release/changelogs/next.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 84d6618aa..3fadfa006 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -2,6 +2,8 @@ #### Improvements 🧹 +- The Windows release binary is now suffixed correctly with `.exe` [#388](https://github.com/terrastruct/d2/issues/388) + #### Bugfixes ⛑️ -- Fixed sequence diagram span size for self-edges [#397](https://github.com/terrastruct/d2/pull/397) \ No newline at end of file +- Fixed sequence diagram span size for self-edges [#397](https://github.com/terrastruct/d2/pull/397) From c2bcb3a93e1c2472b008bf7f4fb94e49c20d97e3 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 19:30:04 -0800 Subject: [PATCH 3/5] release/template/README.md: Document easiest way to use windows --- ci/release/template/README.md.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ci/release/template/README.md.sh b/ci/release/template/README.md.sh index 99411d923..115bba209 100755 --- a/ci/release/template/README.md.sh +++ b/ci/release/template/README.md.sh @@ -19,14 +19,18 @@ ensure_os if [ "$OS" = windows ]; then cat < + +You can install on Windows with [MSYS2](https://www.msys2.org/) which emulates a Linux +shell for Windows. It also enables d2 to show colors in its output. But if you must install on Windows without MSYS2, for now you'll have to add the d2 binary -in \`./bin/d2.exe\` to your \`\$PATH\` manually. You can also add the \`./bin\` directory -to your \`\$PATH\`. +in \`./bin/d2.exe\` to your \`\$PATH\` manually. Or you can add the \`./bin\` directory to +your \`\$PATH\`. See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows See https://github.com/terrastruct/d2/blob/master/docs/INSTALL.md#windows From 31346482731fb6ad4cb605e558a5f3a99cc2f4ae Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 19:32:26 -0800 Subject: [PATCH 4/5] install.md: Document easiest way to use windows --- ci/release/template/README.md.sh | 5 ++++- docs/INSTALL.md | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ci/release/template/README.md.sh b/ci/release/template/README.md.sh index 115bba209..6bfcfdb50 100755 --- a/ci/release/template/README.md.sh +++ b/ci/release/template/README.md.sh @@ -23,7 +23,7 @@ We currently do not have a .msi for automatic installation on Windows so this re structured the same as our Unix releases. Easiest way to use d2 on Windows is to just cd into the bin directory of this release -and invoke d2 like ./d2.exe +and invoke d2 like \`./d2.exe \` You can install on Windows with [MSYS2](https://www.msys2.org/) which emulates a Linux shell for Windows. It also enables d2 to show colors in its output. @@ -32,6 +32,9 @@ But if you must install on Windows without MSYS2, for now you'll have to add the in \`./bin/d2.exe\` to your \`\$PATH\` manually. Or you can add the \`./bin\` directory to your \`\$PATH\`. +We intend to have a \`.msi\` release installer sometime soon that handles putting \`d2\` into +your \`\$PATH\` for you. + See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows See https://github.com/terrastruct/d2/blob/master/docs/INSTALL.md#windows EOF diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 7d29525d2..c4c0b7cd4 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -158,8 +158,13 @@ the `d2` binary. d2 builds and runs on Windows: We have prebuilt standalone releases for Windows though they're structured in the same way -as our Unix releases. So after extracting a release, you'll have to manually put the d2 -binary into your `$PATH` or add the `bin` directory of the release into your `$PATH`. +as our Unix releases. + +Easiest way to use d2 on Windows is to just cd into the bin directory of the release after +extracting it and invoking d2 like `./d2.exe ` + +For installation, you'll have to manually put the d2 binary into your `$PATH` or add the +`bin` directory of the release into your `$PATH`. See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows From 44c11a13ce173292b488a5ab451dd7800eef23f3 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 19:42:58 -0800 Subject: [PATCH 5/5] Update windows install docs --- ci/release/template/README.md.sh | 24 ++++++++++++++---------- docs/INSTALL.md | 16 ++++++++-------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/ci/release/template/README.md.sh b/ci/release/template/README.md.sh index 6bfcfdb50..d52d96716 100755 --- a/ci/release/template/README.md.sh +++ b/ci/release/template/README.md.sh @@ -19,23 +19,27 @@ ensure_os if [ "$OS" = windows ]; then cat <\` +Easiest way to use d2 on Windows is to just \`chdir\` into the bin directory of this release +and invoke d2 like \`./d2 \` -You can install on Windows with [MSYS2](https://www.msys2.org/) which emulates a Linux -shell for Windows. It also enables d2 to show colors in its output. +For installation you'll have to add the \`./bin/d2.exe\` binary to your \`\$PATH\`. Or add +the \`./bin\` directory of this release to your \`\$PATH\`. -But if you must install on Windows without MSYS2, for now you'll have to add the d2 binary -in \`./bin/d2.exe\` to your \`\$PATH\` manually. Or you can add the \`./bin\` directory to -your \`\$PATH\`. +See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows + +Then you'll be able to call \`d2\` from the commandline in \`cmd.exe\` or \`pwsh.exe\`. We intend to have a \`.msi\` release installer sometime soon that handles putting \`d2\` into your \`\$PATH\` for you. -See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows +You can also use \`make install\` to install on Windows after first installing +[MSYS2](https://www.msys2.org/) which emulates a Linux shell for Windows. Its terminal +also enables d2 to show colors in its output. The manpage will also become accessible +with \`man d2\`. + See https://github.com/terrastruct/d2/blob/master/docs/INSTALL.md#windows EOF fi diff --git a/docs/INSTALL.md b/docs/INSTALL.md index c4c0b7cd4..afca4df39 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -140,7 +140,7 @@ go install oss.terrastruct.com/d2@latest ### Source Release -To install a proper release from source clone the repository and then: +To install a release from source clone the repository and then: ```sh ./ci/release/build.sh --install @@ -149,9 +149,9 @@ To install a proper release from source clone the repository and then: ``` Installing a real release will also install manpages and in the future other assets like -fonts and icons. Furthermore, when installing a non versioned commit, installing a proper -release will ensure that `d2 --version` works correctly by embedding the commit hash into -the `d2` binary. +fonts and icons. Furthermore, when installing a non versioned commit, installing a release +will ensure that `d2 --version` works correctly by embedding the commit hash into the `d2` +binary. ## Windows @@ -160,10 +160,10 @@ d2 builds and runs on Windows: We have prebuilt standalone releases for Windows though they're structured in the same way as our Unix releases. -Easiest way to use d2 on Windows is to just cd into the bin directory of the release after -extracting it and invoking d2 like `./d2.exe ` +Easiest way to use d2 on Windows is to just `chdir` into the bin directory of the release +and invoke d2 like `./d2 ` -For installation, you'll have to manually put the d2 binary into your `$PATH` or add the +For installation, you'll have to put the `bin/d2.exe` binary into your `$PATH` or add the `bin` directory of the release into your `$PATH`. See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows @@ -182,7 +182,7 @@ Bash](https://gitforwindows.org/#bash) (Git Bash is based on MSYS2) for an impro terminal experience. MSYS2 provides a unix style shell environment that is native to Windows (unlike -[Cygwin](https://www.cygwin.com/)). MSYS2 allows `install.sh` to work, enables proper +[Cygwin](https://www.cygwin.com/)). MSYS2 allows `install.sh` to work, enables automatic installation of our standalone releases via `make install` and makes the manpage accessible via `man d2`.