Skip to content

Commit

Permalink
github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
MrZoidberg committed Jun 27, 2024
1 parent 5953307 commit f8ff271
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 1 deletion.
33 changes: 33 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: build

on:
push:
branches:
tags:
- 'v*'
pull_request:


jobs:
build:
runs-on: ubuntu-latest

steps:
- name: set up go 1.22
uses: actions/setup-go@v5
with:
go-version: "1.22"
id: go

- name: checkout
uses: actions/checkout@v4

- name: build and test
run: |
go build -v ./...
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest

26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: release

on:
push:
tags:
- 'v*'

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: run goreleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@
# Go workspace file
go.work
go.work.sum
.vscode/
.vscode/
dist/
.bin
88 changes: 88 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2

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 ./...

project_name: megarac
dist: .bin

signs:
- artifacts: checksum

builds:
- binary: "megarac"
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm
- arm64
ignore:
- goos: freebsd
goarch: arm
- goos: freebsd
goarch: arm64
- goos: windows
goarch: arm
- goos: windows
goarch: arm64
ldflags: "-s -w -X main.revision={{.Tag}}-{{.ShortCommit}}-{{.CommitDate}}"


archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
files:
- README.md
- LICENSE

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

nfpms:
- id: spot
package_name: spot
file_name_template: "{{.ProjectName}}_{{.Tag}}_{{.Os}}_{{.Arch}}"
vendor: Umputun
homepage: https://simplotask.com
maintainer: Umputun <[email protected]>
description: A collection of tools for the effortless deployment, configuration, and management of secrets
license: MIT
formats:
- deb
- rpm
- apk
bindir: /usr/bin
epoch: 1
release: 1
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"log"
"os"

Expand All @@ -9,6 +10,8 @@ import (
"github.com/urfave/cli/v2"
)

var revision = "latest"

func main() {

lgr.SetupLog()
Expand Down Expand Up @@ -238,6 +241,14 @@ func main() {
},
},
},
{
Name: "version",
Usage: "show version",
Action: func(c *cli.Context) error {
fmt.Printf("megarac version %s\n", revision)
return nil
},
},
},
}

Expand Down

0 comments on commit f8ff271

Please sign in to comment.