-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
176 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,43 @@ | ||
# .github/workflows/release.yaml | ||
on: | ||
release: | ||
types: [created] | ||
name: goreleaser | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
contents: write | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*.*.*" | ||
# Validate on develop, main, and master branches that the releaser | ||
# is working as expected. | ||
pull_request: | ||
branches: | ||
- develop | ||
- main | ||
- master | ||
|
||
jobs: | ||
releases-matrix: | ||
name: Release Go Binary | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# build and publish in parallel: linux/386, linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64 | ||
goos: [linux, windows, darwin] | ||
goarch: [amd64, arm64] | ||
exclude: | ||
- goarch: arm64 | ||
goos: windows | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: wangyoucao577/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
goos: ${{ matrix.goos }} | ||
goarch: ${{ matrix.goarch }} | ||
project_path: "./" | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21.12' | ||
check-latest: true | ||
- name: Release dry run | ||
run: make release-dry-run | ||
- name: setup release environment | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: |- | ||
echo 'GITHUB_TOKEN=${{secrets.GITHUB_TOKEN}}' > .release-env | ||
- name: Release publish | ||
# Do not publish the release for pull requests. | ||
if: github.event_name != 'pull_request' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: make release |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
version: 2 | ||
|
||
before: | ||
hooks: | ||
- go mod download | ||
|
||
builds: | ||
- id: "price-feeder-darwin" | ||
main: ./ | ||
binary: bin/price-feeder | ||
env: | ||
- CGO_ENABLED=1 | ||
- CC=o64-clang | ||
- CXX=o64-clang++ | ||
goos: | ||
- darwin | ||
goarch: | ||
- amd64 | ||
flags: | ||
- -tags=cgo | ||
ldflags: | ||
- -s -w -X github.com/ExocoreNetwork/price-feeder/version.Name=price-feeder -X github.com/ExocoreNetwor/price-feeder/version.Version={{.Version}} -X github.com/ExocoreNetwor/price-feeder/version.Commit={{.Commit}} | ||
- id: "price-feeder-darwin-arm64" | ||
main: ./ | ||
binary: bin/price-feeder | ||
env: | ||
- CGO_ENABLED=1 | ||
- CC=oa64-clang | ||
- CXX=oa64-clang++ | ||
goos: | ||
- darwin | ||
goarch: | ||
- arm64 | ||
flags: | ||
- -tags=cgo | ||
ldflags: | ||
- -s -w -X github.com/ExocoreNetwork/price-feeder/version.Name=price-feeder -X github.com/ExocoreNetwor/price-feeder/version.Version={{.Version}} -X github.com/ExocoreNetwor/price-feeder/version.Commit={{.Commit}} | ||
- id: "price-feeder-linux" | ||
main: ./ | ||
binary: bin/price-feeder | ||
env: | ||
- CGO_ENABLED=1 | ||
- CC=gcc | ||
- CXX=g++ | ||
goos: | ||
- linux | ||
goarch: | ||
- amd64 | ||
flags: | ||
- -tags=cgo | ||
ldflags: | ||
- -s -w -X github.com/ExocoreNetwork/price-feeder/version.Name=price-feeder -X github.com/ExocoreNetwor/price-feeder/version.Version={{.Version}} -X github.com/ExocoreNetwor/price-feeder/version.Commit={{.Commit}} | ||
- id: "price-feeder-linux-arm64" | ||
main: ./ | ||
binary: bin/price-feeder | ||
env: | ||
- CGO_ENABLED=1 | ||
- CC=aarch64-linux-gnu-gcc | ||
- CXX=aarch64-linux-gnu-g++ | ||
goos: | ||
- linux | ||
goarch: | ||
- arm64 | ||
flags: | ||
- -tags=cgo | ||
ldflags: | ||
- -s -w -X github.com/ExocoreNetwork/price-feeder/version.Name=price-feeder -X github.com/ExocoreNetwor/price-feeder/version.Version={{.Version}} -X github.com/ExocoreNetwor/price-feeder/version.Commit={{.Commit}} | ||
- id: "price-feeder-windows" | ||
main: ./ | ||
binary: bin/price-feeder | ||
env: | ||
- CGO_ENABLED=1 | ||
- CC=x86_64-w64-mingw32-gcc | ||
- CXX=x86_64-w64-mingw32-g++ | ||
goos: | ||
- windows | ||
goarch: | ||
- amd64 | ||
flags: | ||
- -tags=cgo | ||
- -buildmode=exe | ||
ldflags: | ||
- -s -w -X github.com/ExocoreNetwork/price-feeder/version.Name=price-feeder -X github.com/ExocoreNetwor/price-feeder/version.Version={{.Version}} -X github.com/ExocoreNetwor/price-feeder/version.Commit={{.Commit}} | ||
archives: | ||
- name_template: '{{ .ProjectName }}_{{ .Version }}_{{- title .Os }}_{{ .Arch }}' | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
builds: | ||
- exocored-darwin | ||
- exocored-darwin-arm64 | ||
- exocored-windows | ||
- exocored-linux | ||
- exocored-linux-arm64 | ||
|
||
checksum: | ||
name_template: 'checksums.txt' | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
snapshot: | ||
name_template: "{{ .Tag }}-{{ .Branch }}@{{ .ShortCommit }}-{{ .GitTreeState }}" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
PACKAGE_NAME := github.com/ExocoreNetwork/price-feeder | ||
GOLANG_CROSS_VERSION = v1.22-v2.0.0 | ||
GOPATH ?= '$(HOME)/go' | ||
|
||
release-dry-run: | ||
docker run \ | ||
--rm \ | ||
--privileged \ | ||
-e CGO_ENABLED=1 \ | ||
-v /var/run/docker.sock:/var/run/docker.sock \ | ||
-v `pwd`:/go/src/$(PACKAGE_NAME) \ | ||
-v ${GOPATH}/pkg:/go/pkg \ | ||
-w /go/src/$(PACKAGE_NAME) \ | ||
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \ | ||
--clean --skip validate,publish --snapshot | ||
|
||
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) \ | ||
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \ | ||
release --clean --skip validate |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package version | ||
|
||
var Name, Version, Commit string |