Skip to content

Commit

Permalink
Merge pull request #7 from sundowndev/goreleaser-cfg-patch1
Browse files Browse the repository at this point in the history
Add docker & nfpm to goreleaser config
  • Loading branch information
sundowndev committed Jul 7, 2021
2 parents 433a0e3 + 62c0f98 commit b8f97f5
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 18 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,22 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Install github CLI
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0
sudo apt-add-repository https://cli.github.com/packages
sudo apt update
sudo apt install gh
gh issue list --limit 100 --state closed > /tmp/changelog.txt
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Check GoReleaser config
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: check
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist --release-notes=/tmp/changelog.txt
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
34 changes: 29 additions & 5 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ before:
- go mod tidy
- go generate ./...
signs:
- signature: "${artifact}_SHA256SUMS.gpg"
artifacts: all
args: ["-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]
- signature: "myproject_SHA256SUMS.gpg"
artifacts: checksum
args: [ "--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}" ]
builds:
- id: "myproject-build"
binary: myproject
Expand All @@ -29,9 +29,9 @@ builds:
- arm
- arm64
- 386
ldflags: -s -w -X github.com/sundowndev/goreleaser-template.version={{.Version}}
ldflags: "-X github.com/sundowndev/goreleaser-template.version={{.Version}}"
archives:
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}'
format: binary
replacements:
armv6: arm
Expand All @@ -42,3 +42,27 @@ checksum:
algorithm: sha256
snapshot:
name_template: "{{ .Tag }}-next"
dockers:
- image_templates:
- "sundowndev/goreleaser-template:latest"
- "sundowndev/goreleaser-template:{{ .Version }}"
dockerfile: Dockerfile
build_flag_templates:
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/sundowndev/goreleaser-template
- --label=org.opencontainers.image.source=https://github.com/sundowndev/goreleaser-template
- --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
- --platform=linux/amd64
nfpms:
- maintainer: sundowndev <raphael@crvx.fr>
description: sample project
homepage: https://github.com/sundowndev/goreleaser-template
license: MIT
formats:
- deb
- rpm
- apk
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM scratch
COPY myproject /usr/bin/myproject
ENTRYPOINT ["/usr/bin/myproject"]
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package main

import (
"fmt"
"github.com/sundowndev/goreleaser-template/version"
)

const version = "dev"

func main() {
fmt.Println("Hello, world!", version)
fmt.Println("Hello, world!", version.Version)
}
3 changes: 3 additions & 0 deletions version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package version

var Version = "dev"

0 comments on commit b8f97f5

Please sign in to comment.