Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] add-artifact when release tag #30

Merged
merged 16 commits into from
Feb 5, 2025
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 'Release'

on:
push:
tags:
- '*' # Run release on any tag. Will be marked as draft by default anyway.

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22.3'

- run: echo https://github.com/bandprotocol/falcon/blob/${GITHUB_REF#refs/tags/}/CHANGELOG.md#${GITHUB_REF#refs/tags/} > ../release_notes.md

- name: setup release environment
run: |-
echo 'GITHUB_TOKEN=${{secrets.GITHUB_TOKEN}}' > .release-env
- name: release publish
run: make release
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ coverage.out

# Configuration files
.env
.release-env

# Added by goreleaser init:
dist/
78 changes: 78 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
project_name: Falcon

builds:
- id: darwin-amd64
main: ./main.go
binary: falcon
goos:
- darwin
goarch:
- amd64
env:
- CC=o64-clang
- CXX=o64-clang++
flags:
- -mod=readonly
ldflags:
- -s -w -X github.com/bandprotocol/falcon/cmd.Version={{ .Tag }}
- id: darwin-arm64
main: ./main.go
binary: falcon
goos:
- darwin
goarch:
- arm64
env:
- CC=oa64-clang
- CXX=oa64-clang++
flags:
- -mod=readonly
ldflags:
- -s -w -X github.com/bandprotocol/falcon/cmd.Version={{ .Tag }}
- id: linux-amd64
main: ./main.go
binary: falcon
goos:
- linux
goarch:
- amd64
env:
- CC=x86_64-linux-gnu-gcc
- CXX=x86_64-linux-gnu-g++
flags:
- -mod=readonly
ldflags:
- -s -w -X github.com/bandprotocol/falcon/cmd.Version={{ .Tag }}
- id: linux-arm64
main: ./main.go
binary: falcon
goos:
- linux
goarch:
- arm64
env:
- CC=aarch64-linux-gnu-gcc
- CXX=aarch64-linux-gnu-g++
flags:
- -mod=readonly
ldflags:
- -s -w -X github.com/bandprotocol/falcon/cmd.Version={{ .Tag }}

archives:
- id: golang-cross
builds:
- darwin-amd64
- darwin-arm64
- linux-amd64
- linux-arm64
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
formats: tar.gz
wrap_in_directory: true

checksum:
name_template: SHA256SUMS-{{.Version}}.txt
algorithm: sha256

release:
prerelease: auto
draft: true
27 changes: 20 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,32 @@ ldflags := $(strip $(ldflags))

BUILD_FLAGS := -tags "$(build_tags_comma_sep)" -ldflags '$(ldflags)'

PACKAGE_NAME := github.com/bandprotocol/falcon
GOLANG_CROSS_VERSION ?= latest

all: install

install: go.sum
@echo "installing falcon binary..."
@go build -mod=readonly $(BUILD_FLAGS) -o $(GOBIN)/falcon main.go

release: go.sum
env GOOS=linux GOARCH=amd64 \
go build -mod=readonly -o ./build/falcon_linux_amd64 $(BUILD_FLAGS) main.go
env GOOS=darwin GOARCH=amd64 \
go build -mod=readonly -o ./build/falcon_darwin_amd64 $(BUILD_FLAGS) main.go
env GOOS=windows GOARCH=amd64 \
go build -mod=readonly -o ./build/falcon_windows_amd64 $(BUILD_FLAGS) main.go
.PHONY: release
#? release: Run goreleaser to build and release cross-platform falcon binary version
release:
@if [ ! -f ".release-env" ]; then \
echo "\033[91m.release-env is required for release\033[0m";\
exit 1;\
fi
docker run \
--rm \
-e CGO_ENABLED=1 \
--env-file .release-env \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-v `pwd`/sysroot:/sysroot \
-w /go/src/$(PACKAGE_NAME) \
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --clean

mocks:
@go install go.uber.org/mock/mockgen@latest
Expand Down
Loading