From 23190f5349df40de49c7fc9af8cffc6aeeb41266 Mon Sep 17 00:00:00 2001 From: Ferran Borreguero Date: Mon, 8 Jan 2024 09:44:39 +0100 Subject: [PATCH 1/4] Add goreleaser --- .github/workflows/releaser.yml | 36 ++++++++++++ .goreleaser.yaml | 97 ++++++++++++++++++++++++++++++++ Makefile | 18 ++++++ suave/scripts/parse-changelog.sh | 47 ++++++++++++++++ 4 files changed, 198 insertions(+) create mode 100644 .github/workflows/releaser.yml create mode 100644 .goreleaser.yaml create mode 100755 suave/scripts/parse-changelog.sh diff --git a/.github/workflows/releaser.yml b/.github/workflows/releaser.yml new file mode 100644 index 000000000..11d45ea4f --- /dev/null +++ b/.github/workflows/releaser.yml @@ -0,0 +1,36 @@ +# .github/workflows/release.yml +name: goreleaser + +on: + workflow_dispatch: + push: + tags: + - "*" + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: setup dependencies + uses: actions/setup-go@v2 + + - name: Login to GHCR + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Publich ref name + run: echo "Build for tag ${{ github.ref_name }}" + + - name: release dry run + run: make release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG: ${{ github.ref_name }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 000000000..58d498d13 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,97 @@ +env: + - CGO_ENABLED=1 +builds: + - id: suave-geth-darwin-amd64 + binary: suave-geth + main: ./cmd/geth + goarch: + - amd64 + goos: + - darwin + env: + - CC=o64-clang + - CXX=o64-clang++ + flags: + - -trimpath + - id: suave-geth-darwin-arm64 + binary: suave-geth + main: ./cmd/geth + goarch: + - arm64 + goos: + - darwin + env: + - CC=oa64-clang + - CXX=oa64-clang++ + flags: + - -trimpath + - id: suave-geth-linux-amd64 + binary: suave-geth + main: ./cmd/geth + env: + - CC=x86_64-linux-gnu-gcc + - CXX=x86_64-linux-gnu-g++ + goarch: + - amd64 + goos: + - linux + flags: + - -trimpath + ldflags: + - -extldflags "-lc -lrt -lpthread --static" + - id: suave-geth-linux-arm64 + binary: suave-geth + main: ./cmd/geth + goarch: + - arm64 + goos: + - linux + env: + - CC=aarch64-linux-gnu-gcc + - CXX=aarch64-linux-gnu-g++ + flags: + - -trimpath + ldflags: + - -extldflags "-lc -lrt -lpthread --static" + - id: suave-geth-windows-amd64 + binary: suave-geth + main: ./cmd/geth + goarch: + - amd64 + goos: + - windows + env: + - CC=x86_64-w64-mingw32-gcc + - CXX=x86_64-w64-mingw32-g++ + flags: + - -trimpath + - -buildmode=exe + +archives: + - id: w/version + builds: + - suave-geth-darwin-amd64 + - suave-geth-darwin-arm64 + - suave-geth-linux-amd64 + - suave-geth-linux-arm64 + - suave-geth-windows-amd64 + name_template: "suave-geth_v{{ .Version }}_{{ .Os }}_{{ .Arch }}" + wrap_in_directory: false + format: zip + files: + - none* + +dockers: + - dockerfile: ./Dockerfile.suave + use: buildx + goarch: amd64 + goos: linux + build_flag_templates: + - --platform=linux/amd64 + image_templates: + - "ghcr.io/flashbots/suave-geth:{{ .ShortCommit }}" + - "ghcr.io/flashbots/suave-geth:{{ .Tag }}" + - "ghcr.io/flashbots/suave-geth:latest" + +checksum: + name_template: "checksums.txt" diff --git a/Makefile b/Makefile index 71d98a6b5..1a5cb7dcc 100644 --- a/Makefile +++ b/Makefile @@ -54,3 +54,21 @@ devnet-down: fmt-contracts: cd suave && forge fmt + +release: + # Generate the changelog for the release + ./suave/scripts/parse-changelog.sh $(TAG) > /tmp/changelog.md + + # Build and publish the release + docker run \ + --rm \ + -e CGO_ENABLED=1 \ + -e GITHUB_TOKEN="$(GITHUB_TOKEN)" \ + -v /tmp/changelog.md:/build/changelog.md \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v $(HOME)/.docker/config.json:/root/.docker/config.json \ + -v `pwd`:/go/src/$(PACKAGE_NAME) \ + -v `pwd`/sysroot:/sysroot \ + -w /go/src/$(PACKAGE_NAME) \ + ghcr.io/goreleaser/goreleaser-cross:v1.19.5 \ + release --clean --release-notes /build/changelog.md diff --git a/suave/scripts/parse-changelog.sh b/suave/scripts/parse-changelog.sh new file mode 100755 index 000000000..59bce7c47 --- /dev/null +++ b/suave/scripts/parse-changelog.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Define the version you want to extract +target_version=$1 + +if [ -z "$target_version" ]; then + echo "Target version is empty" + exit 1 +fi + +# Input changelog file +changelog_file="CHANGELOG.md" + +# Function to add entries to the markdown file +add_entry() { + echo -e "$1" +} + +# Flag to start processing when the target version is found +found_version=false +found_anything=false + +# Read the changelog file line by line +while IFS= read -r line; do + # Check if the line starts with the target version + if [[ $line == "## $target_version"* ]]; then + echo "## Changelog" + found_version=true + found_anything=true + continue + elif [[ $line == "##"* ]]; then + # We moved to another version, stop processing + found_version=false + fi + + # If we've found the target version, start processing entries + if [ "$found_version" = true ]; then + # Add the current entry to the markdown file + add_entry "$line" + fi +done < "$changelog_file" + +# If no changelog found, return an error +if [ "$found_anything" = false ]; then + echo "No changelog found for $target_version" + exit 1 +fi \ No newline at end of file From 90ac13f339f5fc2c40e7c018df15f9b7462976ad Mon Sep 17 00:00:00 2001 From: Ferran Borreguero Date: Mon, 8 Jan 2024 09:57:43 +0100 Subject: [PATCH 2/4] Add changelog --- CHANGELOG.md | 3 +++ suave/scripts/parse-changelog.sh | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..65d59accb --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## v0.1.0 (Unreleased) + +Initial release of `suave-geth`. diff --git a/suave/scripts/parse-changelog.sh b/suave/scripts/parse-changelog.sh index 59bce7c47..94f52bd1d 100755 --- a/suave/scripts/parse-changelog.sh +++ b/suave/scripts/parse-changelog.sh @@ -28,7 +28,7 @@ while IFS= read -r line; do found_version=true found_anything=true continue - elif [[ $line == "##"* ]]; then + elif [[ $line == "## "* ]]; then # We moved to another version, stop processing found_version=false fi From 668779648d53e19e9416582e23a05d53f9862aea Mon Sep 17 00:00:00 2001 From: Ferran Borreguero Date: Mon, 8 Jan 2024 11:58:08 +0100 Subject: [PATCH 3/4] Update goreleaser --- .goreleaser.yaml | 8 ++++++ CHANGELOG.md | 3 -- Makefile | 7 +---- suave/scripts/parse-changelog.sh | 47 -------------------------------- 4 files changed, 9 insertions(+), 56 deletions(-) delete mode 100644 CHANGELOG.md delete mode 100755 suave/scripts/parse-changelog.sh diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 58d498d13..9da62fd0e 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -95,3 +95,11 @@ dockers: checksum: name_template: "checksums.txt" + +release: + draft: true + header: | + # 🚀 Features + # 🎄 Enhancements + # 🐞 Notable bug fixes + # 🎠 Community diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 65d59accb..000000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## v0.1.0 (Unreleased) - -Initial release of `suave-geth`. diff --git a/Makefile b/Makefile index 1a5cb7dcc..59c19ef0d 100644 --- a/Makefile +++ b/Makefile @@ -56,19 +56,14 @@ fmt-contracts: cd suave && forge fmt release: - # Generate the changelog for the release - ./suave/scripts/parse-changelog.sh $(TAG) > /tmp/changelog.md - - # Build and publish the release docker run \ --rm \ -e CGO_ENABLED=1 \ -e GITHUB_TOKEN="$(GITHUB_TOKEN)" \ - -v /tmp/changelog.md:/build/changelog.md \ -v /var/run/docker.sock:/var/run/docker.sock \ -v $(HOME)/.docker/config.json:/root/.docker/config.json \ -v `pwd`:/go/src/$(PACKAGE_NAME) \ -v `pwd`/sysroot:/sysroot \ -w /go/src/$(PACKAGE_NAME) \ ghcr.io/goreleaser/goreleaser-cross:v1.19.5 \ - release --clean --release-notes /build/changelog.md + release --clean diff --git a/suave/scripts/parse-changelog.sh b/suave/scripts/parse-changelog.sh deleted file mode 100755 index 94f52bd1d..000000000 --- a/suave/scripts/parse-changelog.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -# Define the version you want to extract -target_version=$1 - -if [ -z "$target_version" ]; then - echo "Target version is empty" - exit 1 -fi - -# Input changelog file -changelog_file="CHANGELOG.md" - -# Function to add entries to the markdown file -add_entry() { - echo -e "$1" -} - -# Flag to start processing when the target version is found -found_version=false -found_anything=false - -# Read the changelog file line by line -while IFS= read -r line; do - # Check if the line starts with the target version - if [[ $line == "## $target_version"* ]]; then - echo "## Changelog" - found_version=true - found_anything=true - continue - elif [[ $line == "## "* ]]; then - # We moved to another version, stop processing - found_version=false - fi - - # If we've found the target version, start processing entries - if [ "$found_version" = true ]; then - # Add the current entry to the markdown file - add_entry "$line" - fi -done < "$changelog_file" - -# If no changelog found, return an error -if [ "$found_anything" = false ]; then - echo "No changelog found for $target_version" - exit 1 -fi \ No newline at end of file From 8fd2f79c07a014477ed0c382a96f39e4a17a13a8 Mon Sep 17 00:00:00 2001 From: Ferran Borreguero Date: Mon, 8 Jan 2024 12:01:36 +0100 Subject: [PATCH 4/4] Update docker hub --- .github/workflows/releaser.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/releaser.yml b/.github/workflows/releaser.yml index 11d45ea4f..f3b8238f0 100644 --- a/.github/workflows/releaser.yml +++ b/.github/workflows/releaser.yml @@ -19,14 +19,13 @@ jobs: - name: setup dependencies uses: actions/setup-go@v2 - - name: Login to GHCR + - name: Login to Docker hub uses: docker/login-action@v2 with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Publich ref name + - name: Log tag name run: echo "Build for tag ${{ github.ref_name }}" - name: release dry run