Skip to content

Commit

Permalink
Update the Build and Release Process (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanio authored Jul 27, 2024
2 parents d4e52f5 + e669257 commit 8cf6410
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 47 deletions.
17 changes: 17 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
codecov:
require_ci_to_pass: false
notify:
wait_for_ci: false
coverage:
status:
project:
default:
target: auto
comment:
layout: 'diff, flags, files'
behavior: default
require_changes: true
require_base: false
require_head: true
hide_project_coverage: false
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Before raising or requesting a review of the pull request, please check and confirm the following items have been performed, where possible:

- [ ] I have performed a self-review of my code and run any tests locally to check
- [ ] I have added tests that prove the any changes are effective and work correctly
- [ ] I have added tests that prove that any changes are effective and work correctly
- [ ] I have any made corresponding changes, as needed, to the repository documentation
- [ ] Each commit in, and this pull request, have meaningful subjects and bodies for context
- [ ] I have added `release/...`, `type/...`, and `changes/...` labels, as needed, to this pull request
36 changes: 32 additions & 4 deletions .github/workflows/integrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ jobs:
distribution: goreleaser
version: '~> v2'
args: >-
build
release
--clean
--timeout 5m
--skip publish
--snapshot
--single-target
--timeout 5m
- name: Upload Build
- name: Upload linux_amd64_v3
uses: actions/upload-artifact@v4
with:
name: dashboard_linux_amd64_v3
Expand All @@ -158,6 +158,34 @@ jobs:
# pull request to continue and merge, potentially breaking the release
if-no-files-found: error

- name: Upload linux_arm64
uses: actions/upload-artifact@v4
with:
name: dashboard_linux_arm64
path: dist/dashboard_linux_arm64/
if-no-files-found: error

- name: Upload darwin_arm64
uses: actions/upload-artifact@v4
with:
name: dashboard_darwin_arm64
path: dist/dashboard_darwin_arm64/
if-no-files-found: error

- name: Upload windows_amd64_v3
uses: actions/upload-artifact@v4
with:
name: dashboard_windows_amd64_v3
path: dist/dashboard_windows_amd64_v3/
if-no-files-found: error

- name: Upload windows_arm64
uses: actions/upload-artifact@v4
with:
name: dashboard_windows_arm64
path: dist/dashboard_windows_arm64/
if-no-files-found: error

- name: Upload Metadata
uses: actions/upload-artifact@v4
with:
Expand Down
63 changes: 41 additions & 22 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ release:
owner: n3tuk
name: dashboard
name_template: |-
{{ .Tag }}
{{ .Version }}
changelog:
disable: true
snapshot:
name_template: >-
{{ incpatch .Version }}~dev{{ .Now.Format "-20060102-1504" }}
{{ incpatch .Version }}~d{{ .Now.Format "0601021504" }}
checksum:
name_template: |-
{{ .ProjectName }}-sha512
dashboard-sha512
algorithm: sha3-512

builds:
- id: dashboard
main: main.go
binary: dashboard
mod_timestamp: '{{ .CommitTimestamp }}'
env:
- CGO_ENABLED=0
ldflags: >-
Expand All @@ -37,19 +38,24 @@ builds:
all=-trimpath=.
goos:
- 'linux'
- 'darwin'
- 'windows'
goarch:
- 'arm64'
- 'amd64'
goarm:
- '7'
goamd64:
- 'v3'
ignore:
- goos: darwin
goarch: amd64

archives:
- id: dashboard-archive
- id: archive
name_template: |-
{{ .ProjectName }}-{{ .Version }}-{{ tolower .Os }}-{{ tolower .Arch }}
format: tar.gz
{{ .ProjectName }}-v{{ .Version }}-{{ tolower .Os }}-{{ tolower .Arch }}
format: zip
builds_info:
group: root
owner: root
Expand All @@ -58,50 +64,63 @@ archives:
files:
- LICENSE

# Create images for both amd64 and arm64 to give it the widest possible support
dockers:
- id: '{{ .ProjectName }}-amd64'
- id: amd64
goarch: amd64
goamd64: v3
image_templates:
- ghcr.io/n3tuk/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/n3tuk/dashboard:{{ .ShortCommit }}-amd64
dockerfile: Dockerfile
use: docker
skip_push: false
build_flag_templates:
- --platform=linux/amd64
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ .Date }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}

- id: '{{ .ProjectName }}-arm64'
- id: arm64
goarch: arm64
goarm: 7
image_templates:
- ghcr.io/n3tuk/{{ .ProjectName }}:{{ .Version }}-arm64
- ghcr.io/n3tuk/dashboard:{{ .ShortCommit }}-arm64
dockerfile: Dockerfile
use: docker
skip_push: false
build_flag_templates:
- --platform=linux/arm64
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ .Date }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}

# Build a set of manifests based on all the ways the GitHub Action could be
# called, including as the main branch, both short and long commit IDs, and each of
# Major, Major/Minor, and Major/Minor/Patch versions being tagged
docker_manifests:
- name_template: ghcr.io/n3tuk/{{ .ProjectName }}:latest
- name_template: ghcr.io/n3tuk/dashboard:latest
use: docker
skip_push: auto
image_templates:
- ghcr.io/n3tuk/dashboard:{{ .ShortCommit }}-amd64
- ghcr.io/n3tuk/dashboard:{{ .ShortCommit }}-arm64

