Fix docker #14
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*' | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| build-and-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.25' | |
| - 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: 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" | |
| # Linux AMD64 for the indexer and the API (adjust ldflags packages as needed) | |
| GOOS=linux GOARCH=amd64 go build -ldflags="-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}" -o build/indexer indexer/indexer.go | |
| GOOS=linux GOARCH=amd64 go build -ldflags="-X main.Commit=${GIT_COMMIT} -X main.Version=${VERSION}" -o build/api api/main.go | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| 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@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| 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 |