File tree Expand file tree Collapse file tree 6 files changed +702
-15
lines changed
Expand file tree Collapse file tree 6 files changed +702
-15
lines changed Original file line number Diff line number Diff line change @@ -9,29 +9,77 @@ permissions:
99 contents : write
1010
1111jobs :
12- release :
12+ build :
1313 runs-on : ubuntu-latest
14+ strategy :
15+ matrix :
16+ include :
17+ - goos : linux
18+ goarch : amd64
19+ - goos : linux
20+ goarch : arm64
21+ - goos : linux
22+ goarch : arm
23+ - goos : darwin
24+ goarch : amd64
25+ - goos : darwin
26+ goarch : arm64
27+ - goos : windows
28+ goarch : amd64
29+
1430 steps :
1531 - uses : actions/checkout@v4
1632
1733 - uses : actions/setup-go@v5
1834 with :
1935 go-version-file : go.mod
2036
21- - name : Build binaries
22- run : make build
37+ - name : Build
38+ env :
39+ GOOS : ${{ matrix.goos }}
40+ GOARCH : ${{ matrix.goarch }}
41+ CGO_ENABLED : " 0"
42+ run : |
43+ VERSION=${GITHUB_REF#refs/tags/v}
44+ EXT=""
45+ if [ "$GOOS" = "windows" ]; then EXT=".exe"; fi
46+
47+ mkdir -p dist
48+ LDFLAGS="-s -w -X ip_exit_enum/internal/version.Version=v${VERSION}"
49+ go build -ldflags="$LDFLAGS" -o dist/ip_exit_enum${EXT} .
50+
51+ cd dist
52+ ARCHIVE="ip_exit_enum_${VERSION}_${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz"
53+ tar czf "$ARCHIVE" ip_exit_enum${EXT}
54+ rm ip_exit_enum${EXT}
55+
56+ - uses : actions/upload-artifact@v4
57+ with :
58+ name : ip_exit_enum-${{ matrix.goos }}-${{ matrix.goarch }}
59+ path : dist/*.tar.gz
60+
61+ release :
62+ needs : build
63+ runs-on : ubuntu-latest
64+ steps :
65+ - uses : actions/checkout@v4
66+
67+ - uses : actions/download-artifact@v4
68+ with :
69+ path : artifacts
70+ merge-multiple : true
71+
72+ - name : Generate checksums
73+ run : |
74+ cd artifacts
75+ sha256sum *.tar.gz > SHA256SUMS
76+ cat SHA256SUMS
2377
2478 - name : Create release
2579 env :
2680 GH_TOKEN : ${{ github.token }}
2781 run : |
28- NOTES_FILE=""
29- if [ -f RELEASE_NOTES.md ]; then
30- NOTES_FILE="--notes-file RELEASE_NOTES.md"
31- else
32- NOTES_FILE="--generate-notes"
33- fi
3482 gh release create "${{ github.ref_name }}" \
3583 --title "${{ github.ref_name }}" \
36- $NOTES_FILE \
37- bin /*
84+ --generate-notes \
85+ artifacts /*
Original file line number Diff line number Diff line change 22BINARY =ip_exit_enum
33
44# Version information
5- VERSION =1.0.0
6- BUILD_TIME =$(shell date +% FT% T% z)
5+ VERSION =$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
76
87# Build flags
9- LDFLAGS =-ldflags "-X main. version=${ VERSION} "
8+ LDFLAGS =-ldflags "-X ip_exit_enum/internal/ version.Version= $( VERSION ) "
109
1110# Platforms
1211PLATFORMS =linux/amd64 linux/arm64 linux/arm darwin/amd64 darwin/arm64 windows/amd64
1312
1413# Output directories
1514DIST_DIR =bin
1615
17- .PHONY : all clean help
16+ .PHONY : all clean help build install
1817
1918all : clean build
2019
@@ -32,6 +31,12 @@ build:
3231 done
3332 @echo " Build complete! Binaries are in ${DIST_DIR} /"
3433
34+ install :
35+ @if [ -z " $( HOME) " ]; then echo " error: HOME is not set" >&2 ; exit 1; fi
36+ @mkdir -p " $( HOME) /.local/bin"
37+ go build ${LDFLAGS} -o " $( HOME) /.local/bin/${BINARY} " .
38+ @echo " Installed to ~/.local/bin/${BINARY} "
39+
3540clean :
3641 @rm -rf ${DIST_DIR}
3742 @echo " Cleaned ${DIST_DIR} / directory"
4146 @echo " Available targets:"
4247 @echo " all - Clean and build all binaries (default)"
4348 @echo " build - Build binaries for all platforms"
49+ @echo " install - Build and install to ~/.local/bin"
4450 @echo " clean - Remove build artifacts"
4551 @echo " help - Show this help message"
You can’t perform that action at this time.
0 commit comments