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

build: replace deploy.sh with goreleaser #65

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: ["1.14"]
go-version: ["1.17"]
os: [ubuntu-latest, macOS-latest]

steps:
Expand All @@ -22,7 +22,7 @@ jobs:
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
# cache: true # TODO: cache needs path to go.sum per https://github.com/actions/setup-go#caching-dependency-files-and-build-outputs
cache: true
- name: Install
run: |
bash --version ; type bash
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
docopts
*.swp
env
build/docopts_*
build/docopts.go
dist/
1 change: 1 addition & 0 deletions .go-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.17.1
41 changes: 41 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# https://goreleaser.com

# https://goreleaser.com/customization/hooks/
before:
hooks:
- go mod tidy
# https://goreleaser.com/customization/build/
builds:
- env:
- CGO_ENABLED=0
targets:
- darwin_amd64
- darwin_arm64
- freebsd_amd64
- linux_386
- linux_amd64
- linux_arm
- windows_amd64
# https://goreleaser.com/customization/templates/
# defaults: https://goreleaser.com/cookbooks/using-main.version
ldflags:
- -X "main.Version={{.Version}}"
- -X "main.BuildDate={{.Date}}"
- -X "main.GitCommit={{.ShortCommit}}"
- -X "main.GoBuildVersion={{.Env.GOVERSION}}" # https://goreleaser.com/customization/build/#passing-environment-variables-to-ldflags
archives:
- format: binary # https://goreleaser.com/customization/archive/#disable-archiving
checksum:
name_template: 'sha256sum.txt'
# https://goreleaser.com/customization/snapshots/
snapshot:
name_template: "{{ incpatch .Version }}-next"
# https://goreleaser.com/customization/release/
release:
draft: true
github:
owner: docopt
name: docopts
# https://goreleaser.com/customization/changelog/
changelog:
use: github-native
113 changes: 113 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Changelog

## bug fix v0.6.4-with-no-mangle-double-dash

Tag: `v0.6.4-with-no-mangle-double-dash`

This is a bug fix release.

