diff --git a/.gitignore b/.gitignore index d4052b24c7559dc8e52c2325659edca55560f425..4d8e769dbbf9e6c2704e8e91406545586bfee133 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ .crush .chunkhound lune +dist/ .task diff --git a/Taskfile.yaml b/Taskfile.yaml index fc443e6cc98910546cd1d1846b962b21f64c529c..64bfd1ef1b530ea06fc46149621bc9648eaec7ab 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -83,13 +83,66 @@ tasks: clean: desc: Remove build artifacts cmds: - - rm -rf lune + - rm -rf lune dist/ clean-all: desc: Remove build artifacts and config.toml cmds: - rm -rf lune config.toml + release:build: + desc: Cross-compile for all release targets + vars: + TARGETS: >- + linux/amd64 + linux/arm64 + darwin/amd64 + darwin/arm64 + windows/amd64 + freebsd/amd64 + cmds: + - rm -rf dist + - mkdir -p dist + - for: {var: TARGETS, split: " "} + cmd: | + os=$(echo {{.ITEM}} | cut -d/ -f1) + arch=$(echo {{.ITEM}} | cut -d/ -f2) + ext=""; if [ "$os" = "windows" ]; then ext=".exe"; fi + echo "Building ${os}/${arch}..." + GOOS=${os} GOARCH=${arch} go build \ + -o "dist/lune-{{.VERSION}}-${os}-${arch}${ext}" \ + -ldflags "-s -w -X main.version={{.VERSION}}" + + release:pack: + desc: Compress release binaries with UPX where supported + vars: + # UPX 5.x dropped macOS support; windows/amd64 is PE32 only and + # freebsd/amd64 is ELF32 only, so only Linux targets are packed. + PACK_TARGETS: >- + linux-amd64 + linux-arm64 + cmds: + - for: {var: PACK_TARGETS, split: " "} + cmd: | + bin="dist/lune-{{.VERSION}}-{{.ITEM}}" + if [ -f "$bin" ]; then + echo "Packing {{.ITEM}}..." + upx -q "$bin" + fi + + release:upload: + desc: Upload release artifacts + cmds: + - fish -c 'release upload lune {{.VERSION}} --latest dist/*' + + release:all: + desc: Tag, build, pack, and upload a release + cmds: + - task release + - task release:build + - task release:pack + - task release:upload + release: desc: Interactive release workflow vars: