Skip to content

Commit

Permalink
feat(ci): add binary releases
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkness4 committed Dec 1, 2023
1 parent fbab1f9 commit af66520
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 2 deletions.
45 changes: 43 additions & 2 deletions .github/workflows/golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ jobs:
- name: Run tests
run: go test -race -covermode=atomic -timeout=30s ./...

build-go:
name: Build Go
build-go-docker:
name: Build Docker

runs-on: ubuntu-latest

Expand Down Expand Up @@ -125,3 +125,44 @@ jobs:
${{ steps.get_version.outputs.VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max

build:
name: Build Go

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Download build-essential
run: |
sudo apt update -y
sudo apt install -y make build-essential
- uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
check-latest: true
cache-dependency-path: go.mod

- name: Build
run: |
make build-all
- name: Get the version
if: startsWith(github.ref, 'refs/tags/')
id: get_version
run: |
VERSION=$(echo ${GITHUB_REF#refs/*/}
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
- uses: sersoft-gmbh/setup-gh-cli-action@v2
if: startsWith(github.ref, 'refs/tags/')
with:
version: stable

- name: Create release and upload binaries
if: startsWith(github.ref, 'refs/tags/')
run: gh release create ${{ steps.branch_name.outputs.VERSION }} -t ${{ steps.branch_name.outputs.VERSION }} -F bin/checksums.md --prerelease=${{ contains(steps.get_version.outputs.VERSION, '-') }} bin/dpsproxy-* bin/checksums.txt
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64 changes: 64 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,70 @@ bin/dpsproxy-server: $(GO_SRCS)
bin/dpsproxy: $(GO_SRCS)
go build -trimpath -ldflags "-s -w -X main.version=${VERSION}" -o "$@" ./cmd/dpsproxy/main.go


bin/checksums.txt: $(addprefix bin/,$(bins))
sha256sum -b $(addprefix bin/,$(bins)) | sed 's/bin\///' > $@

bin/checksums.md: bin/checksums.txt
@echo "### SHA256 Checksums" > $@
@echo >> $@
@echo "\`\`\`" >> $@
@cat $< >> $@
@echo "\`\`\`" >> $@

bin/dpsproxy-server-darwin-amd64: $(GO_SRCS)
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -X main.version=${VERSION}" -o "$@" ./cmd/dpsproxy-server/main.go

bin/dpsproxy-server-darwin-arm64: $(GO_SRCS)
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w -X main.version=${VERSION}" -o "$@" ./cmd/dpsproxy-server/main.go

bin/dpsproxy-server-freebsd-amd64: $(GO_SRCS)
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "-s -w -X main.version=${VERSION}" -o "$@" ./cmd/dpsproxy-server/main.go

bin/dpsproxy-server-freebsd-arm64: $(GO_SRCS)
CGO_ENABLED=0 GOOS=freebsd GOARCH=arm64 go build -ldflags "-s -w -X main.version=${VERSION}" -o "$@" ./cmd/dpsproxy-server/main.go

bin/dpsproxy-server-linux-amd64: $(GO_SRCS)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X main.version=${VERSION}" -o "$@" ./cmd/dpsproxy-server/main.go

bin/dpsproxy-server-linux-arm64: $(GO_SRCS)
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X main.version=${VERSION}" -o "$@" ./cmd/dpsproxy-server/main.go

bin/dpsproxy-server-linux-riscv64: $(GO_SRCS)
CGO_ENABLED=0 GOOS=linux GOARCH=riscv64 go build -ldflags "-s -w -X main.version=${VERSION}" -o "$@" ./cmd/dpsproxy-server/main.go

bin/dpsproxy-server-windows-amd64.exe: $(GO_SRCS)
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -X main.version=${VERSION}" -o "$@" ./cmd/dpsproxy-server/main.go

bin/dpsproxy-darwin-amd64: $(GO_SRCS)
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -X main.version=${VERSION}" -o "$@" ./cmd/dpsproxy/main.go

bin/dpsproxy-darwin-arm64: $(GO_SRCS)
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w -X main.version=${VERSION}" -o "$@" ./cmd/dpsproxy/main.go

bin/dpsproxy-freebsd-amd64: $(GO_SRCS)
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "-s -w -X main.version=${VERSION}" -o "$@" ./cmd/dpsproxy/main.go

bin/dpsproxy-freebsd-arm64: $(GO_SRCS)
CGO_ENABLED=0 GOOS=freebsd GOARCH=arm64 go build -ldflags "-s -w -X main.version=${VERSION}" -o "$@" ./cmd/dpsproxy/main.go

bin/dpsproxy-linux-amd64: $(GO_SRCS)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X main.version=${VERSION}" -o "$@" ./cmd/dpsproxy/main.go

bin/dpsproxy-linux-arm64: $(GO_SRCS)
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X main.version=${VERSION}" -o "$@" ./cmd/dpsproxy/main.go

bin/dpsproxy-linux-riscv64: $(GO_SRCS)
CGO_ENABLED=0 GOOS=linux GOARCH=riscv64 go build -ldflags "-s -w -X main.version=${VERSION}" -o "$@" ./cmd/dpsproxy/main.go

bin/dpsproxy-windows-amd64.exe: $(GO_SRCS)
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -X main.version=${VERSION}" -o "$@" ./cmd/dpsproxy/main.go

bins := dpsproxy-server-darwin-amd64 dpsproxy-server-darwin-arm64 dpsproxy-server-freebsd-arm64 dpsproxy-server-freebsd-arm64 dpsproxy-server-linux-amd64 dpsproxy-server-linux-arm64 dpsproxy-server-linux-riscv64 dpsproxy-server-windows-amd64.exe dpsproxy-darwin-amd64 dpsproxy-darwin-arm64 dpsproxy-freebsd-arm64 dpsproxy-freebsd-arm64 dpsproxy-linux-amd64 dpsproxy-linux-arm64 dpsproxy-linux-riscv64 dpsproxy-windows-amd64.exe

.PHONY: build-all
build-all: $(addprefix bin/,$(bins)) bin/checksums.md

.PHONY: run
run: bin/dpsproxy-server
@bin/dpsproxy-server
Expand Down

0 comments on commit af66520

Please sign in to comment.