Skip to content

Commit

Permalink
chore(ci): rework ci for ghcr (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
mloiseleur authored Apr 19, 2024
1 parent 7a3b8df commit 164f235
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 30 deletions.
34 changes: 15 additions & 19 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
name: Build and Test

on:
push:
branches:
- 'main'
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
branches:
- '*'
- 'main'

permissions:
contents: write

jobs:
build:
if: "!github.event.pull_request.draft"
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
runs-on: ${{ matrix.os }}
name: Build & Test
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Setup go
uses: actions/setup-go@v2
- name: Checkout
uses: actions/checkout@v4

- name: Setup go
uses: actions/setup-go@v5
with:
go-version: '^1.16.0'
-
name: Download dependencies

- name: Download dependencies
run: go mod download
-
name: Build & Test

- name: Build & Test
run: |
go build -o ./helm-changelog -v ./cmd/
go test ./...
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
args: release --snapshot --skip-publish --rm-dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,30 @@ on:
tags:
- v*.*.*

permissions:
contents: write
packages: write

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

- name: Setup go
uses: actions/setup-go@v5
with:
go-version: '^1.16.0'
-
name: Download dependencies

- name: Download dependencies
run: go mod download
-
name: Release via goreleaser
uses: goreleaser/goreleaser-action@v2

- name: Release via goreleaser
uses: goreleaser/goreleaser-action@v5
with:
args: release --rm-dist
env:
Expand Down
97 changes: 97 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
project_name: helm-changelog

builds:
- binary: helm-changelog
main: ./

env:
- CGO_ENABLED=0
flags:
- -trimpath
ldflags:
- -s -w -X main.version={{.Version}}

goos:
- windows
- darwin
- linux
goarch:
- amd64
- arm64

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^doc:'
- '^chore:'
- '^test:'
- '^tests:'

archives:
- id: helm-changelog
name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
format: tar.gz
format_overrides:
- goos: windows
format: zip
files:
- LICENSE

docker_manifests:
- name_template: 'ghcr.io/traefik/helm-changelog:{{ .Tag }}'
image_templates:
- 'ghcr.io/traefik/helm-changelog:{{ .Tag }}-amd64'
- 'ghcr.io/traefik/helm-changelog:{{ .Tag }}-arm64'
- name_template: 'ghcr.io/traefik/helm-changelog:latest'
image_templates:
- 'ghcr.io/traefik/helm-changelog:{{ .Tag }}-amd64'
- 'ghcr.io/traefik/helm-changelog:{{ .Tag }}-arm64'
- name_template: 'ghcr.io/traefik/helm-changelog:v{{ .Major }}.{{ .Minor }}'
image_templates:
- 'ghcr.io/traefik/helm-changelog:v{{ .Major }}.{{ .Minor }}-amd64'
- 'ghcr.io/traefik/helm-changelog:v{{ .Major }}.{{ .Minor }}-arm64'

dockers:
- use: buildx
goos: linux
goarch: amd64
dockerfile: buildx.Dockerfile
image_templates:
- 'ghcr.io/traefik/helm-changelog:latest-amd64'
- 'ghcr.io/traefik/helm-changelog:{{ .Tag }}-amd64'
- 'ghcr.io/traefik/helm-changelog:v{{ .Major }}.{{ .Minor }}-amd64'
build_flag_templates:
- '--pull'
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
- '--label=org.opencontainers.image.title={{.ProjectName}}'
- '--label=org.opencontainers.image.description=Myrmica Bibikoffi - Closes stale issues'
- '--label=org.opencontainers.image.source={{.GitURL}}'
- '--label=org.opencontainers.image.url={{.GitURL}}'
- '--label=org.opencontainers.image.documentation={{.GitURL}}'
- '--label=org.opencontainers.image.created={{.Date}}'
- '--label=org.opencontainers.image.revision={{.FullCommit}}'
- '--label=org.opencontainers.image.version={{.Version}}'
- '--platform=linux/amd64'

- use: buildx
goos: linux
goarch: arm64
dockerfile: buildx.Dockerfile
image_templates:
- 'ghcr.io/traefik/helm-changelog:latest-arm64'
- 'ghcr.io/traefik/helm-changelog:{{ .Tag }}-arm64'
- 'ghcr.io/traefik/helm-changelog:v{{ .Major }}.{{ .Minor }}-arm64'
build_flag_templates:
- '--pull'
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
- '--label=org.opencontainers.image.title={{.ProjectName}}'
- '--label=org.opencontainers.image.description=Myrmica Bibikoffi - Closes stale issues'
- '--label=org.opencontainers.image.source={{.GitURL}}'
- '--label=org.opencontainers.image.url={{.GitURL}}'
- '--label=org.opencontainers.image.documentation={{.GitURL}}'
- '--label=org.opencontainers.image.created={{.Date}}'
- '--label=org.opencontainers.image.revision={{.FullCommit}}'
- '--label=org.opencontainers.image.version={{.Version}}'
- '--platform=linux/arm64'

0 comments on commit 164f235

Please sign in to comment.