diff --git a/.github/goreleaser.yaml b/.github/goreleaser.yaml new file mode 100644 index 0000000..693b170 --- /dev/null +++ b/.github/goreleaser.yaml @@ -0,0 +1,157 @@ +project_name: tx-archive + +before: + hooks: + - go mod tidy + - go generate ./... + +builds: + - main: ./cmd + binary: tx-archive + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + goarch: + - amd64 + - arm64 + - arm + goarm: + - 6 + - 7 + +gomod: + proxy: true + +archives: + # https://goreleaser.com/customization/archive/ + - files: + # Standard Release Files + - LICENSE.md + - README.md + +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: + # https://goreleaser.com/customization/docker/ + - use: buildx + dockerfile: Dockerfile.release + goos: linux + goarch: amd64 + image_templates: + - "ghcr.io/gnolang/{{ .ProjectName }}:{{ .Version }}-amd64" + - "ghcr.io/gnolang/{{ .ProjectName }}:latest-amd64" + build_flag_templates: + - "--platform=linux/amd64" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.title={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - use: buildx + dockerfile: Dockerfile.release + goos: linux + goarch: arm64 + image_templates: + - "ghcr.io/gnolang/{{ .ProjectName }}:{{ .Version }}-arm64v8" + - "ghcr.io/gnolang/{{ .ProjectName }}:latest-arm64v8" + build_flag_templates: + - "--platform=linux/arm64/v8" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.title={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - use: buildx + dockerfile: Dockerfile.release + goos: linux + goarch: arm + goarm: 6 + image_templates: + - "ghcr.io/gnolang/{{ .ProjectName }}:{{ .Version }}-armv6" + - "ghcr.io/gnolang/{{ .ProjectName }}:latest-armv6" + build_flag_templates: + - "--platform=linux/arm/v6" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.title={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - use: buildx + dockerfile: Dockerfile.release + goos: linux + goarch: arm + goarm: 7 + image_templates: + - "ghcr.io/gnolang/{{ .ProjectName }}:{{ .Version }}-armv7" + - "ghcr.io/gnolang/{{ .ProjectName }}:latest-armv7" + build_flag_templates: + - "--platform=linux/arm/v7" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.title={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" +docker_manifests: + # https://goreleaser.com/customization/docker_manifest/ + - name_template: ghcr.io/gnolang/{{ .ProjectName }}:{{ .Version }} + image_templates: + - ghcr.io/gnolang/{{ .ProjectName }}:{{ .Version }}-amd64 + - ghcr.io/gnolang/{{ .ProjectName }}:{{ .Version }}-arm64v8 + - ghcr.io/gnolang/{{ .ProjectName }}:{{ .Version }}-armv6 + - ghcr.io/gnolang/{{ .ProjectName }}:{{ .Version }}-armv7 + - name_template: ghcr.io/gnolang/{{ .ProjectName }}:latest + image_templates: + - ghcr.io/gnolang/{{ .ProjectName }}:latest-amd64 + - ghcr.io/gnolang/{{ .ProjectName }}:latest-arm64v8 + - ghcr.io/gnolang/{{ .ProjectName }}:latest-armv6 + - ghcr.io/gnolang/{{ .ProjectName }}:latest-armv7 + +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/{{ .ProjectName }}:{{ .Tag }} + + For example: + ``` + docker pull ghcr.io/gnolang/{{ .ProjectName }}:{{ .Tag }} + ``` + diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ef0b426..03a85a3 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,15 +1,15 @@ -name: goreleaser +name: Go Releaser on: push: # run only against tags tags: - - "*" + - "v*" permissions: - contents: write - packages: write - issues: write + contents: write # needed to write releases + id-token: write # needed for keyless signing + packages: write # needed for ghcr access jobs: goreleaser: @@ -19,18 +19,27 @@ jobs: with: fetch-depth: 0 - run: git fetch --force --tags + - uses: actions/setup-go@v5 with: - go-version: stable + go-version: 1.20 + 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: "gnolang" + username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - uses: goreleaser/goreleaser-action@v5 with: - distribution: goreleaser version: latest - args: release --clean + args: release --clean --config ./.github/goreleaser.yaml env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml deleted file mode 100644 index b546eaf..0000000 --- a/.goreleaser.yaml +++ /dev/null @@ -1,38 +0,0 @@ -before: - hooks: - - go mod tidy - - go generate ./... - -builds: - - env: - - CGO_ENABLED=0 - goos: - - linux - - darwin - - windows - main: ./cmd - -dockers: - - dockerfile: Dockerfile.release - image_templates: - - "ghcr.io/gnolang/tx-archive:latest" - - "ghcr.io/gnolang/tx-archive:{{ .Tag }}" - - "ghcr.io/gnolang/tx-archive:v{{ .Major }}" - - "ghcr.io/gnolang/tx-archive:v{{ .Major }}.{{ .Minor }}" -archives: - - format: tar.gz - # this name template makes the OS and Arch compatible with the results of `uname`. - name_template: >- - {{ .ProjectName }}_ - {{- title .Os }}_ - {{- if eq .Arch "amd64" }}x86_64 - {{- else if eq .Arch "386" }}i386 - {{- else }}{{ .Arch }}{{ end }} - {{- if .Arm }}v{{ .Arm }}{{ end }} - -changelog: - sort: asc - filters: - exclude: - - "^docs:" - - "^test:" diff --git a/Dockerfile.release b/Dockerfile.release index 7db08b3..652fb77 100644 --- a/Dockerfile.release +++ b/Dockerfile.release @@ -1,5 +1,4 @@ FROM scratch - -COPY /tx-archive /tx-archive - -ENTRYPOINT ["/tx-archive"] +COPY tx-archive / +ENTRYPOINT [ "/tx-archive" ] +CMD [ "backup" ] \ No newline at end of file