Skip to content

Commit

Permalink
Merge pull request #4 from drewstinnett/chore-github-workflow
Browse files Browse the repository at this point in the history
Chore: GitHub workflow
  • Loading branch information
drewstinnett authored Jan 19, 2024
2 parents 7970faa + 2f8815d commit 59ac532
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 4 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Coverage

on:
push:
pull_request:

jobs:
coverage:
runs-on: ubuntu-latest
env:
TZ: "America/New_York"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: actions/setup-go@v4
with:
go-version: 'stable'
- name: Run coverage
run: go test -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
files: ./coverage.txt
name: codecov-umbrella
verbose: true
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: goreleaser

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

jobs:
goreleaser:
runs-on: ubuntu-latest
env:
TZ: "America/New_York"
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21"
-
name: Tests
run: |
go mod tidy
go test ./...
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
if: success() && startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
18 changes: 18 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Security Scans
on:
push:
pull_request:
jobs:
security:
runs-on: ubuntu-latest
env:
TZ: "America/New_York"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: actions/setup-go@v4
with:
go-version: 'stable'
- id: govulncheck
uses: golang/govulncheck-action@v1
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.swp
diary.yaml*
places.yaml
dist/
completions/
58 changes: 58 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
before:
hooks:
- go mod tidy
- ./scripts/completions.sh
builds:
- env:
- CGO_ENABLED=0
main: ./cmd/letseat/
mod_timestamp: '{{ .CommitTimestamp }}'
ldflags:
- '-s -w'
- -X github.com/drewstinnett/letseat/cmd/letseat/cmd.date={{ .CommitTimestamp }}
- -X github.com/drewstinnett/letseat/cmd/letseat/cmd.version={{ .Tag }}
- -X github.com/drewstinnett/letseat/cmd/letseat/cmd.commit={{ .ShortCommit }}
flags:
- -trimpath
goos:
- darwin
- linux
- windows
goarch:
- amd64
- arm64
ignore:
- goos: darwin
goarch: '386'
binary: 'letseat'
archives:
- format: tar.gz
name_template: 'letseat-{{ .Version }}_{{ .Os }}_{{ .Arch }}'
files:
- completions/*
checksum:
name_template: 'letseat-{{ .Version }}_SHA256SUMS'
algorithm: sha256
snapshot:
name_template: "{{ .Tag }}-snapshot"
changelog:
skip: true
brews:
- name: 'letseat'
repository:
owner: drewstinnett
name: homebrew-tap
token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
description: "Figure out where to go for dinner!"
homepage: "https://github.com/drewstinnett/letseat"
license: BSD-2-Clause
caveats: |
Add the following in your ~/.zshrc or ~/.profile for faster typin':
alias tp="#{opt_bin}/letseat"
install: |-
bin.install "letseat"
bash_completion.install "completions/letseat.bash" => "letseat"
zsh_completion.install "completions/letseat.zsh" => "_letseat"
fish_completion.install "completions/letseat.fish"
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
BSD 2-Clause License

Copyright (c) 2021, Drew Stinnett
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8 changes: 4 additions & 4 deletions cmd/letseat/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var (
cfgFile string
g *gout.Client
config configPaths
version string = "dev"
)

type configPaths struct {
Expand All @@ -29,10 +30,9 @@ type configPaths struct {
// rootCmd represents the base command when called without any subcommands
func newRootCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "letseat",
Short: "Decide what to eat!",
// Uncomment the following line if your bare application
// has an action associated with it:
Use: "letseat",
Short: "Decide what to eat!",
Version: version,
SilenceUsage: true,
SilenceErrors: true,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
Expand Down
7 changes: 7 additions & 0 deletions scripts/completions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
set -e
rm -rf completions
mkdir completions
for sh in bash zsh fish; do
go run ./cmd/letseat completion "$sh" >"completions/letseat.$sh"
done

0 comments on commit 59ac532

Please sign in to comment.