Skip to content

Commit 3f0d3d5

Browse files
committed
chore: add goreleaser config
1 parent bb9a868 commit 3f0d3d5

File tree

9 files changed

+146
-21
lines changed

9 files changed

+146
-21
lines changed

.circleci/config.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Golang CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-go/ for more details
4+
version: 2
5+
jobs:
6+
build:
7+
docker:
8+
# specify the version
9+
- image: circleci/golang:1.17
10+
11+
# Specify service dependencies here if necessary
12+
# CircleCI maintains a library of pre-built images
13+
# documented at https://circleci.com/docs/2.0/circleci-images/
14+
# - image: circleci/postgres:9.4
15+
16+
#### TEMPLATE_NOTE: go expects specific checkout path representing url
17+
#### expecting it in the form of
18+
#### /go/src/github.com/circleci/go-tool
19+
#### /go/src/bitbucket.org/circleci/go-tool
20+
working_directory: /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}
21+
steps:
22+
- checkout
23+
24+
# specify any bash command here prefixed with `run: `
25+
- run: go get -u golang.org/x/lint/golint && golint -set_exit_status
26+
- run: go get -v -t -d ./...
27+
#- run: go test -v ./...

.github/workflows/codeql-analysis.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [master]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [master]
20+
schedule:
21+
- cron: "44 23 * * 3"
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
language: ["go"]
32+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
33+
# Learn more:
34+
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
35+
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v2
39+
40+
# Initializes the CodeQL tools for scanning.
41+
- name: Initialize CodeQL
42+
uses: github/codeql-action/init@v2
43+
with:
44+
languages: ${{ matrix.language }}
45+
# If you wish to specify custom queries, you can do so here or in a config file.
46+
# By default, queries listed here will override any specified in a config file.
47+
# Prefix the list here with "+" to use these queries and those in the config file.
48+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
49+
50+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
51+
# If this step fails, then you should remove it and run the build manually (see below)
52+
- name: Autobuild
53+
uses: github/codeql-action/autobuild@v2
54+
55+
# ℹ️ Command-line programs to run using the OS shell.
56+
# 📚 https://git.io/JvXDl
57+
58+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
59+
# and modify them (or add more) to build your code if your project
60+
# uses a compiled language
61+
62+
#- run: |
63+
# make bootstrap
64+
# make release
65+
66+
- name: Perform CodeQL Analysis
67+
uses: github/codeql-action/analyze@v2

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
.vscode/*
22
waybar-livestatus
33
vendor/
4+
dist/
5+
6+
dist/

.goreleaser.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This is an example .goreleaser.yml file with some sensible defaults.
2+
# Make sure to check the documentation at https://goreleaser.com
3+
before:
4+
hooks:
5+
# You may remove this if you don't use go modules.
6+
- go mod tidy
7+
# you may remove this if you don't need go generate
8+
- go generate ./...
9+
builds:
10+
- env:
11+
- CGO_ENABLED=0
12+
goos:
13+
- linux
14+
goarch:
15+
- amd64
16+
- arm64
17+
archives:
18+
- replacements:
19+
linux: Linux
20+
amd64: x86_64
21+
arm64: aarch64
22+
23+
checksum:
24+
name_template: "checksums.txt"
25+
snapshot:
26+
name_template: "{{ incpatch .Version }}-next"
27+
changelog:
28+
sort: asc
29+
filters:
30+
exclude:
31+
- "^docs:"
32+
- "^test:"
33+
34+
signs:
35+
- artifacts: all
36+
# modelines, feel free to remove those if you don't want/use them:
37+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
38+
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

Makefile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,13 @@ generate:
2525

2626
.PHONY: build
2727
build: main.go
28-
go build -trimpath -ldflags "-X github.com/cyrinux/waybar-livestatus/helpers.Version=$(VERSION) -linkmode=external" -o $(BIN) main.go
28+
go build -o $(BIN) main.go
2929

3030
.PHONY: debug
3131
debug: main.go
32-
go build -gcflags='all=-N -l' -ldflags "-X github.com/cyrinux/waybar-livestatus/helpers.Version=$(VERSION) -linkmode=external" -o $(BIN) main.go
32+
go build -o $(BIN) main.go
3333
dlv exec ./waybar-livestatus
3434

35-
.PHONY: release
36-
release: build
37-
strip $(BIN) 2>/dev/null || true
38-
upx -9 $(BIN) 2>/dev/null || true
39-
4035
.PHONY: vendor
4136
vendor:
4237
go mod tidy
@@ -109,3 +104,7 @@ graphviz:
109104
@dot -Tsvg ~/protodot/generated/alert.dot -o alert.dot.svg
110105
@rm -vf ~/protodot/generated/alert*
111106
@xdg-open alert.dot.png
107+
108+
.PHONY: release
109+
release:
110+
goreleaser --rm-dist

alert/alert.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

helpers/config.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ import (
1515
"github.com/rs/zerolog/log"
1616
)
1717

18-
// Version give the software version
19-
var Version string
20-
2118
// CONFIG define the configuration content
2219
type CONFIG struct {
2320
Server string `toml:"server" default:""`
@@ -29,7 +26,6 @@ type CONFIG struct {
2926
Debug bool `toml:"debug" default:"false"`
3027
Popup bool `toml:"popup" default:"true"`
3128
Warnings bool `toml:"warnings" default:"true"`
32-
Version bool `default:"false"`
3329
NotificationSnoozeCycle int `toml:"notification_snooze_cycle" default:"10"`
3430
Acknowledged int `toml:"acknowledged" default:"0"`
3531
NotificationsEnabled int `toml:"notifications_enabled" default:"1"`
@@ -87,7 +83,6 @@ func GetConfig() *CONFIG {
8783
flag.BoolVar(&config.Client, "c", false, "Client mode.")
8884
flag.BoolVar(&config.NotesURL, "u", config.NotesURL, "Display notes_url.")
8985
flag.BoolVar(&config.Popup, "n", config.Popup, "Disable notification popup alert.")
90-
flag.BoolVar(&config.Version, "V", false, "Print version and exit.")
9186
flag.BoolVar(&config.Warnings, "w", config.Warnings, "Get also state warnings. Default show critical only.")
9287

9388
flag.IntVar(&config.Refresh, "r", config.Refresh, "Refresh rate in seconds. Min 15.")

helpers/notification.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ package helpers
22

33
import (
44
"fmt"
5+
"os"
6+
"strings"
7+
58
notify "github.com/TheCreeper/go-notify"
69
"github.com/rs/zerolog"
710
"github.com/rs/zerolog/log"
8-
"os"
9-
"strings"
1011
)
1112

1213
// Alert define a event
@@ -48,7 +49,7 @@ func SendNotification(notifications chan *Alert, config *CONFIG) {
4849
alertsWithCounter := make(map[Alert]int)
4950

5051
if config.Debug {
51-
startAlert := Alert{Host: "Livestatus", Desc: fmt.Sprintf("starting version %v", Version)}
52+
startAlert := Alert{Host: "Livestatus", Desc: fmt.Sprint("starting")}
5253
if _, err := createNotification(&startAlert, ""); err != nil {
5354
log.Error().Msgf("Error sending notification: %v", err)
5455
}

main.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ func main() {
8989
// get config
9090
var config = helpers.GetConfig()
9191

92-
if config.Version {
93-
fmt.Println("Waybar Livestatus version:", helpers.Version)
94-
os.Exit(0)
95-
}
96-
9792
// start the client and exit
9893
if config.Client {
9994
err := client.Start(config)

0 commit comments

Comments
 (0)