Skip to content

Commit

Permalink
Updating GoReleaser to update commit, builddate, and version correclty
Browse files Browse the repository at this point in the history
  • Loading branch information
safaci2000 committed Feb 12, 2024
1 parent ca5a1cd commit a7b4a69
Show file tree
Hide file tree
Showing 104 changed files with 21,487 additions and 1,062 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/code_scanners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v3
- uses: actions/setup-go@v4
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21.3"
go-version: "1.21.5"
cache: false
- name: Install Task
run: sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
test:
strategy:
matrix:
go: [ {version: 1.21.3, token: 1}, {version: 1.21.3, token: 0}]
go: [ {version: 1.21.5, token: 1}, {version: 1.21.5, token: 0}]
grafana: [ 10.1.4 ]

env:
Expand All @@ -20,14 +20,14 @@ jobs:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go.version }}
- name: Verify go version
run: go version
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
Expand All @@ -40,11 +40,11 @@ jobs:
run: |
echo "token IS $TEST_TOKEN_CONFIG"
- name: Calc coverage
if: "${{ matrix.go.version == '1.21.3' && matrix.grafana == '10.1.4' && matrix.go.token == '0' }}"
if: "${{ matrix.go.version == '1.21.5' && matrix.grafana == '10.1.4' && matrix.go.token == '0' }}"
run: |
go test -v -covermode=atomic -coverprofile=coverage.out ./...
- name: Convert coverage.out to coverage.lcov
if: "${{ matrix.go.version == '1.21.3' && matrix.grafana == '10.1.4' && matrix.go.token == '0' }}"
if: "${{ matrix.go.version == '1.21.5' && matrix.grafana == '10.1.4' && matrix.go.token == '0' }}"
uses: jandelgado/[email protected]
- name: Test
if: "${{ matrix.go.token == '1' }}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/hugo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
deployHugoPages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Log in to Docker Hub
Expand All @@ -25,10 +25,10 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
version: v1.24.0
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
84 changes: 60 additions & 24 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,53 @@ before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...

source:
rlcp: true


builds:
- env:
- id: gdg
env:
- CGO_ENABLED=0
binary: gdg
ldflags: -s -w -X github.com/esnet/gdg/version.GitCommit={{ .Commit }} -X github.com/esnet/gdg/version.BuildDate={{ .Date }} -X github.com/esnet/gdg/version.Version={{ .Tag }}
ldflags: -s -w -X github.com/esnet/gdg/internal/version.GitCommit={{ .Commit }} -X github.com/esnet/gdg/internal/version.BuildDate={{ .Date }} -X github.com/esnet/gdg/internal/version.Version={{ .Tag }}
main: ./cmd/gdg
goos:
- linux
- windows
- darwin
goarch:
- arm64
- 386
- amd64
- id: gdg-generate
env:
- CGO_ENABLED=0
binary: gdg-generate
ldflags: -s -w -X github.com/esnet/gdg/internal/version.GitCommit={{ .Commit }} -X github.com/esnet/gdg/internal/version.BuildDate={{ .Date }} -X github.com/esnet/gdg/internal/version.Version={{ .Tag }}
main: ./cmd/gen
goos:
- linux
- windows
- darwin
goarch:
- arm64
- 386
- amd64

nfpms:
-
id: gdg
- id: gdg
package_name: gdg
file_name_template: "{{ .ConventionalFileName }}"
homepage: https://software.es.net/gdg/
maintainer: GDG ESNet <[email protected]>
description: |-
GDG is a tool used to manage dashboards, datasources, orgs and various entities of the Grafana application.
GDG is a tool used to manage dashboards, connections, organizations and various entities of the Grafana application.
license: BSD License
builds:
- gdg
- gdg-generate
formats:
- apk
- deb
Expand All @@ -52,57 +73,72 @@ nfpms:
- src: config/importer-example.yml
dst: /etc/gdg/importer.yml
type: config
# Simple config file
- src: config/templates-example.yml
dst: /etc/gdg/templates.yml
type: config


# ids: [ gdg gdg-generate ]
universal_binaries:
- replace: true
ids:
- gdg
- gdg-generate

release:
prerelease: auto


dockers:
-
id: gdg
# # You can have multiple Docker images.
# - # ID of the image, needed if you want to filter by it later on (e.g. on custom publishers).
- id: gdg
# # You can have multiple Docker images.
# - # ID of the image, needed if you want to filter by it later on (e.g. on custom publishers).
goos: linux
goarch: amd64
#
#
image_templates:
- "ghcr.io/esnet/gdg:latest"
- "ghcr.io/esnet/gdg:{{ .RawVersion }}"
- "ghcr.io/esnet/gdg:{{ .Major }}.{{ .Minor }}"

skip_push: false
dockerfile: "docker/Dockerfile-gorelease"
dockerfile: "docker/Dockerfile"


brews:
-
name:
- name: gdg
homepage: https://software.es.net/gdg
commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}"
description: Grafana Dash-n-Grab (GDG) -- Dashboard/DataSource Manager for grafana supporting backup/restore to local filesystem, s3, gcs, azure, and other S3 compatible storage engines.
description: Grafana Dash-n-Grab (GDG) -- Dashboard/DataSource Manager for grafana supporting backup/restore to local filesystem, s3, gcs, azure, and other S3 compatible storage engines.
folder: Formula
repository:
owner: esnet
name: homebrew-gdg
token: "{{ .Env.HOMEBREW_TOKEN }}"
branch: main
commit_author:
name: GDG ESNet
name: GDG ESNet
email: [email protected]

