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

fix: build and sign images with goreleaser #51

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
62 changes: 7 additions & 55 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
release:
permissions:
packages: write
id-token: write
needs: tag
if: needs.tag.outputs.new-tag == 'true'
runs-on: ubuntu-latest
Expand All @@ -52,6 +53,12 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: stable
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up environment
run: echo "GOVERSION=$(go version)" >> "$GITHUB_ENV"
- name: Install Cosign
Expand All @@ -63,58 +70,3 @@ jobs:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Tar up binaries
run: tar -cvf dist.tar dist
- name: Upload binaries tar file
uses: actions/upload-artifact@v3
with:
name: dist.tar
path: dist.tar
releaseimage:
strategy:
matrix:
binary:
- go-cli-github
needs:
- tag
- release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download binaries tar file
uses: actions/download-artifact@v3
with:
name: dist.tar
- name: Untar binaries
run: tar -xvf dist.tar
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
# this id is namespaced per matrix run
id: docker_metadata
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/${{ matrix.binary }}
tags: |
${{ needs.tag.outputs.new-tag-version }}
latest
- name: Build and push ${{ matrix.binary }} container image
id: docker_build
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ steps.docker_metadata.outputs.tags }}
labels: ${{ steps.docker_metadata.outputs.labels }}
file: deploy/${{ matrix.binary }}/Dockerfile
context: dist/${{ matrix.binary }}_linux_amd64_v1
- name: Install Cosign
uses: sigstore/[email protected]
- name: Sign the container image
run: >
echo "${{ steps.docker_metadata.outputs.tags }}" |
while read -r tag; do cosign sign --yes "$tag"; done
41 changes: 41 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ builds:
-X "main.version={{.Version}}"
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
- arm64

sboms:
- artifacts: archive

signs:
- cmd: cosign
signature: "${artifact}.sig"
Expand All @@ -23,3 +31,36 @@ signs:
- "${artifact}"
- "--yes"
artifacts: checksum

dockers:
- image_templates:
- "smlx/go-cli-github:{{ .Version }}-amd64"
use: buildx
dockerfile: deploy/go-cli-github/Dockerfile
build_flag_templates:
- "--platform=linux/amd64"
- image_templates:
- "smlx/go-cli-github:{{ .Version }}-arm64v8"
use: buildx
goarch: arm64
dockerfile: deploy/go-cli-github/Dockerfile
build_flag_templates:
- "--platform=linux/arm64/v8"

docker_manifests:
- name_template: "smlx/go-cli-github:{{ .Version }}"
image_templates:
- "foo/bar:{{ .Version }}-amd64"
- "foo/bar:{{ .Version }}-arm64v8"
- name_template: "smlx/go-cli-github:latest"
image_templates:
- "foo/bar:{{ .Version }}-amd64"
- "foo/bar:{{ .Version }}-arm64v8"

docker_signs:
- args:
- "sign"
- "${artifact}@${digest}"
- "--yes"
artifacts: all
output: true
2 changes: 1 addition & 1 deletion deploy/go-cli-github/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM alpine:3.16
FROM alpine:3.19
ENTRYPOINT ["/go-cli-github"]
COPY go-cli-github /