diff --git a/.github/goreleaser.yaml b/.github/goreleaser.yaml new file mode 100644 index 00000000..263513ab --- /dev/null +++ b/.github/goreleaser.yaml @@ -0,0 +1,88 @@ +project_name: tx-indexer + +before: + hooks: + - go mod tidy + +builds: + - main: ./cmd + binary: tx-indexer + goos: + - linux + - darwin + goarch: + - amd64 + - arm64 + +gomod: + proxy: true + +archives: + - name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" + +signs: + - cmd: cosign + env: + - COSIGN_EXPERIMENTAL=1 + certificate: '${artifact}.pem' + args: + - sign-blob + - '--output-certificate=${certificate}' + - '--output-signature=${signature}' + - '${artifact}' + - "--yes" # needed on cosign 2.0.0+ + artifacts: checksum + output: true + +dockers: + - image_templates: + - "ghcr.io/gnolang/tx-indexer:latest" + - "ghcr.io/gnolang/tx-indexer:{{ .Tag }}" + dockerfile: Dockerfile.release + build_flag_templates: + - "--pull" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.name={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - "--label=org.opencontainers.image.source={{.GitURL}}" + +docker_signs: + - cmd: cosign + env: + - COSIGN_EXPERIMENTAL=1 + artifacts: images + output: true + args: + - 'sign' + - '${artifact}' + - "--yes" # needed on cosign 2.0.0+ + +checksum: + name_template: 'checksums.txt' + +changelog: + sort: asc + +source: + enabled: true + +sboms: + - artifacts: archive + - id: source # Two different sbom configurations need two different IDs + artifacts: source + +release: + draft: true + replace_existing_draft: true + prerelease: true + footer: | + ### Container Images + + https://ghcr.io/gnolang/tx-indexer:{{ .Tag }} + + For example: + ``` + docker pull ghcr.io/gnolang/tx-indexer:{{ .Tag }} + ``` + diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml deleted file mode 100644 index 737aa220..00000000 --- a/.github/workflows/docker.yaml +++ /dev/null @@ -1,38 +0,0 @@ -name: docker - -on: - push: - branches: - - "main" - tags: - - "v*" - -jobs: - docker: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ghcr.io/${{ github.repository }} - tags: | - type=raw,value=latest - type=semver,pattern=v{{version}} - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/releaser.yaml b/.github/workflows/releaser.yaml new file mode 100644 index 00000000..e5082723 --- /dev/null +++ b/.github/workflows/releaser.yaml @@ -0,0 +1,40 @@ +name: Go Releaser + +on: + push: + tags: + - "v*" + +permissions: + contents: write # needed to write releases + id-token: write # needed for keyless signing + packages: write # needed for ghcr access + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-go@v5 + with: + go-version: 1.21 + cache: true + + - uses: sigstore/cosign-installer@v3.4.0 + - uses: anchore/sbom-action/download-syft@v0.15.10 + + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: goreleaser/goreleaser-action@v5 + with: + version: latest + args: release --clean --config ./.github/goreleaser.yaml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Makefile b/Makefile index d59bdf16..d692902d 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ all: build .PHONY: build build: @echo "Building indexer binary" - go build -o build/indexer ./cmd + go build -o build/tx-indexer ./cmd .PHONY: lint lint: