Skip to content

Commit

Permalink
Add workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
imoore76 committed Apr 23, 2024
1 parent 51d62ab commit f566d1d
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 6 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: goreleaser

on:
push:
tags:
- 'v*'

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21.x

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{secrets.GH_GOREL}}
32 changes: 32 additions & 0 deletions .github/workflows/run_checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: run_checks

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- run: sudo apt-get install pcre2-utils

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'

- run: go install github.com/gordonklaus/ineffassign@latest
- run: go install honnef.co/go/tools/cmd/staticcheck@latest
- run: go install github.com/client9/misspell/cmd/misspell@latest
- run: go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
- run: go install github.com/google/addlicense@latest
- run: wget https://github.com/go-task/task/releases/download/v3.36.0/task_linux_amd64.deb
- run: sudo dpkg -i task_linux_amd64.deb
- run: rm task_linux_amd64.deb
- run: task check

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.*
!/.gitignore
!/.github
!/.goreleaser.yaml
/build
/dist

# Added by vscode's C# extension
/go-ldlm.sln
Expand Down
60 changes: 60 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
builds:
- binary: ldlm-lock
id: ldlm-lock
main: ./cmd/lock
targets:
- "windows_amd64"
- "linux_amd64"
- "linux_arm64"
- "darwin_amd64"
- "darwin_arm64"
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
- binary: ldlm-server
id: ldlm-server
main: ./cmd/server
targets:
- "windows_amd64"
- "linux_amd64"
- "linux_arm64"
- "darwin_amd64"
- "darwin_arm64"
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath


gomod:
proxy: true

archives:
- name_template: "{{.ProjectName}}_{{.Os}}_{{.Arch}}"
files:
- README.md
- LICENSE
- examples/
format_overrides:
- goos: windows
format: zip

release:
draft: true

snapshot:
name_template: "{{.Tag}}"

checksum:
name_template: "ldlm_checksums.txt"

nfpms:
- vendor: imoore76@yahoo.com
homepage: https://github.com/imoore76/go-ldlm
maintainer: Ian Moore <imoore76@yahoo.com>
description: Light weight Distributed Lock Manager server implemented over gRPC
license: Apache 2.0
formats:
- deb
- rpm
file_name_template: "{{.ProjectName}}_{{.Os}}_{{.Arch}}"

8 changes: 8 additions & 0 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,25 @@ import (
// Configurature struct for app configuration
type Config struct {
ConfigFile config.File `desc:"Path to yaml configuration file" default:"" short:"c"`
Version bool `desc:"Show version and exit" default:"false"`
constants.LogLevelConfig
server.ServerConfig
}

var Version string

func main() {

conf := config.Configure[Config](&config.Options{
EnvPrefix: constants.ConfigEnvPrefix,
Args: os.Args[1:],
})

if conf.Version {
fmt.Printf("Version: %s\n", Version)
os.Exit(0)
}

log.SetLevel(conf.LogLevel)

if stopper, err := server.Run(&conf.ServerConfig); err != nil {
Expand Down
4 changes: 0 additions & 4 deletions examples/config/ldlm-config.ini

This file was deleted.

4 changes: 2 additions & 2 deletions taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ tasks:
license_headers:
desc: "Make sure source files have headers"
cmds:
- addlicense -check -ignore **/.* ./
- addlicense -check -ignore '**/.*' -ignore '.*/**' ./

add_license_headers:
desc: "Make sure source files have headers"
aliases: ["alh"]
preconditions:
- test "{{.CLI_ARGS}}" != ""
cmds:
- addlicense -ignore **/.* ./ {{.CLI_ARGS}}
- addlicense -ignore '**/.*' -ignore '.*/**' ./ {{.CLI_ARGS}}

check_readme_google:
desc: "Make sure README.md has common items"
Expand Down

0 comments on commit f566d1d

Please sign in to comment.