Skip to content

Commit

Permalink
Add explicit binary version and resurrect "bashbrew.sh" for helping u…
Browse files Browse the repository at this point in the history
…sers compile from source
  • Loading branch information
tianon committed Apr 24, 2020
1 parent 173e6d7 commit 61ca39f
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**
!bashbrew.sh
!cmd/
!go.mod
!go.sum
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run: |
docker build --tag bashbrew --pull .
docker run --rm bashbrew tar -cC /usr/local/bin bashbrew | tar -xv
./bashbrew --help > /dev/null
./bashbrew --version
- name: Smoke Test
run: |
image='https://github.com/docker-library/official-images/raw/master/library/hello-world'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin/
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ RUN apt-get update; \
rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/bashbrew
COPY go.mod go.sum ./
COPY go.mod go.sum bashbrew.sh ./
COPY cmd cmd
COPY vendor vendor
RUN export CGO_ENABLED=0; \
go build -mod vendor -v -o /usr/local/bin/bashbrew ./cmd/bashbrew; \
bash -x ./bashbrew.sh --version; \
rm -r ~/.cache/go-build; \
bashbrew --help > /dev/null
mv bin/bashbrew /usr/local/bin/; \
bashbrew --version

ENV BASHBREW_CACHE /bashbrew-cache
# make sure our default cache dir exists and is writable by anyone (similar to /tmp)
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ NAME:
USAGE:
bashbrew [global options] command [command options] [arguments...]

VERSION:
v0.1.0

COMMANDS:
list, ls list repo:tag combinations for a given repo
build build (and tag) repo:tag combinations for a given repo
Expand All @@ -35,6 +38,7 @@ GLOBAL OPTIONS:
--library value where the bodies are buried (default: "/home/tianon/docker/official-images/library") [$BASHBREW_LIBRARY]
--cache value where the git wizardry is stashed (default: "/home/tianon/.cache/bashbrew") [$BASHBREW_CACHE]
--help, -h, -? show help
--version, -v print the version
```

## Installing
Expand Down
12 changes: 12 additions & 0 deletions bashbrew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -Eeuo pipefail

# a small shell script to help compile bashbrew

dir="$(readlink -f "$BASH_SOURCE")"
dir="$(dirname "$dir")"

export GO111MODULE=on
go build -o bin/bashbrew -mod vendor ./cmd/bashbrew > /dev/null

exec "$dir/bin/bashbrew" "$@"
3 changes: 1 addition & 2 deletions cmd/bashbrew/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ func main() {
app := cli.NewApp()
app.Name = "bashbrew"
app.Usage = "canonical build tool for the official images"
app.Version = "dev"
app.HideVersion = true
app.Version = version
app.EnableBashCompletion = true

// TODO add "Description" to app and commands (for longer-form description of their functionality)
Expand Down
3 changes: 3 additions & 0 deletions cmd/bashbrew/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package main

const version = "v0.1.0"

0 comments on commit 61ca39f

Please sign in to comment.