Skip to content

Commit

Permalink
prepare for github
Browse files Browse the repository at this point in the history
  • Loading branch information
paragor committed Sep 11, 2024
1 parent c18af17 commit 5cd91b4
Show file tree
Hide file tree
Showing 11 changed files with 203 additions and 8 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: goreleaser

on:
push:
tags:
- '*'

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Docker Login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.23.0
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26 changes: 25 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
todolist
### Go template
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work


dist/
69 changes: 69 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# 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 ./...
- go test ./...

builds:
- env:
- CGO_ENABLED=0
goarch:
- amd64
- arm64
goos:
- linux
- windows
- darwin

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

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

dockers:
- image_templates:
- "paragor/todolist:{{ .Tag }}-amd64"
goarch: amd64
use: buildx
build_flag_templates:
- "--builder=default"
- image_templates:
- "paragor/todolist:{{ .Tag }}-arm64"
goarch: arm64
use: buildx
build_flag_templates:
- "--builder=default"
docker_manifests:
- name_template: "paragor/todolist:{{ .Tag }}"
image_templates:
- "paragor/todolist:{{ .Tag }}-amd64"
- "paragor/todolist:{{ .Tag }}-arm64"
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM alpine:3.20.2

WORKDIR /app

COPY todolist /usr/bin/
ENTRYPOINT ["/usr/bin/todolist"]
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
build:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o todolist main.go
build_local:
goreleaser release --snapshot --clean

install:
CGO_ENABLED=0 go build -o /usr/local/bin/todolist main.go
/usr/local/bin/todolist config-persist

update_default_config:
rm config_example.yaml || true
TODOLIST_HOME=./ go run main.go config-persist --config=config_example.yaml
16 changes: 15 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"
)

var homeDir = path.Join(os.Getenv("HOME"), ".config/todolist")
var homeDir = path.Join(Or(os.Getenv("TODOLIST_HOME"), os.Getenv("HOME")), ".config/todolist")

func init() {
cobra.OnInitialize(initConfig)
Expand Down Expand Up @@ -50,3 +50,17 @@ func initConfig() {
panic(fmt.Errorf("cant unmarshal config file: %w", err).Error())
}
}

func Or[T comparable](value T, alternatives ...T) T {
var zero T
if value != zero {
return value
}
for _, alternative := range alternatives {
if alternative != zero {
return alternative
}
}

return zero
}
34 changes: 34 additions & 0 deletions config_example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
server:
diagnostic_endpoints_enabled: true
database_file: .config/todolist/database.json
listen_addr: :8080
public_url: ""
auth_enabled: false
token_auth:
enabled: false
client_token: api_password
base_auth:
enabled: false
login: ""
password: ""
oidc_auth:
enabled: false
client_id: ""
client_secret: ""
issuer_url: https://accounts.google.com
scopes:
- openid
- email
- profile
cookie_key: kiel4teof4Eoziheigiesh7ooquiepho
whitelist_emails: []
telegram:
enabled: false
token: ""
userId: 0
everyday_agenda:
enabled: false
at: 0001-01-01T00:00:00Z
client:
remote_addr: http://127.0.0.1:8080
server_token: api_password
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module github.com/paragor/todo

go 1.21.3
go 1.23.0

require (
github.com/google/uuid v1.6.0
github.com/gorilla/handlers v1.5.2
github.com/gorilla/mux v1.8.1
github.com/jedib0t/go-pretty/v6 v6.5.9
github.com/prometheus/client_golang v1.19.1
github.com/spf13/cobra v1.8.1
github.com/zitadel/oidc/v3 v3.26.1
Expand All @@ -22,7 +23,6 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gorilla/securecookie v1.1.2 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jedib0t/go-pretty/v6 v6.5.9 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/muhlemmer/gu v0.3.1 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
Expand Down
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package main

import "github.com/paragor/todo/cmd"
import (
"github.com/paragor/todo/cmd"
_ "time/tzdata"
)

func main() {
cmd.Execute()
Expand Down
2 changes: 1 addition & 1 deletion pkg/models/human_input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestParseHumanInput(t *testing.T) {
}{
{
args: args{
input: " modify 358bb57b-7d84-47a0-a3d5-29fcd77f87b9 project:one bla due:2024-10-15T10:00:00 +hui blabla bla -bui notify: status:pending\t \n ",
input: " modify 358bb57b-7d84-47a0-a3d5-29fcd77f87b9 project:one bla due:2024-10-15T10:00:00 +hui blabla bla !bui notify: status:pending\t \n ",
},
want: &HumanInputParserResult{
Action: HumanActionModify,
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# todolist

todo

0 comments on commit 5cd91b4

Please sign in to comment.