Skip to content

Commit

Permalink
final cleanup and setup for release
Browse files Browse the repository at this point in the history
  • Loading branch information
runeimp committed Apr 16, 2020
1 parent 58b07f5 commit e12f0e7
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 15 deletions.
70 changes: 70 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
project_name: gzipdate
env:
- GO111MODULE=on
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos:
- darwin
- freebsd
- linux
- netbsd
- openbsd
- windows
ignore:
- goos: darwin
goarch: 386
ldflags:
- -s -w
main: ./main.go
archives:
- files:
- CHANGELOG.md
- LICENSE
- README.md
format_overrides:
- goos: windows
format: zip
replacements:
386: i386
amd64: x86_64
darwin: macos
# darwin: macOS
# freebsd: FreeBSD
# linux: Linux
# netbsd: NetBSD
# openbsd: OpenBSD
# gzipdate: GzipDate
# windows: Windows
wrap_in_directory: true
nfpms:
# note that this is an array of nfpm configs
- formats:
- deb
- rpm
# ID of the nfpm config, must be unique.
# Defaults to "default".
id: gzipdate
homepage: "https://github.com/runeimp/gzipdate"
license: MIT
replacements:
386: i386
amd64: x86_64
darwin: macos
checksum:
name_template: 'checksums.txt'
# signs:
# - artifacts: checksum
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ChangeLog:
==========

v1.0.0
------

Initial release

* Added all initially planned features

71 changes: 71 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
PROJECT_NAME := "GzipDate"

alias arc := archive

@_default:
just _term-wipe
just --list

# Archive GoReleaser dist
archive:
#!/bin/sh
just _term-wipe
tag="$(git tag --points-at master)"
app="{{PROJECT_NAME}}"
arc="${app}_${tag}"

# echo "app = '${app}'"
# echo "tag = '${tag}'"
# echo "arc = '${arc}'"
if [ -e dist ]; then
echo "Move dist -> distro/${arc}"
mv dist "distro/${arc}"

# echo "cd distro"
cd distro

printf "pwd = "
pwd

ls -Alh
else
echo "dist directory not found for archiving"
fi

# Build and install app
build:
@just _term-wipe
go build -o gzipdate main.go
mv gzipdate "${GOBIN}/"
@# go install main.go


# Build distro
distro:
#!/bin/sh
goreleaser
just archive


# Run code
run +args='':
@just _term-wipe
go run main.go {{args}}


_term-wipe:
#!/bin/sh
if [[ ${#VISUAL_STUDIO_CODE} -gt 0 ]]; then
clear
elif [[ ${KITTY_WINDOW_ID} -gt 0 ]] || [[ ${#TMUX} -gt 0 ]] || [[ "${TERM_PROGRAM}" = 'vscode' ]]; then
printf '\033c'
elif [[ "$(uname)" == 'Darwin' ]] || [[ "${TERM_PROGRAM}" = 'Apple_Terminal' ]] || [[ "${TERM_PROGRAM}" = 'iTerm.app' ]]; then
osascript -e 'tell application "System Events" to keystroke "k" using command down'
elif [[ -x "$(which tput)" ]]; then
tput reset
elif [[ -x "$(which reset)" ]]; then
reset
else
clear
fi

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Features
* Does not delete source files by default. Though they can be automatically deleted with a command line switch.
* Always uses maximum compression when creating archives
* 100% compatible with gzip and gunzip tools
* Written in Go so it's easy to cross-compile binaries for many platforms


Rational
Expand Down
31 changes: 16 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ import (
const (
AppName = "GzipDate"
AppVersion = "1.0.0"
argDeleteUsage = "Delete the source file after successful processing"
argHelpUsage = "Display this help info"
argVersionUsage = "Display this apps version number"
cliDeleteUsage = "Delete the source file after successful processing"
cliHelpUsage = "Display this help info"
cliVersionUsage = "Display this apps version number"
cliUsageHeader = `%s
USAGE: gzipdate [OPTIONS] [FILENAMES]
OPTIONS:
`
)

/*
Expand All @@ -44,12 +50,12 @@ func main() {
// Bespoke CLI Handler because flags is lame
for _, arg := range os.Args[1:] {
switch arg {
case "-d", "-del", "-delete":
case "-d", "-del", "-delete", "--delete":
deleteSource = true
case "-h", "-help":
case "-h", "-help", "--help":
helpOutput()
os.Exit(0)
case "-v", "-ver", "-version":
case "-v", "-ver", "-version", "--version":
fmt.Println(AppLabel)
os.Exit(0)
default:
Expand Down Expand Up @@ -192,15 +198,10 @@ func gzipEncode(filename string) error {
}

func helpOutput() {
// flag.Usage()
// fmt.Println("----")
fmt.Printf("USAGE: gzipdate [OPTIONS] FILENAMES\n\nOPTIONS:\n")
// flag.PrintDefaults()
// fmt.Println()

fmt.Printf(" -d | -del | -delete %s\n", argDeleteUsage)
fmt.Printf(" -h | -help %s\n", argHelpUsage)
fmt.Printf(" -v | -ver | -version %s\n", argVersionUsage)
fmt.Printf(cliUsageHeader, AppLabel)
fmt.Printf(" -d | -del | -delete %s\n", cliDeleteUsage)
fmt.Printf(" -h | -help %s\n", cliHelpUsage)
fmt.Printf(" -v | -ver | -version %s\n", cliVersionUsage)
fmt.Println()
fmt.Printf("Options may be interspersed with file names if so desired.\nThey are not position dependent.\n\n")
}

0 comments on commit e12f0e7

Please sign in to comment.