Release #5
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| if: github.server_url == 'https://github.com' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.26' | |
| - name: Run tests | |
| run: go test ./... | |
| - name: Build binaries | |
| run: | | |
| VERSION=${GITHUB_REF_NAME} | |
| LDFLAGS="-s -w -X main.version=${VERSION}" | |
| targets=( | |
| "linux/amd64" | |
| "linux/arm64" | |
| "linux/arm" | |
| "darwin/amd64" | |
| "darwin/arm64" | |
| "windows/amd64" | |
| "freebsd/amd64" | |
| "freebsd/arm64" | |
| ) | |
| mkdir -p dist | |
| for target in "${targets[@]}"; do | |
| GOOS="${target%/*}" | |
| GOARCH="${target#*/}" | |
| output="dist/dssh-${GOOS}-${GOARCH}" | |
| if [ "$GOOS" = "windows" ]; then | |
| output="dist/dssh.exe" | |
| fi | |
| echo "Building ${GOOS}/${GOARCH}..." | |
| CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" \ | |
| go build -ldflags="$LDFLAGS" -o "$output" ./cmd/dssh/ | |
| done | |
| - name: Create tar.gz archives for macOS binaries | |
| run: | | |
| VERSION=${GITHUB_REF_NAME} | |
| for arch in amd64 arm64; do | |
| tar -czf "dist/dssh-darwin-${arch}.tar.gz" -C dist "dssh-darwin-${arch}" | |
| done | |
| - name: Compress Linux binaries with UPX | |
| run: | | |
| sudo apt-get update && sudo apt-get install -y upx | |
| for f in dist/dssh-linux-*; do | |
| echo "Compressing $f..." | |
| upx --best "$f" || echo "UPX failed for $f, using uncompressed" | |
| done | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| generate_release_notes: true | |
| files: dist/* |