From 0fd7e09714b4e218e94c404e8ceb6dcd0b8622f8 Mon Sep 17 00:00:00 2001 From: Runchao Han Date: Fri, 11 Oct 2024 16:48:46 +1100 Subject: [PATCH] init --- .github/workflows/changelog-reminder.yml | 11 +++++ .github/workflows/ci.yml | 4 -- .gitignore | 1 + .goreleaser.yml | 52 ++++++++++++++++++++++ Makefile | 55 ++++++++++++++++++++++++ 5 files changed, 119 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/changelog-reminder.yml create mode 100644 .goreleaser.yml diff --git a/.github/workflows/changelog-reminder.yml b/.github/workflows/changelog-reminder.yml new file mode 100644 index 0000000..ebe2a55 --- /dev/null +++ b/.github/workflows/changelog-reminder.yml @@ -0,0 +1,11 @@ +name: Changelog Reminder +on: + pull_request: + types: [assigned, opened, synchronize, reopened, labeled, unlabeled] + branches: + - main + +jobs: + changelog_reminder: + uses: babylonlabs-io/.github/.github/workflows/reusable_changelog_reminder.yml@v0.7.0 + secrets: inherit diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5c614f..59258d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,10 +15,6 @@ jobs: run-build: true run-gosec: true gosec-args: "-exclude-generated -exclude-dir=itest -exclude-dir=testutil ./..." - - changelog_reminder: - uses: babylonlabs-io/.github/.github/workflows/reusable_changelog_reminder.yml@v0.7.0 - secrets: inherit docker_pipeline: uses: babylonlabs-io/.github/.github/workflows/reusable_docker_pipeline.yml@v0.7.0 diff --git a/.gitignore b/.gitignore index 08d680e..ec92862 100644 --- a/.gitignore +++ b/.gitignore @@ -26,5 +26,6 @@ main tmp/ build/ +dist/ *.swp diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..7b60ab1 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,52 @@ +project_name: covenant-emulator + +builds: + - id: covd-linux-amd64 + main: ./cmd/covd + binary: covd + hooks: + pre: + - wget https://github.com/CosmWasm/wasmvm/releases/download/{{ .Env.COSMWASM_VERSION }}/libwasmvm.x86_64.so -O /lib/libwasmvm_muslc.x86_64.so + goos: + - linux + goarch: + - amd64 + flags: + - -mod=readonly + - -trimpath + ldflags: + - -w + - -s + tags: + - netgo + +archives: + - id: zipped + builds: + - covd-linux-amd64 + name_template: "{{.ProjectName}}-{{ .Version }}-{{ .Os }}-{{ .Arch }}" + format: tar.gz + files: + - none* + - id: binaries + builds: + - covd-linux-amd64 + name_template: "{{.ProjectName}}-{{ .Version }}-{{ .Os }}-{{ .Arch }}" + format: binary + files: + - none* + +checksum: + name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt" + algorithm: sha256 + +release: + github: + owner: babylonlabs-io + name: covenant-emulator + +# Docs: https://goreleaser.com/customization/changelog/ +changelog: + disable: true + +dist: dist diff --git a/Makefile b/Makefile index 7cf7ca6..5839d3f 100644 --- a/Makefile +++ b/Makefile @@ -71,3 +71,58 @@ update-changelog: ./scripts/update_changelog.sh $(sinceTag) $(upcomingTag) .PHONY: update-changelog + + +############################################################################### +### Release ### +############################################################################### + +# The below is adapted from https://github.com/osmosis-labs/osmosis/blob/main/Makefile +GO_VERSION := $(shell grep -E '^go [0-9]+\.[0-9]+' go.mod | awk '{print $$2}') +GORELEASER_IMAGE := ghcr.io/goreleaser/goreleaser-cross:v$(GO_VERSION) +COSMWASM_VERSION := $(shell go list -m github.com/CosmWasm/wasmvm/v2 | sed 's/.* //') + +.PHONY: release-dry-run release-snapshot release +release-dry-run: + docker run \ + --rm \ + -e COSMWASM_VERSION=$(COSMWASM_VERSION) \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/babylon \ + -w /go/src/babylon \ + $(GORELEASER_IMAGE) \ + release \ + --clean \ + --skip=publish + +release-snapshot: + docker run \ + --rm \ + -e COSMWASM_VERSION=$(COSMWASM_VERSION) \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/babylon \ + -w /go/src/babylon \ + $(GORELEASER_IMAGE) \ + release \ + --clean \ + --snapshot \ + --skip=publish,validate \ + +# NOTE: By default, the CI will handle the release process. +# this is for manually releasing. +ifdef GITHUB_TOKEN +release: + docker run \ + --rm \ + -e GITHUB_TOKEN=$(GITHUB_TOKEN) \ + -e COSMWASM_VERSION=$(COSMWASM_VERSION) \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/babylon \ + -w /go/src/babylon \ + $(GORELEASER_IMAGE) \ + release \ + --clean +else +release: + @echo "Error: GITHUB_TOKEN is not defined. Please define it before running 'make release'." +endif \ No newline at end of file