Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add most common architectures to goreleaser. #21

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions .github/goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
project_name: supernova

before:
hooks:
- go mod tidy

builds:
- main: ./cmd
binary: supernova
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
- 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 }}
```

32 changes: 21 additions & 11 deletions .github/workflows/release-binary.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,45 @@
name: Release Binaries

permissions:
contents: write
contents: write # needed to write releases
id-token: write # needed for keyless signing
packages: write # needed for ghcr access

on:
release:
types: [ published ]
push:
tags:
- "v*"

jobs:
binary:
runs-on: ubuntu-latest
env:
working-directory: go/src/github.com/gnolang/supernova

steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.19
ajnavarro marked this conversation as resolved.
Show resolved Hide resolved


- uses: sigstore/cosign-installer@v3.4.0
- uses: anchore/sbom-action/download-syft@v0.15.10

- name: Checkout
uses: actions/checkout@v4
with:
path: ${{ env.working-directory }}
fetch-depth: 0

- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
workdir: ${{ env.working-directory }}
version: 1.13.0
args: release --rm-dist
version: latest
args: release --clean --config ./.github/goreleaser.yaml
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
9 changes: 0 additions & 9 deletions .goreleaser.yml

This file was deleted.

3 changes: 3 additions & 0 deletions Dockerfile.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM scratch
COPY supernova /
ENTRYPOINT [ "/supernova" ]
Loading