From 6c5a6e85a7dc56aac664092241ba82fe960b14f1 Mon Sep 17 00:00:00 2001 From: Stefan Wichmann Date: Tue, 28 Mar 2023 19:18:44 +0200 Subject: [PATCH] Update Github Actions and Goreleaser workflows --- .github/workflows/build.yml | 6 +-- .github/workflows/release.yml | 30 ++++++----- .goreleaser.yaml | 97 +++++++++++++++++++++++++++-------- Dockerfile | 2 +- 4 files changed, 96 insertions(+), 39 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b12b262..fd0ec50 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,14 +10,14 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v4 with: - go-version: 1.17 + go-version: 1.20.2 - name: Build run: go build -v ./... diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1d3c2c9..4ebc4b0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,24 +11,28 @@ permissions: jobs: goreleaser: runs-on: ubuntu-latest + env: + DOCKER_CLI_EXPERIMENTAL: "enabled" steps: - - - name: Checkout - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v3 with: fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Login to Docker Hub + uses: docker/login-action@v2 with: - go-version: 1.17 - - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.20.2 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v3 with: - distribution: goreleaser version: latest - args: release --rm-dist + args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 0a5df50..ddb382b 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -4,32 +4,20 @@ before: - go mod tidy builds: - - - env: + - env: - CGO_ENABLED=0 - goos: - - linux - - windows - - darwin - - freebsd - - goarch: - - 386 - - amd64 - - arm - - arm64 - - goarm: - - 5 - - gomips: - - hardfloat - - softfloat + targets: + - linux_amd64 + - linux_arm_5 + - linux_arm_7 + - linux_arm64 + - windows_amd64 + - darwin_amd64 + - darwin_arm64 archives: - - - format_overrides: + - format_overrides: - goos: windows format: zip @@ -39,6 +27,8 @@ archives: - gui/* - etc/* + rlcp: true + checksum: name_template: 'checksums.txt' @@ -51,3 +41,66 @@ changelog: exclude: - '^docs:' - '^test:' + +dockers: +- image_templates: ["stefanwichmann/{{ .ProjectName }}:{{ .Version }}-amd64"] + goos: linux + goarch: amd64 + dockerfile: Dockerfile + use: buildx + build_flag_templates: + - --platform=linux/amd64 + - --label=org.opencontainers.image.title={{ .ProjectName }} + - --label=org.opencontainers.image.description={{ .ProjectName }} + - --label=org.opencontainers.image.url=https://github.com/stefanwichmann/{{ .ProjectName }} + - --label=org.opencontainers.image.source=https://github.com/stefanwichmann/{{ .ProjectName }} + - --label=org.opencontainers.image.version={{ .Version }} + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} + - --label=org.opencontainers.image.licenses=MIT + +- image_templates: ["stefanwichmann/{{ .ProjectName }}:{{ .Version }}-armv7"] + goos: linux + goarch: arm + goarm: 7 + dockerfile: Dockerfile + use: buildx + build_flag_templates: + - --platform=linux/arm/v7 + - --label=org.opencontainers.image.title={{ .ProjectName }} + - --label=org.opencontainers.image.description={{ .ProjectName }} + - --label=org.opencontainers.image.url=https://github.com/stefanwichmann/{{ .ProjectName }} + - --label=org.opencontainers.image.source=https://github.com/stefanwichmann/{{ .ProjectName }} + - --label=org.opencontainers.image.version={{ .Version }} + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} + - --label=org.opencontainers.image.licenses=MIT + +- image_templates: ["stefanwichmann/{{ .ProjectName }}:{{ .Version }}-arm64"] + goos: linux + goarch: arm64 + dockerfile: Dockerfile + use: buildx + build_flag_templates: + - --platform=linux/arm64/v8 + - --label=org.opencontainers.image.title={{ .ProjectName }} + - --label=org.opencontainers.image.description={{ .ProjectName }} + - --label=org.opencontainers.image.url=https://github.com/stefanwichmann/{{ .ProjectName }} + - --label=org.opencontainers.image.source=https://github.com/stefanwichmann/{{ .ProjectName }} + - --label=org.opencontainers.image.version={{ .Version }} + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} + - --label=org.opencontainers.image.licenses=MIT + +docker_manifests: +- name_template: stefanwichmann/{{ .ProjectName }}:{{ .Version }} + image_templates: + - stefanwichmann/{{ .ProjectName }}:{{ .Version }}-amd64 + - stefanwichmann/{{ .ProjectName }}:{{ .Version }}-armv7 + - stefanwichmann/{{ .ProjectName }}:{{ .Version }}-arm64 + +- name_template: stefanwichmann/{{ .ProjectName }}:latest + image_templates: + - stefanwichmann/{{ .ProjectName }}:{{ .Version }}-amd64 + - stefanwichmann/{{ .ProjectName }}:{{ .Version }}-armv7 + - stefanwichmann/{{ .ProjectName }}:{{ .Version }}-arm64 diff --git a/Dockerfile b/Dockerfile index 5197a86..724ee5e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,6 @@ WORKDIR /opt/kelvin VOLUME /etc/opt/kelvin RUN apk --no-cache add ca-certificates tzdata && update-ca-certificates -COPY dist/kelvin-linux-amd64-v* /opt/kelvin/ +COPY kelvin /opt/kelvin/ ENTRYPOINT /opt/kelvin/kelvin -enableWebInterface -configuration=/etc/opt/kelvin/config.json 2>&1 | tee /var/log/kelvin.log