Skip to content

Commit

Permalink
Merge pull request #24 from adhocore/11-goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
adhocore authored Apr 24, 2023
2 parents 9465e9b + fec2be9 commit b9f8fdc
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 0 deletions.
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

0 comments on commit b9f8fdc

Please sign in to comment.