File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : CI
2+
3+ on :
4+ push :
5+ branches : [main]
6+ pull_request :
7+ branches : [main]
8+
9+ env :
10+ GONOSUMCHECK : github.com/GoCodeAlone/*
11+ GONOSUMDB : github.com/GoCodeAlone/*
12+ GOPRIVATE : github.com/GoCodeAlone/*
13+
14+ jobs :
15+ lint :
16+ name : Lint
17+ runs-on : ubuntu-latest
18+ steps :
19+ - uses : actions/checkout@v4
20+
21+ - uses : actions/setup-go@v5
22+ with :
23+ go-version : ' 1.26'
24+ cache : true
25+
26+ - name : Resolve dependencies
27+ run : go mod tidy
28+
29+ - name : Run go vet
30+ run : go vet ./...
31+
32+ - name : Run go fmt check
33+ run : |
34+ if [ "$(gofmt -l . | wc -l)" -gt 0 ]; then
35+ echo "The following files are not formatted:"
36+ gofmt -l .
37+ exit 1
38+ fi
39+
40+ test :
41+ name : Test
42+ runs-on : ubuntu-latest
43+ steps :
44+ - uses : actions/checkout@v4
45+
46+ - uses : actions/setup-go@v5
47+ with :
48+ go-version : ' 1.26'
49+ cache : true
50+
51+ - name : Resolve dependencies
52+ run : go mod tidy
53+
54+ - name : Run tests
55+ run : go test ./... -v -race
56+
57+ build :
58+ name : Cross-platform Build
59+ runs-on : ubuntu-latest
60+ strategy :
61+ matrix :
62+ include :
63+ - goos : linux
64+ goarch : amd64
65+ - goos : linux
66+ goarch : arm64
67+ - goos : darwin
68+ goarch : amd64
69+ - goos : darwin
70+ goarch : arm64
71+ steps :
72+ - uses : actions/checkout@v4
73+
74+ - uses : actions/setup-go@v5
75+ with :
76+ go-version : ' 1.26'
77+ cache : true
78+
79+ - name : Resolve dependencies
80+ run : go mod tidy
81+
82+ - name : Build ${{ matrix.goos }}/${{ matrix.goarch }}
83+ env :
84+ GOOS : ${{ matrix.goos }}
85+ GOARCH : ${{ matrix.goarch }}
86+ run : |
87+ go build -o bin/workflow-plugin-authz-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/workflow-plugin-authz
Original file line number Diff line number Diff line change 1+ name : Release
2+
3+ on :
4+ push :
5+ tags :
6+ - ' v*'
7+
8+ permissions :
9+ contents : write
10+
11+ env :
12+ GONOSUMCHECK : github.com/GoCodeAlone/*
13+ GONOSUMDB : github.com/GoCodeAlone/*
14+ GOPRIVATE : github.com/GoCodeAlone/*
15+
16+ jobs :
17+ release :
18+ name : Build and Release
19+ runs-on : ubuntu-latest
20+ steps :
21+ - uses : actions/checkout@v4
22+ with :
23+ fetch-depth : 0
24+
25+ - uses : actions/setup-go@v5
26+ with :
27+ go-version : ' 1.26'
28+ cache : true
29+
30+ - name : Resolve dependencies
31+ run : go mod tidy
32+
33+ - name : Run tests
34+ run : go test ./... -v -race
35+
36+ - name : Build binaries
37+ run : |
38+ VERSION=${GITHUB_REF#refs/tags/}
39+
40+ declare -a PLATFORMS=("linux/amd64" "linux/arm64" "darwin/amd64" "darwin/arm64")
41+ mkdir -p bin
42+
43+ for platform in "${PLATFORMS[@]}"; do
44+ os="${platform%%/*}"
45+ arch="${platform##*/}"
46+ output="bin/workflow-plugin-authz-${os}-${arch}"
47+ echo "Building ${output}..."
48+ GOOS=${os} GOARCH=${arch} go build -ldflags "-X main.version=${VERSION}" \
49+ -o "${output}" ./cmd/workflow-plugin-authz
50+ done
51+
52+ ls -la bin/
53+
54+ - name : Create release archives
55+ run : |
56+ mkdir -p dist
57+ for binary in bin/workflow-plugin-authz-*; do
58+ name=$(basename "${binary}")
59+ tar -czf "dist/${name}.tar.gz" -C bin "${name}"
60+ sha256sum "dist/${name}.tar.gz" >> dist/checksums.txt
61+ done
62+ cp plugin.json dist/
63+ ls -la dist/
64+
65+ - name : Create GitHub Release
66+ uses : softprops/action-gh-release@v2
67+ with :
68+ files : |
69+ dist/*.tar.gz
70+ dist/checksums.txt
71+ dist/plugin.json
72+ generate_release_notes : true
73+ draft : false
74+ prerelease : false
Original file line number Diff line number Diff line change 1- .PHONY : build test install clean
1+ .PHONY : build test install clean cross-build
22
33BINARY_NAME = workflow-plugin-authz
4+ VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
5+ LDFLAGS = -ldflags "-X main.version=$(VERSION ) "
46INSTALL_DIR ?= data/plugins/$(BINARY_NAME )
7+ PLATFORMS = linux/amd64 linux/arm64 darwin/amd64 darwin/arm64
58
69build :
7- GOPRIVATE=github.com/GoCodeAlone/* go build -o bin/$(BINARY_NAME ) ./cmd/$(BINARY_NAME )
10+ GOPRIVATE=github.com/GoCodeAlone/* go build $( LDFLAGS ) -o bin/$(BINARY_NAME ) ./cmd/$(BINARY_NAME )
811
912test :
1013 GOPRIVATE=github.com/GoCodeAlone/* go test ./... -v -race
@@ -14,5 +17,16 @@ install: build
1417 cp bin/$(BINARY_NAME ) $(DESTDIR ) /$(INSTALL_DIR ) /
1518 cp plugin.json $(DESTDIR ) /$(INSTALL_DIR ) /
1619
20+ cross-build :
21+ @mkdir -p bin
22+ @for platform in $(PLATFORMS ) ; do \
23+ os=$$ {platform%%/* }; \
24+ arch=$$ {platform## */}; \
25+ output=bin/$(BINARY_NAME ) -$$ {os}-$$ {arch}; \
26+ echo " Building $$ {output}..." ; \
27+ GOOS=$$ {os} GOARCH=$$ {arch} GOPRIVATE=github.com/GoCodeAlone/* \
28+ go build $(LDFLAGS ) -o $$ {output} ./cmd/$(BINARY_NAME ) ; \
29+ done
30+
1731clean :
1832 rm -rf bin/
You can’t perform that action at this time.
0 commit comments