release: On windows use .exe and alter README

Closes #388
This commit is contained in:
Anmol Sethi 2022-12-07 19:14:05 -08:00
parent cb414e5382
commit ce0e2b3326
No known key found for this signature in database
GPG key ID: 25BC68888A99A8BA
2 changed files with 37 additions and 6 deletions

View file

@ -4,19 +4,23 @@ cd -- "$(dirname "$0")/../.."
. ./ci/sub/lib.sh . ./ci/sub/lib.sh
sh_c mkdir -p "$HW_BUILD_DIR" sh_c mkdir -p "$HW_BUILD_DIR"
sh_c rsync --recursive --perms --delete \ sh_c cp ./ci/release/template/LICENSE.txt "$HW_BUILD_DIR"
--human-readable --copy-links ./ci/release/template/ "$HW_BUILD_DIR/" sh_c cp ./ci/release/template/Makefile "$HW_BUILD_DIR"
VERSION=$VERSION sh_c eval "'$HW_BUILD_DIR/README.md.sh'" \> "'$HW_BUILD_DIR/README.md'" sh_c cp -R ./ci/release/template/man "$HW_BUILD_DIR"
sh_c rm -f "$HW_BUILD_DIR/README.md.sh" sh_c cp -Rf ./ci/release/template/scripts "$HW_BUILD_DIR"
sh_c find "$HW_BUILD_DIR" -exec touch {} \\\; sh_c VERSION="$VERSION" ./ci/release/template/README.md.sh \> "'$HW_BUILD_DIR/README.md'"
ensure_goos ensure_goos
ensure_goarch ensure_goarch
sh_c mkdir -p "$HW_BUILD_DIR/bin" 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'" \ -ldflags "'-X oss.terrastruct.com/d2/lib/version.Version=$VERSION'" \
-o "$HW_BUILD_DIR/bin/d2" . -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 ARCHIVE=$PWD/$ARCHIVE
cd "$(dirname "$HW_BUILD_DIR")" cd "$(dirname "$HW_BUILD_DIR")"
sh_c tar -czf "$ARCHIVE" "$(basename "$HW_BUILD_DIR")" sh_c tar -czf "$ARCHIVE" "$(basename "$HW_BUILD_DIR")"

View file

@ -1,5 +1,7 @@
#!/bin/sh #!/bin/sh
set -eu set -eu
cd -- "$(dirname "$0")/../../.."
. ./ci/sub/lib.sh
cat <<EOF cat <<EOF
# d2 # d2
@ -7,6 +9,31 @@ cat <<EOF
For docs, more installation options and the source code see https://oss.terrastruct.com/d2 For docs, more installation options and the source code see https://oss.terrastruct.com/d2
version: $VERSION version: $VERSION
os: $OS
arch: $ARCH
Built with $(go version | grep -o 'go[^ ]\+').
EOF
ensure_os
if [ "$OS" = windows ]; then
cat <<EOF
We currently do not have a .msi for proper installation on Windows so this release is
structured the same as our Unix releases. You can still install on Windows still though
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\`.
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
fi
cat <<EOF
## Install ## Install