archives:
- name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
files:
- name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
allow_different_binary_count: true
format_overrides:
- goos: windows
format: zip
builds:
- gdg
- gdg-generate
files:
- README*
- config/importer-example.yml
- config/templates-example.yml
checksum:
name_template: "checksums.txt"
Expand Down
13 changes: 13 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
with-expecter: true
recursive: false
all: true
dir: "{{.InterfaceDir}}/mocks"
outpkg: "mocks"
filename: "{{.InterfaceName}}.go"
mockname: "{{.InterfaceName}}"
packages:
github.com/esnet/gdg/internal/service:
config:
all: true
dir: "{{.InterfaceDir}}/mocks"
outpkg: "mocks"
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ The following remote backup locations are supported:

Please find the generated documentation [here](https://software.es.net/gdg/) and the code for updating the docs is available [here](https://github.com/esnet/gdg/blob/master/documentation/content/docs/usage_guide.md)

## Quickstart

![Quickstart screen](website/static/quickstart.gif)

## Release conventions.

GDG mostly follows the semver conventions with some minor modifications.
Expand All @@ -33,7 +37,3 @@ contexts. i.e. `gdg diff dashboards prod staging` is a major divergences from

For more info, please see the release notes and documentation both available [here](https://software.es.net/gdg/)

## Quickstart

![Quickstart screen](website/static/quickstart.gif)

43 changes: 18 additions & 25 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@ dotenv: ['.env']
tasks:
default:
cmds:
- task: build
- task: build_all
install_tools:
desc: "Install required Dev tools by GDG"
cmds:
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- go install github.com/client9/misspell/cmd/misspell@latest
- go install github.com/securego/gosec/v2/cmd/gosec@master
- go install golang.org/x/vuln/cmd/govulncheck@latest
format:
desc: "Format code"
cmds:
- gofmt -w -s .
security:
desc: "Run security scan"
cmds:
Expand All @@ -51,37 +47,33 @@ tasks:
mocks:
desc: "Re-generate Mocks"
cmds:
- mockery --dir=internal/service/ --output=internal/service/mocks --outpkg=mocks --all
- rm -fr internal/service/mocks
- mockery
linux:
desc: "Build linux binary"
cmds:
- env GOOS='linux' GOARCH='amd64' go build -ldflags "{{ .LD_FLAGS }} " -o bin/{{ .BIN_NAME }}_linux
- env GOOS='linux' GOARCH='amd64' go build -ldflags "{{ .LD_FLAGS }}" -o bin/{{ .BIN_NAME }}_linux cmd/gdg/main.go
build_all:
desc: "Buiding All binaries"
cmds:
- task: build
- task: build_generate
build:
desc: "Buiding {{ .BIN_NAME }} {{ .VERSION }}"
cmds:
- echo "GOPATH=${GOPATH}"
- go build -ldflags "{{ .LD_FLAGS }}" -o bin/{{ .BIN_NAME }}
- go build -ldflags "{{ .LD_FLAGS }}" -o bin/{{ .BIN_NAME }} cmd/gdg/main.go
build_generate:
desc: "Buiding {{ .BIN_NAME }}-generate {{ .VERSION }}"
cmds:
- echo "GOPATH=${GOPATH}"
- go build -ldflags "{{ .LD_FLAGS }}" -o bin/{{ .BIN_NAME }}-generate cmd/gen/main.go
install:
desc: "installing {{ .BIN_NAME }} {{ .VERSION }}"
cmds:
- echo "GOPATH=${GOPATH}"
- go install -ldflags "{{ .LD_FLAGS}}"
- mv ${GOPATH}/bin/gdg ${GOPATH}/bin/{{ .BIN_NAME }}
- go install -ldflags "{{ .LD_FLAGS}}" cmd/gdg/main.go
silent: false
get-deps:
desc: "Tidy Deps"
cmds:
- go mod tidy
pakcage:
desc: "building image {{ .BIN_NAME }} {{ .VERSION }} {{ .GIT_COMMIT }}"
cmds:
- docker build --build-arg VERSION={{ .VERSION }} --build-arg GIT_COMMIT={{ .GIT_COMMIT }} -t $(IMAGE_NAME):local .
tag:
desc: "Tagging: latest {{ .VERSION }} {{ .GIT_COMMIT }}"
cmds:
- docker tag $(IMAGE_NAME):local $(IMAGE_NAME):{{ .GIT_COMMIT }}
- docker tag $(IMAGE_NAME):local $(IMAGE_NAME):{{ .VERSION }}
- docker tag $(IMAGE_NAME):local $(IMAGE_NAME):latest
push:
desc: "Pushing docker image to registry: latest {{ .VERSION }} {{ .GIT_COMMIT }}"
deps: [tag]
Expand All @@ -103,7 +95,8 @@ tasks:
deps: [clean]
desc: "Release GDG"
cmds:
- goreleaser release
- goreleaser release --skip=publish,validate

test:
desc: "test check"
cmds:
Expand Down
Loading

0 comments on commit a7b4a69

Please sign in to comment.