Skip to content

Commit 31e4d4e

Browse files
authored
Merge pull request #11 from areed/areed/ch568/vendor-cli-release
install script for linux
2 parents 1a9b0a6 + 175f2db commit 31e4d4e

File tree

6 files changed

+114
-33
lines changed

6 files changed

+114
-33
lines changed

.goreleaser.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ release:
66
brew:
77
github:
88
owner: replicatedhq
9-
name: replicated
9+
name: homebrew-replicated
10+
folder: HomebrewFormula
1011
install: bin.install "replicated"
1112
homepage: https://replicated.com
1213
description: "Manage your app's channels and releases from the command line"

Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ RUN go get github.com/spf13/cobra/cobra
1010

1111
RUN go get github.com/go-swagger/go-swagger/cmd/swagger
1212

13-
RUN curl --location -o goreleaser.deb https://github.com/goreleaser/goreleaser/releases/download/v0.24.0/goreleaser_Linux_x86_64.deb
14-
RUN dpkg -i goreleaser.deb
15-
1613
WORKDIR $PROJECTPATH
1714

1815
CMD ["/bin/bash"]

Makefile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,6 @@ build:
5454
go build -o replicated cli/main.go
5555
mv replicated ${GOPATH}/bin
5656

57-
# release the latest tag
58-
release:
59-
docker run --rm -it \
60-
--volume `pwd`:/go/src/github.com/replicatedhq/replicated \
61-
--env GITHUB_TOKEN=${GITHUB_TOKEN} \
62-
replicatedhq.replicated goreleaser
63-
6457
docs:
6558
go run docs/generate.go --path ./gen/docs
6659

README.md

Lines changed: 81 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
# replicated
22

33
This repository provides a client and CLI for interacting with the Replicated Vendor API.
4-
The models are generated from the API's swagger spec.
54

65
## CLI
76

8-
Grab the latest [release](https://github.com/replicatedhq/replicated/releases) and extract it to your path.
97

8+
### Mac Install
9+
```
10+
brew install replicatedhq/replicated/replicated
11+
```
12+
13+
### Linux Install
14+
```
15+
curl -sSL https://raw.githubusercontent.com/replicatedhq/replicated/master/install.sh
16+
sudo bash ./install.sh
17+
```
18+
19+
### Getting Started
1020
```
1121
replicated channel ls --app my-app-slug --token e8d7ce8e3d3278a8b1255237e6310069
1222
```
@@ -15,6 +25,70 @@ Set the following env vars to avoid passing them as arguments to each command.
1525
* REPLICATED_APP_SLUG
1626
* REPLICATED_API_TOKEN
1727

28+
Then the above command would be simply
29+
```
30+
replicated channel ls
31+
```
32+
33+
### CI Example
34+
Creating a new release for every tagged build is a common use of the replicated command.
35+
36+
Assume the app's yaml config is checked in at replicated.yaml and you have configured TravisCI or CircleCI with your REPLICATED_APP_SLUG and REPLICATED_API_TOKEN environment variables, as well as UNSTABLE_CHANNEL_ID```.
37+
38+
Then add a release.sh script to your project looking something like this:
39+
40+
```bash
41+
#!/bin/bash
42+
43+
# Create a new release from replicated.yaml and promote the Unstable channel to use it.
44+
# Aborts if version tag is empty.
45+
46+
set -e
47+
48+
VERSION=$1
49+
INSTALL_SCRIPT=https://raw.githubusercontent.com/replicatedhq/replicated/master/install.sh
50+
51+
if [ -z "$VERSION" ]; then
52+
echo "No version; skipping replicated release"
53+
exit
54+
fi
55+
56+
unstable_channel_id() {
57+
replicated channel ls | grep Unstable | awk '{print $1}'
58+
}
59+
60+
new_sequence() {
61+
replicated release create --yaml "$(< replicated.yaml)" | grep 'SEQUENCE:' | grep -Eo '[0-9]+'
62+
}
63+
64+
# install replicated
65+
curl -sSL "$INSTALL_SCRIPT" > install.sh
66+
sudo bash ./install.sh
67+
68+
replicated release promote $(new_sequence) $(unstable_channel_id) --version "$VERSION"
69+
# Channel ee9d99e87b4a5acc2863f68cb2a0c390 successfully promoted to release 15
70+
```
71+
72+
Now you can automate tagged releases in TravisCI or CircleCI:
73+
74+
```yaml
75+
# .travis.yml
76+
sudo: required
77+
after_success:
78+
- ./release.sh "$TRAVIS_TAG"
79+
80+
```
81+
82+
```yaml
83+
# circle.yml
84+
deployment:
85+
tag:
86+
tag: /v.*/
87+
owner: replicatedcom
88+
commands:
89+
- ./release.sh "$CIRCLE_TAG"
90+
```
91+
1892
## Client
1993
2094
[GoDoc](https://godoc.org/github.com/replicatedhq/replicated/client)
@@ -53,20 +127,16 @@ func main() {
53127

54128
## Development
55129
```make build``` installs the binary to ```$GOPATH/bin```
130+
The models are generated from the API's swagger spec.
56131

57132
### Tests
58-
REPLICATED_API_ORIGIN may be set for testing an alternative environment.
59133

60-
Since apps can only be deleted in a login session, set these to cleanup garbage from the tests.
61-
VENDOR_USER_EMAIL should be set to delete app
62-
VENDOR_USER_PASSWORD should be set to delete app
134+
#### Environment
135+
* ```REPLICATED_API_ORIGIN``` may be set to override the API endpoint
136+
* ```VENDOR_USER_EMAIL``` and ```VENDOR_USER_PASSWORD``` should be set to delete apps created for testing
63137

64138
### Releases
65-
Releases are created locally with [goreleaser](https://github.com/goreleaser/goreleaser).
66-
Tag the commit to release then run goreleaser.
67-
Ensure GITHUB_TOKEN is [set](https://github.com/settings/tokens/new).
68-
139+
Releases are created on Travis when a tag is pushed. This will also update the docs container.
69140
```
70141
git tag -a v0.1.0 -m "First release" && git push origin v0.1.0
71-
make release
72142
```

install.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
set -e
3+
4+
TAR_FILE="/tmp/replicated.tar.gz"
5+
6+
RELEASES_URL="https://github.com/replicatedhq/replicated/releases"
7+
8+
test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"
9+
10+
last_version() {
11+
curl --silent --location --output /dev/null --write-out %{url_effective} ${RELEASES_URL}/latest |
12+
grep -Eo '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]$'
13+
}
14+
15+
download() {
16+
if [[ $(uname -m) =~ '64$' ]]; then
17+
ARCH=amd64
18+
else
19+
ARCH=386
20+
fi
21+
VERSION="$(last_version)"
22+
# https://github.com/replicatedhq/replicated/releases/download/v0.1.1/replicated_0.1.1_linux_amd64.tar.gz
23+
URL="${RELEASES_URL}/download/v${VERSION}/replicated_${VERSION}_$(uname -s)_${ARCH}.tar.gz"
24+
25+
rm -f "$TAR_FILE"
26+
curl -s -L -o "$TAR_FILE" "$URL"
27+
}
28+
29+
download
30+
tar -xf "$TAR_FILE" -C "$TMPDIR"
31+
mv "${TMPDIR}/replicated" /usr/local/bin

replicated.rb

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)