Skip to content

Commit

Permalink
Add Docker and goreleaser workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Themimitoof committed Aug 22, 2022
1 parent 6f8b734 commit 1e3f95b
Show file tree
Hide file tree
Showing 3 changed files with 184 additions and 0 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Docker build

on:
push:
branches:
- "main"
tags:
- "*"

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25
with:
cosign-release: 'v1.9.0'


# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
COSIGN_EXPERIMENTAL: "true"
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: goreleaser

on:
push:
tags:
- '*'

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Fetch all tags
run: git fetch --force --tags

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68 changes: 68 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
project_name: ipg

before:
hooks:
- go mod tidy

builds:
- id: ipg-binaries
env:
- CGO_ENABLED=0
goos:
- linux
# - windows # XXX: Not tested for Windows... yet.
- darwin
- freebsd
- openbsd
goarch:
- amd64
- arm
- arm64
goarm:
- 7

archives:
- replacements:
darwin: MacOS
linux: Linux
windows: Windows
amd64: x86_64
arm: armhf

nfpms:
- id: ipg-pkgs
package_name: ipg
vendor: Themimitoof
homepage: https://github.com/themimitoof/ipg
maintainer: Michael V. <dev@mvieira.fr>
license: MIT
formats:
- apk
- deb
- rpm
builds:
- ipg-binaries
replacements:
darwin: MacOS
linux: Linux
windows: Windows
amd64: x86_64
arm: armhf

checksum:
name_template: 'checksums.txt'

snapshot:
name_template: "{{ incpatch .Version }}-next"

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

release:
draft: true
footer: |
That's all for this new release of ipg {{ .Tag }}!

0 comments on commit 1e3f95b

Please sign in to comment.