Skip to content

Commit

Permalink
feat: goreleaser overhaul with apple signed binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
ekristen committed Feb 4, 2024
1 parent 1507be8 commit 1fd3ef0
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 70 deletions.
101 changes: 101 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: goreleaser

on:
workflow_dispatch:
push:
branches:
- main
- next
tags:
- "*"
release:
types:
- published

permissions:
contents: write
packages: write
id-token: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
if: github.event_name == 'pull_request'
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- uses: actions/checkout@v4
if: github.event_name != 'pull_request'
with:
fetch-depth: 0
- name: setup-go
uses: actions/setup-go@v5
with:
go-version: 1.21.x
- name: setup qemu
id: qemu
uses: docker/setup-qemu-action@v3
- name: setup docker buildx
id: 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: install cosign
uses: sigstore/cosign-installer@v3
- name: install quill
env:
QUILL_VERSION: 0.4.1
run: |
curl -Lo /tmp/quill_${QUILL_VERSION}_linux_amd64.tar.gz https://github.com/anchore/quill/releases/download/v${QUILL_VERSION}/quill_${QUILL_VERSION}_linux_amd64.tar.gz
tar -xvf /tmp/quill_${QUILL_VERSION}_linux_amd64.tar.gz -C /tmp
mv /tmp/quill /usr/local/bin/quill
chmod +x /usr/local/bin/quill
- name: set goreleaser default args
if: startsWith(github.ref, 'refs/tags/') == true
run: |
echo "GORELEASER_ARGS=" >> $GITHUB_ENV
- name: set goreleaser args for branch
if: startsWith(github.ref, 'refs/tags/') == false
run: |
echo "GORELEASER_ARGS=--snapshot" >> $GITHUB_ENV
- name: set goreleaser args renovate
if: startsWith(github.ref, 'refs/heads/renovate') == true
run: |
echo "GORELEASER_ARGS=--snapshot --skip publish --skip sign" >> $GITHUB_ENV
- name: setup-quill
uses: 1password/load-secrets-action@v1
# Extra Safeguard - This ensures the secrets are only loaded on tag and a tag that the repo owner triggered
if: startsWith(github.ref, 'refs/tags/') == true && github.actor == github.repository_owner
with:
export-env: true
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
QUILL_NOTARY_KEY: ${{ secrets.OP_QUILL_NOTARY_KEY }}
QUILL_NOTARY_KEY_ID: ${{ secrets.OP_QUILL_NOTARY_KEY_ID }}
QUILL_NOTARY_ISSUER: ${{ secrets.OP_QUILL_NOTARY_ISSUER }}
QUILL_SIGN_PASSWORD: ${{ secrets.OP_QUILL_SIGN_PASSWORD }}
QUILL_SIGN_P12: ${{ secrets.OP_QUILL_SIGN_P12 }}
- name: run goreleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean ${{ env.GORELEASER_ARGS }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: push docker images (for branches)
if: github.ref == 'refs/heads/main' || github.event.pull_request.base.ref == 'main'
run: |
docker images --format "{{.Repository}}:{{.Tag}}" | grep "${{ github.repository }}" | xargs -L1 docker push
- name: upload artifacts
if: github.event.pull_request.base.ref == 'main'
uses: actions/upload-artifact@v4
with:
name: binaries
path: releases/*.tar.gz
54 changes: 0 additions & 54 deletions .github/workflows/release.yaml

This file was deleted.

40 changes: 27 additions & 13 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ release:
github:
owner: ekristen
name: azure-nuke
extra_files:
- glob: ./cosign.pub
builds:
- id: default
env:
Expand All @@ -29,9 +27,21 @@ builds:
ldflags:
- -s
- -w
- -extldflags="-static"
- -X '{{ .ModulePath }}/pkg/common.SUMMARY={{ .Version }}'
- -X '{{ .ModulePath }}/pkg/common.BRANCH={{ .Branch }}'
- -X '{{ .ModulePath }}/pkg/common.VERSION={{ .Tag }}'
- -X '{{ .ModulePath }}/pkg/common.COMMIT={{ .Commit }}'
hooks:
post:
- cmd: |
{{- if eq .Os "darwin" -}}
quill sign-and-notarize "{{ .Path }}" --dry-run={{ .IsSnapshot }} --ad-hoc={{ .IsSnapshot }} -vv
{{- else -}}
true
{{- end -}}
env:
- QUILL_LOG_FILE=/tmp/quill-{{ .Target }}.log
archives:
- id: default
builds:
Expand Down Expand Up @@ -95,21 +105,25 @@ docker_manifests:
- ghcr.io/ekristen/azure-nuke:v{{ .Version }}-arm64
- ghcr.io/ekristen/azure-nuke:v{{ .Version }}-arm32v7
signs:
- cmd: cosign
stdin: "{{ .Env.COSIGN_PASSWORD }}"
args:
["sign-blob", "--key=cosign.key", "--output=${signature}", "${artifact}"]
- ids:
- default
- darwin
cmd: cosign
signature: "${artifact}.sig"
certificate: "${artifact}.pem"
args: ["sign-blob", "--yes", "--oidc-provider=github", "--oidc-issuer=https://token.actions.githubusercontent.com", "--output-certificate=${certificate}", "--output-signature=${signature}", "${artifact}"]
artifacts: all
docker_signs:
- artifacts: all
stdin: "{{ .Env.COSIGN_PASSWORD }}"
- ids:
- default
artifacts: all
cmd: cosign
args: ["sign", "--yes", "--oidc-provider=github", "--oidc-issuer=https://token.actions.githubusercontent.com", "--output-certificate=${certificate}", "--output-signature=${signature}", "${artifact}"]
checksum:
name_template: "checksums.txt"
snapshot:
name_template: '{{ trimprefix .Summary "v" }}'
# We are skipping changelog because we are using semantic release
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
skip: true

3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# syntax=docker/dockerfile:1.3-labs
FROM alpine:3.16.0 as base
ARG PROJECT_NAME=azure-nuke
RUN apk add --no-cache ca-certificates
RUN useradd -D azure-nuke
RUN adduser -D azure-nuke

FROM ghcr.io/acorn-io/images-mirror/golang:1.21 AS build
COPY / /src
Expand Down
4 changes: 2 additions & 2 deletions cosign.pub
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEKQCJH3WJCprZ5uTdK6dJT4BNMh6S
QUHAUH8PlFwEHDgQmU7+iaZPawO2kQfK5h21XYKozyMoJTCAU58OyBPdig==
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEG3iKhzhU316JraFaQfqynAfegPdC
gYII2iOCpmxJa4YK2WWEj+l2Ok1zeZmn71U4QTkIRr1PSU7eOk2eVnaS+g==
-----END PUBLIC KEY-----

0 comments on commit 1fd3ef0

Please sign in to comment.