chore: update CHANGELOG.md #26
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| jobs: | |
| build-and-release: | |
| name: Build and Release | |
| permissions: | |
| contents: write | |
| packages: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - name: Setup Go | |
| uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4 | |
| with: | |
| go-version: "1.26.4" | |
| - name: Get version | |
| id: version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| # Check if this is a pre-release (contains alpha, beta, rc, etc.) | |
| if [[ $VERSION =~ (alpha|beta|rc) ]]; then | |
| echo "prerelease=true" >> $GITHUB_OUTPUT | |
| echo "docker_tag=dev" >> $GITHUB_OUTPUT | |
| else | |
| echo "prerelease=false" >> $GITHUB_OUTPUT | |
| echo "docker_tag=latest" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Get git metadata | |
| id: gitmeta | |
| run: | | |
| # actions/checkout provides the .git directory so these commands will work | |
| echo "git_commit=$(git rev-parse --short HEAD 2>/dev/null || echo unknown)" >> $GITHUB_OUTPUT | |
| echo "git_tag=$(git describe --tags --exact-match 2>/dev/null || echo)" >> $GITHUB_OUTPUT | |
| echo "git_branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo)" >> $GITHUB_OUTPUT | |
| - name: Install arm64 cross-compiler | |
| run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
| - name: Build binaries | |
| env: | |
| GIT_COMMIT: ${{ steps.gitmeta.outputs.git_commit }} | |
| GIT_TAG: ${{ steps.gitmeta.outputs.git_tag }} | |
| GIT_BRANCH: ${{ steps.gitmeta.outputs.git_branch }} | |
| VERSION_INPUT: ${{ steps.version.outputs.version }} | |
| run: | | |
| mkdir -p build | |
| # Compute VERSION (prefer tag, otherwise branch-commit) | |
| if [ -n "$GIT_TAG" ]; then | |
| VERSION="$GIT_TAG" | |
| else | |
| VERSION="${GIT_BRANCH}-${GIT_COMMIT}" | |
| fi | |
| echo "Building with VERSION=$VERSION, GIT_COMMIT=$GIT_COMMIT" | |
| go mod download | |
| LDFLAGS_INDEXER="-X github.com/Cogwheel-Validator/spectra-gnoland-indexer/indexer/cmd.Commit=${GIT_COMMIT} -X github.com/Cogwheel-Validator/spectra-gnoland-indexer/indexer/cmd.Version=${VERSION} -w -s" | |
| LDFLAGS_API="-X main.Commit=${GIT_COMMIT} -X main.Version=${VERSION} -w -s" | |
| # amd64 | |
| GOOS=linux GOARCH=amd64 go build -ldflags="$LDFLAGS_INDEXER" -o build/indexer-linux-amd64 indexer/cmd/indexer.go | |
| GOOS=linux GOARCH=amd64 go build -ldflags="$LDFLAGS_API" -o build/api-linux-amd64 api/*.go | |
| # arm64 | |
| GOOS=linux GOARCH=arm64 go build -ldflags="$LDFLAGS_INDEXER" -o build/indexer-linux-arm64 indexer/cmd/indexer.go | |
| GOOS=linux GOARCH=arm64 go build -ldflags="$LDFLAGS_API" -o build/api-linux-arm64 api/*.go | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: build/* | |
| prerelease: ${{ steps.version.outputs.prerelease }} | |
| generate_release_notes: true | |
| body: | | |
| ## Release ${{ steps.version.outputs.version }} | |
| ### Installation for the indexer | |
| Download the binary for your platform and make it executable: | |
| ```bash | |
| chmod +x indexer-* | |
| ``` | |
| You will need to set up the database for the indexer, check the docs for more information. | |
| To generate a default config use: | |
| ```bash | |
| indexer setup create-config | |
| ``` | |
| This will create a config.yml in the current directory. | |
| When you have the database running run the cmd to create the database and the user. | |
| ```bash | |
| indexer setup create-db --db-host localhost --db-port 5432 --db-user postgres --db-name postgres --ssl-mode disable --new-db-name gnoland --chain-name gnoland | |
| indexer setup create-user --db-host localhost --db-port 5432 --db-user postgres --db-name postgres --ssl-mode disable --user writer --privilege writer | |
| ``` | |
| From here you can run the indexer using live or historic mode | |
| ```bash | |
| ./indexer run live --config config.yml | |
| ./indexer run historic --config config.yml --from-height 1 --to-height 2000 | |
| ``` | |
| For more information check the docs. | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker Indexer image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: Dockerfile | |
| push: true | |
| platforms: linux/amd64 | |
| tags: | | |
| ghcr.io/cogwheel-validator/spectra-gnoland-indexer:${{ steps.version.outputs.version }} | |
| ghcr.io/cogwheel-validator/spectra-gnoland-indexer:${{ steps.version.outputs.docker_tag }} | |
| build-args: | | |
| VERSION=${{ steps.version.outputs.version }} | |
| GIT_COMMIT=${{ steps.gitmeta.outputs.git_commit }} | |
| GIT_TAG=${{ steps.gitmeta.outputs.git_tag }} | |
| GIT_BRANCH=${{ steps.gitmeta.outputs.git_branch }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Build and push Docker API image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: Dockerfile-api | |
| push: true | |
| platforms: linux/amd64 | |
| tags: | | |
| ghcr.io/cogwheel-validator/spectra-gnoland-api:${{ steps.version.outputs.version }} | |
| ghcr.io/cogwheel-validator/spectra-gnoland-api:${{ steps.version.outputs.docker_tag }} | |
| build-args: | | |
| VERSION=${{ steps.version.outputs.version }} | |
| GIT_COMMIT=${{ steps.gitmeta.outputs.git_commit }} | |
| GIT_TAG=${{ steps.gitmeta.outputs.git_tag }} | |
| GIT_BRANCH=${{ steps.gitmeta.outputs.git_branch }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |