Skip to content

Commit

Permalink
Taskfile machinery to make GitHub releases
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-m committed Jun 5, 2020
1 parent ae8aa32 commit cd8e0b6
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
bin/
TODO.txt
TODO.md
*.code-workspace
27 changes: 16 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
45 changes: 37 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
76 changes: 75 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions secrets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GITHUB_TOKEN: !var m/github/repo

0 comments on commit cd8e0b6

Please sign in to comment.