docopts
docopts copied to clipboard
build: replace `deploy.sh` with `goreleaser`
Summary
-
Replace bespoke
deploy.shscript with thegoreleaserlibrary- Basically implementing https://github.com/docopt/docopts/issues/59#issuecomment-1108109979
-
Replace outdated custom dependency management with standard, built-in Go modules
Details
-
deploy.shwas a custom bespoke script for building, cross-compiling, and releasing to GitHub- it was eventually moved out of this repo and into https://github.com/opensource-expert/deploy.sh (per https://github.com/docopt/docopts/issues/59#issuecomment-1106141209 (search "deploy.sh"))
-
goreleaseris a popular Go library for doing the same thing and more! -
replace
deployment.yamlwith.goreleaser.yamlwith the same targets- note that
darwin_arm64is also here to support #58 - add various comments with links to help Sylvain and others get familiar with
goreleaser's various configurations - configure
archivesandchecksumto match previous output fromdeploy.sh - add some defaults for
releaseandchangelog-- to be changed by Sylvain as preferred - replace
govvvandget_ldflags.shby configuringldflags
- note that
-
modify
CHANGELOG.mdto have the actual release notes (sincedeployment.yamlno longer exists)- use an
awkscript andgoreleaser's--release-notesflag to insert the latest version's notes
- use an
-
gitignoredistinstead ofbuildas that'sgoreleaser's default output directory -
change
Makefileto usegoreleaserinstead ofdeploy.shandgo build- note that
goreleaser buildis intended to replacego build- the example in the docs specifically mentions the use-case of a
Makefileandldflags, i.e. the exact use-case here
- the example in the docs specifically mentions the use-case of a
- add a
releasecommand -- to be changed by Sylvain as preferred
- note that
-
add
go.modandgo.sumto use Go modules instead of a customMakefilescript- since this is built into Go nowadays
- add
tools.goto contain dev dependencies, i.e.goreleaser- this is a Go convention, per https://github.com/golang/go/issues/25922#issuecomment-1038394599
- using standard Go modules should also make it easier for contributors to get started and for users to build from source
- made it easier for me!
- simplify
README.md's "Compiling" section accordingly- and remove reference to Go "Workspaces", as modules are now the preferred standard
- should also make it easier to add this to
homebrew-coreas the build is a standard Go build now for https://github.com/docopt/docopts/issues/59#issuecomment-1106900282 (search "Brew", step "4.")
-
add
.go-versionfile for standardizing which Go version to use withgoenv- use
1.17.1to match the previous release -- feel free to update this as needed
- use
Less hackiness and custom / bespoke scripts now! 🙂
So I'm training myself with github review. So you also received individual comment on this review. 😉
No worries, you seemed to have figured out how to use GH reviews already! 🙂
You did an amazing conversion work on my hacky code! 👍
Thank you! It took a bit of effort but seemed well worth it! 😄
goreleaser seems to have takeover all I was doing by external tool at the time I did start this project.
Yea and it's got lots of other features too -- like it can generate .deb packages for #22, Brew formulae, etc etc etc. I haven't used all of the features yet either.
So lets move forward.
I responded in-line to your comments / questions; let me know what changes you'd like to see from there.
At the very least, I'll have to update the pre-built-binaries.md doc with the new process using goreleaser and Go modules before this can be merged, as I didn't notice that file before.
Hello, I will be in vacation for a week. So I will pause my brain, including Opensource Software. :wink:
You wont see any more input from me until September 5th. Read you later.
😆 from CI:
/bin/sh: 1: goreleaser: not found
I fixed that! I wrote this PR and #62 simultaneously, so that was a bit of a "merge conflict" of sorts as I wasn't able to use Go 1.17 until a go.mod / go.sum existed. CI passes now 🙂
Added release notes generation now, so I think that addresses all remaining review comments.
@Sylvain303 do you think you'll be ready to merge this soon?
If not, I might split up the Go modules piece into a separate PR to be merged first (and leave this as just goreleaser stuff), as it's currently blocking https://github.com/docopt/docopts/issues/59#issuecomment-1229483738 .
That one would be much simpler; then you can take your time with this one as it wouldn't be blocking anything (for now).
I also made a few other tiny, mostly docs PRs 2 weeks ago in case you hadn't seen those.
Global note of the PR (may be more easy to search for, let's try)
For me to validate this PR
- [ ]
make(without argument build a single localdocoptswith correctVERSIONembedded) - [ ] validate
docs/release.mdsteps from testing and copy pasting command and complete missing stuf if any - [ ] publish release to my personal github account for testing the whole process
- [ ] test
CHANGELOG.mdbehavior ` --release-notes flag - [ ] go.mod huge list, hundred of megabyte download only for local build is (tools.go the way to go?)
VERSION vs goreleaser main.Version={{.Version}}
Our discussion here: https://github.com/docopt/docopts/pull/65#discussion_r954477423
release notes
According to https://goreleaser.com/customization/release/#custom-release-notes it can be a markdown file.
tools.go
according to cmd/go: clarify best practice for tool dependencies there's some behavior to keep in mind here.
go build only vs make
our conversation https://github.com/docopt/docopts/pull/65#discussion_r966675312
@agilgur5
do you think you'll be ready to merge this soon?
I made a comment on the PR roadmap steps in my comment above.
Unfortunately, I'm near, or already, at burnout. I'm brain behaving like a colander

Leaving some information out from the previous day. And progressing in mud disorganized fashion. So I may stop again from being active to rest. :sleeping: :worried:
I will progress on my decision today. Let's see how I organize myself...
I'm lost in PR too, obviously :wink:
I'm waking up and coding, for fun, as usual, let's see that Makefile target with my colander. :yum:
So, I'm in a resting phase no more than 2h of computer per day. I did my day.
Hello @agilgur5
I'm trying to work 1h on the PR. I can't push my changes to your PR branch:
sylvain@lap43: ~/code/go/src/github.com/docopt/docopts$ git push agilgur5 build-with-goreleaser
To github.com:agilgur5/docopts.git
! [rejected] build-with-goreleaser -> build-with-goreleaser (non-fast-forward)
error: failed to push some refs to 'github.com:agilgur5/docopts.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
May some rebase did happen related to parallel PR on CI or something I don't know.
I add a local branch based on you changes named agilgur5-build-with-goreleaser
I made a new one from your branching history:
git switch master
git checkout -b 2agilgur5-build-with-goreleaser 94799c5c834be4bd1e96723f3c269604e4c417ae
git pull agilgur5 build-with-goreleaser
I really dislike the bloated module thing introduced by goreleaser dependency as from being part of tools.go I think:
tooks > 1m to build because of the go mod tidy or something the builder think he has to download the world for building :thinking: quite strange I already downloaded plenty of time the 133 dependencies of goreleaser
sylvain@lap43: ~/code/go/src/github.com/docopt/docopts$ make clean
# remove goreleaser dist/ difrectrory recursively
rm -rf dist
rm -f docopts-* docopts README.tmp
sylvain@lap43: ~/code/go/src/github.com/docopt/docopts$ make
GOVERSION=$(go version) goreleaser build --rm-dist --snapshot --single-target -o docopts
• starting build...
• loading config file file=.goreleaser.yaml
• building only for linux/amd64 reason=single target is enabled
• loading environment variables
• getting and validating git state
• ignoring errors because this is a snapshot error=couldn't get remote URL: fatal: No remote configured to list refs from.
• building... commit=none latest tag=v0.0.0
• pipe skipped reason=disabled during snapshot mode
• parsing tag
• setting defaults
• running before hooks
• running hook=go mod tidy
• took: 1m21s
• snapshotting
• building snapshot... version=0.0.1-next
• checking distribution directory
• loading go mod information
• build prerequisites
• writing effective config file
• writing config=dist/config.yaml
• building binaries
• building binary=dist/docopts_linux_amd64_v1/docopts
• storing release metadata
• writing file=dist/artifacts.json
• writing file=dist/metadata.json
• copying binary to "docopts"
• build succeeded after 1m21s
I think we missed some step here about tooling and goreleaser invasive behavior on the module side.
I was looking a the make default target and CHANGELOG.md new feature in the Makefile, but the git glitch took all my time. :disappointed:
I still can't push :disappointed:
sylvain@lap43: ~/code/go/src/github.com/docopt/docopts$ git pull agilgur5 build-with-goreleaser
From github.com:agilgur5/docopts
* branch build-with-goreleaser -> FETCH_HEAD
Current branch 2agilgur5-build-with-goreleaser is up to date.
sylvain@lap43: ~/code/go/src/github.com/docopt/docopts$ git push agilgur5 build-with-goreleaser
To github.com:agilgur5/docopts.git
! [rejected] build-with-goreleaser -> build-with-goreleaser (non-fast-forward)
error: failed to push some refs to 'github.com:agilgur5/docopts.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
My changes:
diff --git a/Makefile b/Makefile
index 8cacfec..fa9240e 100644
--- a/Makefile
+++ b/Makefile
@@ -8,8 +8,8 @@ RELEASE_NOTES := $$(awk -v RS='\#\# *|\#\# ' 'NR==2 { print }' CHANGELOG.md)
# keep docopts: as first target for development
-docopts: docopts.go Makefile
- go build -o $@
+docopts: docopts.go Makefile VERSION
+ GOVERSION=$(GOVERSION) goreleaser build --single-target --rm-dist --snapshot -o $@
install_builddep:
go mod tidy
@@ -34,7 +34,9 @@ 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 dist/*
+ # remove goreleaser dist/ difrectrory recursively
+ rm -rf dist
+ rm -f docopts-* docopts README.tmp
test_release_notes:
echo "\n## $(RELEASE_NOTES)"
diff --git a/go.mod b/go.mod
index f096bb9..c6acfc7 100644
--- a/go.mod
+++ b/go.mod
@@ -4,6 +4,7 @@ go 1.17
require (
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
+ github.com/gookit/color v1.5.2
github.com/goreleaser/goreleaser v1.10.3
)
@@ -120,6 +121,7 @@ require (
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/xanzy/go-gitlab v0.68.2 // indirect
github.com/xanzy/ssh-agent v0.3.1 // indirect
+ github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
go.opencensus.io v0.23.0 // indirect
gocloud.dev v0.24.0 // indirect
golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70 // indirect
diff --git a/go.sum b/go.sum
index df532e0..42058be 100644
--- a/go.sum
+++ b/go.sum
@@ -424,6 +424,8 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/googleapis/gax-go/v2 v2.1.0 h1:6DWmvNpomjL1+3liNSZbVns3zsYzzCjm6pRBO1tLeso=
github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0=
+github.com/gookit/color v1.5.2 h1:uLnfXcaFjlrDnQDT+NCBcfhrXqYTx/rcCa6xn01Y8yI=
+github.com/gookit/color v1.5.2/go.mod h1:w8h4bGiHeeBpvQVePTutdbERIUf3oJE5lZ8HM0UgXyg=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/goreleaser/chglog v0.1.2 h1:tdzAb/ILeMnphzI9zQ7Nkq+T8R9qyXli8GydD8plFRY=
github.com/goreleaser/chglog v0.1.2/go.mod h1:tTZsFuSZK4epDXfjMkxzcGbrIOXprf0JFp47BjIr3B8=
@@ -682,6 +684,8 @@ github.com/xanzy/ssh-agent v0.3.1/go.mod h1:QIE4lCeL7nkC25x+yA3LBIYfwCc1TFziCtG7
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
+github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
+github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
I will see later.
The goal was to share my progress on the Makefile default target (requires goreleaser v1.11.3+)
To be continued.