- name_template: ghcr.io/n3tuk/dashboard:v{{ .Major }}
use: docker
skip_push: auto
image_templates:
- ghcr.io/n3tuk/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/n3tuk/{{ .ProjectName }}:{{ .Version }}-arm64
- ghcr.io/n3tuk/dashboard:{{ .ShortCommit }}-amd64
- ghcr.io/n3tuk/dashboard:{{ .ShortCommit }}-arm64

- name_template: ghcr.io/n3tuk/{{ .ProjectName }}:{{ .Version }}
- name_template: ghcr.io/n3tuk/dashboard:v{{ .Version }}
use: docker
skip_push: auto
image_templates:
- ghcr.io/n3tuk/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/n3tuk/{{ .ProjectName }}:{{ .Version }}-arm64
- ghcr.io/n3tuk/dashboard:{{ .ShortCommit }}-amd64
- ghcr.io/n3tuk/dashboard:{{ .ShortCommit }}-arm64

- name_template: ghcr.io/n3tuk/{{ .ProjectName }}:{{ .ShortCommit }}
- name_template: ghcr.io/n3tuk/dashboard:{{ .ShortCommit }}
use: docker
skip_push: false
image_templates:
- ghcr.io/n3tuk/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/n3tuk/{{ .ProjectName }}:{{ .Version }}-arm64
- ghcr.io/n3tuk/dashboard:{{ .ShortCommit }}-amd64
- ghcr.io/n3tuk/dashboard:{{ .ShortCommit }}-arm64
22 changes: 20 additions & 2 deletions .taskfiles/jsonschema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ tasks:
- Taskfiles (Taskfile.yaml, .taskfiles/*.yaml)
- GitHub Dependabot configuration (.github/dependabot.yaml)
- GitHub Workflows (.github/workflows/*.yaml)
- pre-commit Configuration (.pre-commit-config)
- pre-commit Configuration (.pre-commit-config.yaml)
- CodeCov Configuration (.codecov.yml)
silent: true
cmds:
- task: taskfiles
- task: dependabot
- task: workflows
- task: pre-commit
- task: codecov
- task: serve
- task: send

Expand Down Expand Up @@ -79,6 +81,22 @@ tasks:
{{ .files }}
echo -e '{{ .cg }}Passed{{ .cc }}'
codecov:
internal: true
silent: true
sources:
- '.codecov.yml'
cmds:
# Check that the dependabot.yaml file exists first, and fail cleanly if
# that is the case, otherwise check-jsonschema will fail the check
- cmd: |-
[[ -f .codecov.yml ]] || exit 0
check-jsonschema \
--output-format text --verbose \
--schemafile https://json.schemastore.org/codecov.json \
.codecov.yml
echo -e '{{ .cg }}Passed{{ .cc }}'
pre-commit:
internal: true
silent: true
Expand All @@ -89,7 +107,7 @@ tasks:
[[ -f .pre-commit-config.yaml ]] || exit 0
check-jsonschema \
--output-format text --no-cache --verbose \
--schemafile https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/pre-commit-config.json \
--schemafile https://json.schemastore.org/pre-commit-config.json \
.pre-commit-config.yaml
echo -e '{{ .cg }}Passed{{ .cc }}'
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ LABEL maintainer="Jonathan Wright <[email protected]>" \
org.opencontainers.image.authors="Jonathan Wright <[email protected]>" \
org.opencontainers.image.url="https://github.com/n3tuk/dashboard" \
org.opencontainers.image.source="https://github.com/n3tuk/dashboard/blob/Dockerfile" \
org.opencontainers.image.vendor="n3t.uk"
org.opencontainers.image.vendor="n3t.uk" \
org.opencontainers.image.licenses="MIT"

COPY dashboard /go/bin/dashboard

Expand Down
20 changes: 3 additions & 17 deletions internal/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"
"path/filepath"

"github.com/MakeNowJust/heredoc/v2"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -70,24 +69,11 @@ func runVersion(cmd *cobra.Command, _ []string) {
if err == nil && json {
// Rather than go down the rabbit whole of marshalling JSON, just create the
// raw strong which can be parsed further down as an alternate output
output = heredoc.Doc(`
{
"application":"%s",
"version":"%s",
"arch":"%s",
"build-date":"%s",
"commit":"%s",
"branch":"%s"
}
`)
output = `{"application":"%s","version":"%s","arch":"%s","date":"%s","branch":"%s","commit":"%s"}`
} else {
output = heredoc.Doc(`
%s %s
built for %s on %s
commit %s on branch %s
`)
output = "%s %s (%s)\nbuilt %s\n (%s/%s)"
}

//nolint:forbidigo // This is a genuine output to the console
fmt.Printf(output, Application, Version, Architecture, BuildDate, Commit, Branch)
fmt.Printf(output, Application, Version, Architecture, BuildDate, Branch, Commit)
}

0 comments on commit 8cf6410

Please sign in to comment.