From 3826c1bdc0e8e88757965d4b01ca8e92bdff2431 Mon Sep 17 00:00:00 2001 From: artpav <19916123+artemijspavlovs@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:21:05 +0300 Subject: [PATCH] refactor: add install script (#915) --- .github/workflows/release.yaml | 31 ++++------ .goreleaser.yaml | 109 +++++++++++++++++++++++++++------ Makefile | 2 +- install.sh | 27 +++----- 4 files changed, 112 insertions(+), 57 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 41ff8ed1..7295ad86 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -8,7 +8,7 @@ on: jobs: release: name: release - runs-on: ["self-hosted"] + runs-on: ubuntu-latest permissions: pull-requests: write actions: read @@ -35,28 +35,21 @@ jobs: ] # token must have repo write permissions ( https://github.com/googleapis/release-please/blob/main/docs/cli.md#create-a-manifest-pull-request-deprecated ) token: ${{ secrets.GITHUB_TOKEN }} - - name: Checkout - uses: actions/checkout@v3 - if: steps.release-please.outputs.release_created + - uses: actions/checkout@v4 with: - fetch-depth: 0 + fetch-depth: '0' + - name: Set up Go uses: actions/setup-go@v5 - if: steps.release-please.outputs.release_created with: + check-latest: true go-version-file: go.mod - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - if: steps.release-please.outputs.release_created - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - if: steps.release-please.outputs.release_created - # TODO: handle GCP, AWS, GitHub, Docker Hub and Azure container registries - - name: Run GoReleaser - release binaries - uses: goreleaser/goreleaser-action@v6 - with: - args: release --clean --config .goreleaser.yaml + + - name: Setup release environment env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GOPRIVATE: github.com/${{ env.GITHUB_REPOSITORY_OWNER }} - if: steps.release-please.outputs.release_created + run: |- + echo 'GITHUB_TOKEN=${{secrets.GITHUB_TOKEN}}' > .release-env + + - name: Release publish + run: make release diff --git a/.goreleaser.yaml b/.goreleaser.yaml index d5adcd19..78fd6b0d 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,36 +1,107 @@ version: 2 -project_name: roller before: hooks: - - go mod tidy + - go mod download + builds: - - id: roller - main: ./main.go + - id: "roller-darwin" + main: ./ binary: roller env: - - CGO_ENABLED=0 + - CGO_ENABLED=1 + - CC=o64-clang + - CXX=o64-clang++ goos: - - linux - darwin - - windows goarch: - amd64 + flags: + - -tags=cgo + ldflags: + - -X github.com/dymensionxyz/roller/version.BuildVersion={{.Version}} -X github.com/dymensionxyz/roller/version.BuildCommit={{.Commit}} -X github.com/dymensionxyz/roller/version.BuildTime={{.Date}} + - id: "roller-darwin-arm64" + main: ./ + binary: roller + env: + - CGO_ENABLED=1 + - CC=oa64-clang + - CXX=oa64-clang++ + goos: + - darwin + goarch: - arm64 + flags: + - -tags=cgo + ldflags: + - -X github.com/dymensionxyz/roller/version.BuildVersion={{.Version}} -X github.com/dymensionxyz/roller/version.BuildCommit={{.Commit}} -X github.com/dymensionxyz/roller/version.BuildTime={{.Date}} + - id: "roller-linux" + main: ./ + binary: roller + env: + - CGO_ENABLED=1 + - CC=gcc + - CXX=g++ + goos: + - linux + goarch: + - amd64 + flags: + - -tags=cgo + ldflags: + - -X github.com/dymensionxyz/roller/version.BuildVersion={{.Version}} -X github.com/dymensionxyz/roller/version.BuildCommit={{.Commit}} -X github.com/dymensionxyz/roller/version.BuildTime={{.Date}} + - id: "roller-linux-arm64" + main: ./ + binary: roller + env: + - CGO_ENABLED=1 + - CC=aarch64-linux-gnu-gcc + - CXX=aarch64-linux-gnu-g++ + goos: + - linux + goarch: + - arm64 + flags: + - -tags=cgo + ldflags: + - -X github.com/dymensionxyz/roller/version.BuildVersion={{.Version}} -X github.com/dymensionxyz/roller/version.BuildCommit={{.Commit}} -X github.com/dymensionxyz/roller/version.BuildTime={{.Date}} + - id: "roller-windows" + main: ./ + binary: roller + 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: + - -X github.com/dymensionxyz/roller/version.BuildVersion={{.Version}} -X github.com/dymensionxyz/roller/version.BuildCommit={{.Commit}} -X github.com/dymensionxyz/roller/version.BuildTime={{.Date}} + +archives: + - name_template: '{{ .ProjectName }}_{{- title .Os }}_{{ .Arch }}' + format_overrides: + - goos: windows + format: zip + builds: + - roller-darwin + - roller-darwin-arm64 + - roller-windows + - roller-linux + - roller-linux-arm64 + +checksum: + name_template: 'checksums.txt' changelog: - use: git - groups: - - title: Features - regexp: "^.*feat[(\\w)]*:+.*$" - order: 0 - - title: 'Bug fixes' - regexp: "^.*fix[(\\w)]*:+.*$" - order: 1 - - title: Others - order: 999 + sort: asc filters: exclude: - '^chore:' + - '^docs:' - '^test:' - '^ci:' - -# TODO: add azure, gcp and aws container registries as docker and docker manifest targets +snapshot: + name_template: "{{ .Tag }}-next" diff --git a/Makefile b/Makefile index 0c92becf..4db6576d 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ endif ldflags = -X github.com/dymensionxyz/roller/version.BuildVersion=$(VERSION) \ -X github.com/dymensionxyz/roller/version.BuildCommit=$(COMMIT) \ - -X github.com/dymensionxyz/roller/version.BuildTime=$(TIME)" + -X github.com/dymensionxyz/roller/version.BuildTime=$(TIME) BUILD_FLAGS := -ldflags '$(ldflags)' # ---------------------------------------------------------------------------- # diff --git a/install.sh b/install.sh index 9e2329b5..721cf131 100755 --- a/install.sh +++ b/install.sh @@ -1,43 +1,34 @@ #!/bin/bash + set -e -OS=$(uname -s | tr '[:upper:]' '[:lower:]') +OS=$(uname -s) ARCH=$(uname -m) + if [[ "$ARCH" == "x86_64" ]]; then ARCH="amd64" elif [[ "$ARCH" == "arm64" ]] || [[ "$ARCH" == "aarch64" ]]; then ARCH="arm64" fi -API_URL="https://api.github.com/repos/dymensionxyz/roller/releases/latest" -if [ -z "$ROLLER_RELEASE_TAG" ]; then - TGZ_URL=$(curl -s $API_URL \ + +API_URL="https://api.github.com/repos/artemijspavlovs/roller/releases/latest" +if [ "$ROLLER_RELEASE_TAG" = "" ]; then + TGZ_URL=$(curl -s "$API_URL" \ | grep "browser_download_url.*_${OS}_${ARCH}.tar.gz" \ | cut -d : -f 2,3 \ | tr -d \" \ | tr -d ' ' ) else - TGZ_URL="https://github.com/dymensionxyz/roller/releases/download/$ROLLER_RELEASE_TAG/roller_${ROLLER_RELEASE_TAG}_${OS}_${ARCH}.tar.gz" + TGZ_URL="https://github.com/artemijspavlovs/roller/releases/download/$ROLLER_RELEASE_TAG/roller_${OS}_${ARCH}.tar.gz" fi -INTERNAL_DIR="/usr/local/bin/roller_bins" ROLLER_BIN_PATH="/usr/local/bin/roller" -DYMD_BIN_PATH="/usr/local/bin/dymd" -ROLLAPP_EVM_PATH="/usr/local/bin/rollapp_evm" # The path where rollapp_evm will be installed if [ -f "$ROLLER_BIN_PATH" ] || [ -f "$ROLLAPP_EVM_PATH" ] || [ -f "$DYMD_BIN_PATH" ] || [ -d "$INTERNAL_DIR" ]; then sudo rm -f "$ROLLER_BIN_PATH" - sudo rm -f "$ROLLAPP_EVM_PATH" - sudo rm -f "$DYMD_BIN_PATH" - sudo rm -rf "$INTERNAL_DIR" fi -sudo mkdir -p "$INTERNAL_DIR" sudo mkdir -p "/tmp/roller_tmp" echo "💈 Downloading roller..." sudo curl -L "$TGZ_URL" --progress-bar | sudo tar -xz -C "/tmp/roller_tmp" echo "💈 Installing roller..." -sudo mv "/tmp/roller_tmp/roller_bins/lib"/* "$INTERNAL_DIR" -sudo mv "/tmp/roller_tmp/roller_bins/roller" "$ROLLER_BIN_PATH" -sudo mv "/tmp/roller_tmp/roller_bins/rollapp_evm" "$ROLLAPP_EVM_PATH" -sudo mv "/tmp/roller_tmp/roller_bins/dymd" "$DYMD_BIN_PATH" +sudo mv "/tmp/roller_tmp/roller" "$ROLLER_BIN_PATH" sudo chmod +x "$ROLLER_BIN_PATH" -sudo chmod +x "$ROLLAPP_EVM_PATH" -sudo chmod +x "$DYMD_BIN_PATH" sudo rm -rf "/tmp/roller_tmp" echo "💈 Installation complete! You can now use roller from your terminal."