diff --git a/.gitignore b/.gitignore index 6c64d20..1b99b3c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ bin/ -TODO.txt +TODO.md *.code-workspace diff --git a/CHANGELOG.md b/CHANGELOG.md index 0077648..8feb6d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,31 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased -### Fixes +### Fixed -### Breaking Changes +### Changed, breaking -### Changes +### Changed -### Additions +### New -## [v0.1.0] - [2020-06-02] +## [v0.2.0] - [2020-06-05] -First release. +### New -### Fixes +- Binary releases available from GitHub [releases + page](https://github.com/marco-m/timeit/releases). +- Taskfile machinery to make GitHub releases, using + [github-release](https://github.com/github-release/github-release) -### Breaking Changes +## [v0.1.0] - [2020-06-02] -### Changes +First release. -### Additions +### New - Basic timing functionalities. - Print timing results also if child exits with error. - Return correct exit code if child is terminated by a signal (128 + sigNum). -- Ignore SIGINT; let child handle it (see commit comments for ac061824f). +- Ignore SIGINT as /usr/bin/time does; let child handle it (see commit comments + for ac061824f). - flag `-version` reports the git commit. [v0.1.0]: https://github.com/marco-m/timeit/releases/tag/v0.1.0 +[v0.2.0]: https://github.com/marco-m/timeit/releases/tag/v0.2.0 diff --git a/README.md b/README.md index 73e1baf..6f35d21 100644 --- a/README.md +++ b/README.md @@ -8,29 +8,58 @@ It has some features inspired by the FreeBSD `/usr/bin/time`: ## Examples +Timing a command, with or without options: + $ timeit sleep 61 timeit results: real: 1m1.007506918s +Timing a shell construct: you have to time the execution of a subshell, for +example: + + $ timeit fish -c 'for i in (seq 3); sleep 1; echo $i; end' + 1 + 2 + 3 + timeit results: + real: 3.035378818s + # Status -Version 0. Working and tested, but expect breaking changes. +Before 1.0.0. Working and tested, backwards incompatible changes possible. ## Supported platforms Unix-like and macOS. +## Installation + +1. Download the archive for your platform from the [releases + page](https://github.com/marco-m/timeit/releases). +2. Unarchive and copy the `timeit` executable somewhere in your `$PATH`. I like + to use `$HOME/bin/`. + +### Installation for macOS + +You have to cope with the macOS gatekeeper, that will put the executable in +quarantine, since it is not signed nor notarized. There are two options: + +1. Download the archive with a command-line tool, like curl or wget. +2. Download the archive with a web browser, unarchive and run + ``` + $ xattr -d com.apple.quarantine timeit + ``` + ## Build and install -* Option 1. - 1. Install [task](https://taskfile.dev/). - 2. `$ task` +1. Install [task](https://taskfile.dev/). +2. `$ task` + +Then, copy the executable to a directory in your `$PATH`. -* Option 2. - 1. `$ go build ./cmd/timeit` - 2. `$ go test ./...` +## Making a release -Then, copy the executable to a directory in your `$PATH`, for example `~/bin`. + $ env RELEASE_TAG=v0.1.0 summon task release ## License diff --git a/Taskfile.yml b/Taskfile.yml index e5730ad..8ae8960 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -7,7 +7,7 @@ tasks: deps: [test] clean: desc: Delete build artifacts - cmds: [rm -f bin/*] + cmds: [rm -rf bin/*] timeit: desc: Build the timeit executable dir: bin @@ -32,3 +32,77 @@ tasks: GOTESTSUM: sh: which gotestsum; true TESTRUNNER: "{{if .GOTESTSUM}}{{.GOTESTSUM}}{{else}}go test{{end}}" + + # usage: env RELEASE_TAG=v0.1.0 summon task release + release: + desc: Build a release and upload to GitHub as draft. You need to transition + from draft to published in the web UI. + preconditions: + - sh: test -n "$RELEASE_TAG" + msg: "error: missing environment variable RELEASE_TAG" + - sh: test -z $(git status --porcelain) + msg: "error: git dirty" + - sh: test -z $(git status --branch --porcelain | grep ahead) + msg: "error: git local branch ahead" + cmds: + # - task: unit-test + # We create the (local) git tag now, after having ran the unit tests and + # before building the executables, so that we can embed this information + # in the binaries. + # To recover: delete local tag: git tag --delete tagname + - git tag -a {{.RELEASE_TAG}} -m '' + - task: release-linux + - task: release-darwin + # - task: system-test + - task: test + # We create the release as a draft (that is: not visible to the public). + # The act of "publishing" the release is left to a human from the web UI. + - > + github-release release + --tag {{.RELEASE_TAG}} + --draft + --description "See the [CHANGELOG](https://github.com/$GITHUB_USER/$GITHUB_REPO/blob/{{.RELEASE_TAG}}/CHANGELOG.md)" + # Upload the artifacts. + - > + github-release upload + --tag {{.RELEASE_TAG}} + --name timeit-linux-amd64.zip + --file bin/linux/timeit-linux-amd64.zip + - > + github-release upload + --tag {{.RELEASE_TAG}} + --name timeit-darwin-amd64.zip + --file bin/darwin/timeit-darwin-amd64.zip + # We don't push the git tag. Instead, in the web UI, the act of + # transitioning the release from draft to published will create the + # corresponding tag in the remote repository. This is safer, because it + # reduces the situations when one might be tempted to delete a public tag + # due to a mistake in the release. + - cmd: | + echo "Draft release $RELEASE_TAG created successfully." + echo "Remember to publish it in the GitHub web UI https://github.com/$GITHUB_USER/$GITHUB_REPO/releases" + silent: true + env: + GITHUB_USER: marco-m + GITHUB_REPO: timeit + # GITHUB_TOKEN expected to be set securely via `summon` or equivalent + release-linux: + dir: bin/linux + cmds: &release-cmds + - go build -v -ldflags="-w -s -X main.version={{.GIT_COMMIT}}" ../../cmd/timeit + - zip timeit-$GOOS-$GOARCH.zip timeit + env: + CGO_ENABLED: 0 + GOOS: linux + GOARCH: amd64 + vars: + GIT_COMMIT: *git-commit + release-darwin: + dir: bin/darwin + cmds: *release-cmds + env: + CGO_ENABLED: 0 + GOOS: darwin + GOARCH: amd64 + vars: + GIT_COMMIT: *git-commit diff --git a/secrets.yml b/secrets.yml new file mode 100644 index 0000000..bfd19f5 --- /dev/null +++ b/secrets.yml @@ -0,0 +1 @@ +GITHUB_TOKEN: !var m/github/repo