features changes:
- fix error refusing mangling double dash in global mode [#52]
- still refuse to mangle single dash `[-]` in global mode (not compatible with v0.6.1)
- now can mangle single-dash and double-dash in `-G` mode
- fix output bash empty array #53

internal changes:
- use Go 1.17.1 for compiling
- `language_agnostic_tester.py` re-write for python3
- sort argument key in `Print_bash_args()` `Print_bash_global()`
- sort input keys in `docopts_test.go`
- add PR #52 test to `testcases.docopt`
- completed developer documentation
- #52 ignore `[--]` double-dash option in `Print_bash_global()`
- reformat of Go code with `gofmt`; indent change Space ==> Tab
- add `tests/functional_tests_docopts.bats`

## docopts binary transitional v0.6.3-rc2

Tag: `v0.6.3-rc2`

This is a transitional release.

It supports all the previous command line API plus some extra options.
Fully compatible with previous 0.6.2 python code for Bash.

See: https://github.com/docopt/docopts/tree/v0.6.1%2Bfix
based on master branch

features changes:
- `docopts.sh` function `docopt_get_help_string()` now uses awk to extract only first `Usage:`

internal changes:
- use Go 1.14 for compiling
- more pre-built binaries, removed darwin/386
- fixed #44 `get_docopts.sh` for macOS + functional tests
- removed `bats` git submodule
- use [bats-core 1.2-dev](https://github.com/bats-core/bats-core) as testing framework from travis
- `deploy.sh` removed, now uses its [own repository](https://github.com/opensource-expert/deploy.sh)
- updated Makefile to use `get_ldflags.sh` from `deploy.sh`
- [travis hack](travis/get_bash5_macos.sh) to get faster build on macos with our embedded bash5 binary

## docopts binary transitional v0.6.3-rc1

Tag: `v0.6.3-rc1`

This is a transitional release.

It supports all the previous API plus some extra command line options.
Fully compatible with previous 0.6.2 Python code for Bash.

See: https://github.com/docopt/docopts/tree/v0.6.1%2Bfix
based on master branch

changes:
- more test for macOS
- Bash 3.2 support is more documented and fixed
- use `bats-core` as testing framework
- updated README merged from old README.rst
- now documentation introduce `docopts.sh` See [docs](https://github.com/docopt/docopts/tree/v0.6.3-rc1/docs/)
- added `Makefile`
- added `build_doc.sh` PoC markdown preprocessor

all examples written for docopts:
- shebang conversion `#!/bin/bash` ==> `#!/usr/bin/env bash`
- legacy example completed
- example from README extracted a file, and merged in README via `build_doc.sh`
- `sshdiff` full example coded
- added examples with `--auto -G`

docopts.sh helper:
- is more documented in the code
- has documenation in [docs/README.md](https://github.com/docopt/docopts/tree/v0.6.3-rc1/docs/README.md)
- now supports bash strict mode (`set -euo pipefail`)
- now supports `--auto -G` to auto parse with global vars (doesn't use bash 4 associative array)
`docopts` behavior sould be unchanged:
- add mangled name collision detection

## docopts for Bash first release in golang

Tag: `v0.6.3-alpha1`

This is a transitional release.

It is a complete rewrite of the Python code in Go.
It supports all of the previous API plus some extra command line options.

Fully compatible with previous 0.6.2 python code for Bash.
based on https://github.com/docopt/docopts/tree/packaging-debian

## first release in Go

Tag: `v0.6.2`

This is a transitional release.

Docopt for shell.
It supports all of the previous API.

Fully compatible with previous 0.6.1 Python code for Bash.
See: https://github.com/docopt/docopts/tree/v0.6.1%2Bfix
based on master branch

changes:
- now written in Go, no more Python dependency
4 changes: 0 additions & 4 deletions Changelog.md

This file was deleted.

43 changes: 14 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,44 +1,20 @@
#
# Makefile for managing docopts build
#
# See also: deploy.sh

PREFIX ?= /usr/local
GOVERSION := $$(go version)
RELEASE_NOTES := $$(awk -v RS='\#\# *|\#\# ' 'NR==2 { print }' CHANGELOG.md)

# keep docopts: as first target for development

# govvv define main.Version with the contents of ./VERSION file, if exists
agilgur5 marked this conversation as resolved.
Show resolved Hide resolved
BUILD_FLAGS=$(shell ./get_ldflags.sh)
docopts: docopts.go Makefile
go build -o $@ -ldflags "${BUILD_FLAGS} ${LDFLAGS}"
go build -o $@

# dependancies
install_builddep:
go get github.com/docopt/docopts
go get github.com/docopt/docopt-go
go get github.com/mitchellh/gox
go get github.com/itchio/gothub
go get gopkg.in/yaml.v2
go get github.com/ahmetb/govvv
go mod tidy

all: install_builddep docopts README.md
./deploy.sh build current

############################ cross compile, we use gox now inside deploy.sh

## build 32 bits version too
#docopts-32bits: docopts.go
# env GOOS=linux GOARCH=386 go build -o docopts-32bits docopts.go
#
## build for OSX
#docopts-OSX: docopts.go
# env GOOS=darwin go build -o docopts-OSX docopts.go
#
## build 32 bits version too
#docopts-arm: docopts.go
# env GOOS=linux GOARCH=arm go build -o docopts-arm docopts.go

###########################

# requires write access to $PREFIX
install: all
Expand All @@ -58,4 +34,13 @@ README.md: examples/legacy_bash/rock_hello_world.sh examples/legacy_bash/rock_he
mv README.tmp README.md

clean:
rm -f docopts-* docopts README.tmp build/*
rm -f docopts-* docopts README.tmp dist/*

test_release_notes:
echo "\n## $(RELEASE_NOTES)"

snapshot: install_builddep
GOVERSION=$(GOVERSION) goreleaser build --rm-dist --snapshot -o docopts

release: clean all test snapshot
GOVERSION=$(GOVERSION) goreleaser release --release-notes "## $(RELEASE_NOTES)"
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,10 @@ We encourage you to build your own binary, which is easy once
you have Go installed. Or find a local golang developer that you
trust and ask her, in exchange for a beer or two, if she could build it for you. ;)

Requires a [Go workspace](https://golang.org/doc/code.html#Organization).

local build:
(also done with our Makefile default target: `make`)

```
go get github.com/docopt/docopt-go
go get github.com/docopt/docopts
cd src/github.com/docopt/docopts
go build docopts.go
```

Expand All @@ -394,7 +389,6 @@ env GOOS=linux GOARCH=386 go build docopts.go
or via Makefile:

```
cd src/github.com/docopt/docopts
make all
make test
```
Expand Down
3 changes: 0 additions & 3 deletions build/.placeholder

This file was deleted.

Loading