From f321b89d34a978abfccc702913015f2619fc76f7 Mon Sep 17 00:00:00 2001 From: Peter Kieltyka Date: Sat, 10 Feb 2024 20:00:48 -0500 Subject: [PATCH] release workflow --- .github/workflows/.goreleaser.yml | 72 ++++++++++++++++++++++++++ .github/workflows/release.yml | 43 +++++++++++++++ Makefile | 9 ++-- compressor/Dockerfile | 25 +++++++++ compressor/Makefile | 3 ++ compressor/cmd/czip-compressor/main.go | 2 +- compressor/compressor.go | 3 ++ 7 files changed, 151 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/.goreleaser.yml create mode 100644 .github/workflows/release.yml create mode 100644 compressor/Dockerfile create mode 100644 compressor/compressor.go diff --git a/.github/workflows/.goreleaser.yml b/.github/workflows/.goreleaser.yml new file mode 100644 index 0000000..a79c3e2 --- /dev/null +++ b/.github/workflows/.goreleaser.yml @@ -0,0 +1,72 @@ +# See documentation at https://goreleaser.com/customization/build. +project_name: czip + +builds: + - id: czip-compressor + main: ./cmd/czip-compressor + binary: czip-compressor + goos: + - darwin + - linux + - windows + goarch: + - amd64 + - arm64 + ldflags: + - -s -w -X github.com/0xsequence/czip/compressor.VERSION=v{{.Version}} + +archives: + - id: czip-compressor + builds: + - czip-compressor + name_template: "{{ .Binary }}.{{ .Os }}-{{ .Arch }}" + format: binary + +checksum: + name_template: "checksums.txt" + +release: + footer: | + ## Docker + ``` + $ docker pull ghcr.io/0xsequence/czip-compressor:v{{.Version}} + ``` + + Example: `$ docker run ghcr.io/0xsequence/czip-compressor` + + ## Homebrew + ``` + $ brew tap 0xsequence/tap + $ brew install czip-compressor + $ czip-compressor + ``` + + ## Build from source + ``` + $ go install github.com/0xsequence/czip/cmd/czip-compressor + ``` + + ## Download binaries + macOS: [amd64](https://github.com/0xsequence/czip/releases/download/v{{.Version}}/czip-compressor.darwin-amd64), [arm64](https://github.com/0xsequence/czip/releases/download/v{{.Version}}/czip-compressor.darwin-arm64) (Apple Silicon) + Linux: [amd64](https://github.com/0xsequence/czip/releases/download/v{{.Version}}/czip-compressor.linux-amd64), [arm64](https://github.com/0xsequence/czip/releases/download/v{{.Version}}/czip-compressor.linux-arm64) + Windows: [amd64](https://github.com/0xsequence/czip/releases/download/v{{.Version}}/czip-compressor.windows-amd64.exe), [arm64](https://github.com/0xsequence/czip/releases/download/v{{.Version}}/czip-compressor.windows-arm64.exe) + +changelog: + use: github + sort: asc + +brews: + - name: czip-compressor + ids: + - czip-compressor + tap: + owner: 0xsequence + name: homebrew-tap + token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}" + commit_author: + name: goreleaserbot + email: bot@goreleaser.com + commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}" + homepage: "https://github.com/0xsequence/czip" + description: "czip: EVM Calldata Zip" + license: "MIT" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9bad86c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,43 @@ +name: Release tag + +on: + push: + tags: + - "v*" + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.22 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v3 + with: + distribution: goreleaser + version: latest + args: release -f .github/workflows/.goreleaser.yml --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} + + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Log into Github registry + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + - name: Docker build + run: | + docker build --build-arg VERSION=${GITHUB_REF##*/} -t ghcr.io/0xsequence/czip-compressor:${GITHUB_REF##*/} -t ghcr.io/0xsequence/czip-compressor:latest . + docker push ghcr.io/0xsequence/czip-compressor:${GITHUB_REF##*/} + docker push ghcr.io/0xsequence/czip-compressor:latest diff --git a/Makefile b/Makefile index a80a733..dee2d81 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,10 @@ all: @echo "Usage: make " @echo " where is one of the following:" - @echo " foundryup" - @echo " foundrydown" - @echo " foundryclean" - @echo " foundryrestart" - @echo " foundrystatus" + @echo " bootstrap" + @echo " forge" + @echo " build" + @echo " test" bootstrap: check-forge check-huffc forge diff --git a/compressor/Dockerfile b/compressor/Dockerfile new file mode 100644 index 0000000..ae8a540 --- /dev/null +++ b/compressor/Dockerfile @@ -0,0 +1,25 @@ +# ----------------------------------------------------------------- +# Builder +# ----------------------------------------------------------------- +FROM golang:1.22.0-alpine3.19 as builder +ARG VERSION + +RUN apk add --update git + +ADD ./ /src + +WORKDIR /src +RUN go build -ldflags="-s -w -X github.com/0xsequence/czip/compressor.VERSION=${VERSION}" -o /usr/bin/czip-compressor ./cmd/czip-compressor + +# ----------------------------------------------------------------- +# Runner +# ----------------------------------------------------------------- +FROM alpine:3.19 + +ENV TZ=UTC + +RUN apk add --no-cache --update ca-certificates + +COPY --from=builder /usr/bin/czip-compressor /usr/bin/ + +ENTRYPOINT ["/usr/bin/czip-compressor"] diff --git a/compressor/Makefile b/compressor/Makefile index f74539d..085f3da 100644 --- a/compressor/Makefile +++ b/compressor/Makefile @@ -9,3 +9,6 @@ build-cli: install: GOGC=off go install -v ./cmd/czip-compressor + +docker-image: + @docker build -t 0xsequence/czip-compressor . diff --git a/compressor/cmd/czip-compressor/main.go b/compressor/cmd/czip-compressor/main.go index 6b59ae6..f1354fd 100644 --- a/compressor/cmd/czip-compressor/main.go +++ b/compressor/cmd/czip-compressor/main.go @@ -16,7 +16,7 @@ func main() { } if len(args.Positional) < 1 { - fmt.Println("Usage: encode_sequence_tx / encode_call / encode_calls / encode_any / extras") + fmt.Printf("Usage (%s): encode_sequence_tx / encode_call / encode_calls / encode_any / extras\n", compressor.VERSION) os.Exit(1) } diff --git a/compressor/compressor.go b/compressor/compressor.go new file mode 100644 index 0000000..7814c06 --- /dev/null +++ b/compressor/compressor.go @@ -0,0 +1,3 @@ +package compressor + +var VERSION = "dev"