Skip to content

Commit

Permalink
use goreleaser and new help
Browse files Browse the repository at this point in the history
  • Loading branch information
kpym committed Oct 11, 2020
1 parent 5548773 commit f2c7e50
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 25 deletions.
47 changes: 22 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
# workflow name
name: release
name: goreleaser




# on events
on:
release:
types:
- created
push:
tags:
- '*'

# jobs
jobs:
# generate build cross-platform build files
generate:
name: Generate cross-platform builds
goreleaser:
runs-on: ubuntu-latest
steps:
# step 1: checkout repository code
- name: Checkout the repository
-
name: Checkout
uses: actions/checkout@v2

# step 2: generate build files
- name: Generate build files
uses: thatisuday/go-build-action@v1
with:
platforms: "linux/amd64, darwin/amd64, windows/amd64"
package: ""
name: "urlencode"
compress: "true"
dest: "dist"

# step 3: upload build-artifacts
- name: Upload build-artifacts
uses: skx/github-action-publish-binaries@master
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: "./dist/*.tar.gz"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.exe
dist
37 changes: 37 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod download
# you may remove this if you don't need go generate
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
ldflags:
- -s -w -X main.version={{.Version}}
archives:
- replacements:
darwin: MacOS
linux: Linux
windows: Windows
386: 32bit
amd64: 64bit
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package main

import (
"flag"
"fmt"
"io/ioutil"
"net/url"
"os"
"strings"
)

var version string = "--"

func restoreSpaces(s string) string {
return strings.ReplaceAll(strings.ReplaceAll(s, "%20", " "), "+", " ")
}
Expand All @@ -18,6 +21,13 @@ func main() {
keepSpaces := flag.Bool("keep-spaces", false, "keep spaces as they are")
usePathEscape := flag.Bool("path-escape", false, "use PathEscape in place of QueryEscape")
trimSpaces := flag.Bool("trim", false, "trim (from both sides) spaces and new lines")
// Help message
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "urlencode (version: %s, executable: %s)\n\n", version, os.Args[0])
fmt.Fprintf(os.Stderr, "This program is a thin wrapper around the standard go url escape functions.\nAvailable flgs:\n\n")
flag.PrintDefaults()
fmt.Fprintf(os.Stderr, "\n")
}
// parse flags
flag.Parse()

Expand Down

0 comments on commit f2c7e50

Please sign in to comment.