Skip to content

Commit

Permalink
refactor: add install script (#915)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemijspavlovs authored Sep 11, 2024
1 parent 0fccdb3 commit 3826c1b
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 57 deletions.
31 changes: 12 additions & 19 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
release:
name: release
runs-on: ["self-hosted"]
runs-on: ubuntu-latest
permissions:
pull-requests: write
actions: read
Expand All @@ -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
109 changes: 90 additions & 19 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
# ---------------------------------------------------------------------------- #
Expand Down
27 changes: 9 additions & 18 deletions install.sh
Original file line number Diff line number Diff line change
@@ -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."

0 comments on commit 3826c1b

Please sign in to comment.