diff --git a/.travis.yml b/.travis.yml index ae55811..19e0ff8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,13 @@ language: go go: - - "1.11.x" - -before_script: - - go get -u github.com/mitchellh/gox - - env GO111MODULE=on go vet ./... + - "1.25.x" install: true script: + - go vet ./... + - go test ./... - ./build.sh deploy: diff --git a/README.md b/README.md index 2c29742..f9f047e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # `dbxcli`: A command line tool for Dropbox users and team admins [UNOFFICIAL] -[![Build Status](https://travis-ci.org/dropbox/dbxcli.svg?branch=master)](https://travis-ci.org/dropbox/dbxcli) +[![Build Status](https://app.travis-ci.com/dropbox/dbxcli.svg?branch=master)](https://app.travis-ci.com/dropbox/dbxcli) [![Go Report Card](https://goreportcard.com/badge/github.com/dropbox/dbxcli)](https://goreportcard.com/report/github.com/dropbox/dbxcli) :warning: WARNING: This project is **NOT official**. What does this mean? @@ -49,18 +49,25 @@ $ chmod +x dbxcli ### Instructions for building yourself For newcomers the go build process can be a bit arcane, these steps can be followed to build `dbxcli` yourself. -1. Make sure `git`, `go`, and `gox` are installed. -2. Create a Go folder. For example, `mkdir $HOME/go` or `mkdir $HOME/.go`. Navigate to it. -3. `go get github.com/dropbox/dbxcli`. That's right, you don't manually clone it, this does it for you. -4. `cd ~/go/src/github.com/dropbox/dbxcli` (adapt accordingly based on step 2). +1. Make sure `git` and `go` are installed. +2. Install the latest released version: + ```sh + $ go install github.com/dropbox/dbxcli@latest + ``` +3. Or build from source: + ```sh + $ git clone https://github.com/dropbox/dbxcli.git + $ cd dbxcli + $ go build . + ``` + +To use your own Dropbox app while developing, provide its app key when logging in: -To use your own Dropbox app while developing, provide its app key when running -`dbxcli`: ```sh -$ export DROPBOX_PERSONAL_APP_KEY=your-app-key +$ dbxcli login --app-key=your-app-key ``` -Finally we're ready to build. Run `go build`, and you'll see a `dbxcli` binary has been created in the current directory. Congrats, we're done! +If you built from source, the `go build .` command creates a `dbxcli` binary in the current directory. ## Usage diff --git a/build.sh b/build.sh index bd26171..7a8655f 100755 --- a/build.sh +++ b/build.sh @@ -1,12 +1,20 @@ #!/bin/bash -LDFLAGS="-s -w -X main.version=${TRAVIS_TAG:-TRAVIS_COMMIT}" -LDFLAGS+=" -X github.com/dropbox/dbxcli/cmd.personalAppKey=${PERSONAL_KEY}" -LDFLAGS+=" -X github.com/dropbox/dbxcli/cmd.personalAppSecret=${PERSONAL_SECRET}" -LDFLAGS+=" -X github.com/dropbox/dbxcli/cmd.teamAccessAppKey=${ACCESS_KEY}" -LDFLAGS+=" -X github.com/dropbox/dbxcli/cmd.teamAccessAppSecret=${ACCESS_SECRET}" -LDFLAGS+=" -X github.com/dropbox/dbxcli/cmd.teamManageAppKey=${MANAGE_KEY}" -LDFLAGS+=" -X github.com/dropbox/dbxcli/cmd.teamManageAppSecret=${MANAGE_SECRET}" -GO111MODULE=on gox -ldflags="${LDFLAGS}" \ - -osarch="darwin/amd64 linux/amd64 windows/amd64 linux/arm openbsd/amd64" \ - -output "dist/{{.Dir}}-{{.OS}}-{{.Arch}}" +set -e + +LDFLAGS="-s -w -X main.version=${TRAVIS_TAG:-${TRAVIS_COMMIT:-dev}}" + +TARGETS="darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 linux/arm openbsd/amd64 windows/amd64" + +mkdir -p dist + +for target in $TARGETS; do + GOOS="${target%/*}" + GOARCH="${target#*/}" + output="dist/dbxcli-${GOOS}-${GOARCH}" + if [ "$GOOS" = "windows" ]; then + output="${output}.exe" + fi + echo "Building ${target}..." + GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="${LDFLAGS}" -o "$output" . +done