Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Goreleaser #24

Merged
merged 5 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release

on:
push:
tags:
- '*'

permissions:
contents: write
# packages: write
# issues: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git fetch --force --tags
- uses: actions/setup-go@v4
with:
go-version: stable
- uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
vendor/
dist/
.env
bin/
*.php
test/*.go
*.txt
67 changes: 67 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
project_name: tasker

release:
prerelease: auto
name_template: "v{{.Version}}"
draft: true
mode: "keep-existing"

before:
hooks:
- go mod tidy

builds:
- <<: &build_defaults
binary: bin/tasker
main: ./cmd/tasker
ldflags:
- -X main.Version={{.Version}}
env:
- CGO_ENABLED=0
id: macOS
goos: [darwin]
goarch: [amd64, arm64]

- <<: *build_defaults
id: linux
goos: [linux]
goarch: [386, arm, amd64, arm64]

- <<: *build_defaults
id: windows
goos: [windows]
goarch: [amd64]

archives:
- id: nix
builds: [macOS, linux]
<<: &archive_defaults
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
wrap_in_directory: true
rlcp: true
format: tar.gz
files:
- LICENSE

- id: windows
builds: [windows]
<<: *archive_defaults
wrap_in_directory: false
format: zip
files:
- LICENSE

checksum:
name_template: 'checksums.txt'
algorithm: sha256

changelog:
skip: true
use: github
sort: desc
filters:
exclude:
- '^doc:'
- '^dev:'
- '^build:'
- '^ci:'
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ First, just install tasker command:
go install github.com/adhocore/gronx/cmd/tasker@latest
```

Or you can also download latest prebuilt binary from [release](https://github.com/adhocore/gronx/releases/latest) for platform of your choice.

Then prepare a taskfile ([example](./tests/../test/taskfile.txt)) in crontab format
(or can even point to existing crontab).
> `user` is not supported: it is just cron expr followed by the command.
Expand Down
11 changes: 11 additions & 0 deletions cmd/tasker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"flag"
"fmt"
"log"
"os"
"time"
Expand All @@ -13,6 +14,10 @@ var exit = os.Exit
var tick = time.Minute

var opt tasker.Option
var v bool

// Version of tasker, injected in build
var Version = "n/a"

func init() {
flag.StringVar(&opt.File, "file", "", "The task file in crontab format (without user)")
Expand All @@ -21,6 +26,7 @@ func init() {
flag.StringVar(&opt.Out, "out", "", "The fullpath to file where output from tasks are sent to")
flag.BoolVar(&opt.Verbose, "verbose", false, "The verbose mode outputs as much as possible")
flag.Int64Var(&opt.Until, "until", 0, "The timeout for task daemon in minutes")
flag.BoolVar(&v, "v", false, "Show version")
}

func main() {
Expand All @@ -42,6 +48,11 @@ func mustParseOption() {
opt = tasker.Option{}
flag.Parse()

if v {
fmt.Printf("v%s\n", Version)
exit(0)
}

if opt.File == "" {
flag.Usage()
exit(1)
Expand Down
9 changes: 9 additions & 0 deletions pkg/tasker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ First, just install tasker command:
go install github.com/adhocore/gronx/cmd/tasker@latest
```

Or you can also download latest prebuilt binary from [release](https://github.com/adhocore/gronx/releases/latest) for platform of your choice.

Then prepare a taskfile ([example](https://github.com/adhocore/gronx/blob/main/test/taskfile.txt)) in crontab format
(or can even point to existing crontab).
> `user` is not supported: it is just cron expr followed by the command.
Expand All @@ -102,6 +104,13 @@ Finally run the task daemon like so
```
tasker -file path/to/taskfile
```

#### Version

```sh
tasker -v
```

> You can pass more options to control the behavior of task daemon, see below.

#### Tasker command options:
Expand Down