diff --git a/MAINTAINERS.md b/MAINTAINERS.md new file mode 100644 index 0000000000..0d61d10b64 --- /dev/null +++ b/MAINTAINERS.md @@ -0,0 +1,87 @@ +**This guide is intended for scaleway-cli maintainers. If you are not a +maintainer, you probably want to check out the [documentation](README.md) +instead.** + +## Package release HOWTO + +Ready to deploy a new version to users? Let's make a checklist of what you need +to do. + +For the sake of the example, we assume you want to release the version `42.8`. + +### Commit release + +* Edit the Changelog in [README.md](README.md), ensure it is up to date and + fill the current date. Also update the link in the line "View full commits + list": replace *master* with *v42.8*. +* Edit [pkg/scwversion/version.go](pkg/scwversion/version.go) and update the + *VERSION* to *v42.8*. +* Make the commit release: `git commit -m 'Release v42.8'`. +* Tag the commit: `git tag v42.8`. +* Push: `git push && git push --tags`. + +### Make a github release + +* [Draft a new release](https://github.com/scaleway/scaleway-cli/releases) on + Github. +* Build release files: `make prepare-release`. +* Upload the generated files in *dist/42.8/* to github. +* Publish the release. + +### Docker image + +The image *scaleway/cli* has been created by `make prepare-release` called +during the previous step. + +* Push the local Docker image to the Docker hub: `docker push scaleway/cli`. + +### Homebrew (OSX) package + +* Get the released archive's sha256sum: `curl -sL + https://github.com/scaleway/scaleway-cli/archive/v42.8.tar.gz | shasum -a + 256`. +* Clone the homebrew Github repository: `git clone + git@github.com:Homebrew/brew.git` to you personal account. +* Edit *Formula/scw.rb* and fix the *url* and the *sha256* on top of the file. +* Make a pull request from your repository to + [homebrew](https://github.com/Homebrew/homebrew-core) to make your new + version official. + +### Archlinux package + +**This section is incomplete. Edit this part if you have additional +informations.** + +There is a Archlinux community package (aka. "AUR" — Archlinux User Repository) +for scaleway-cli: https://aur.archlinux.org/packages/scaleway-cli/ maintained +by "moscar". We should probably ping him when we make a new release. + +### Update VERSION file + +From time to time, scaleway-cli makes a HTTP query to +https://fr-1.storage.online.net/scaleway/scaleway-cli/VERSION to check if it is +at the latest version available. This file needs to be updated. + +``` +$> echo '42.8' > VERSION +$> s3cmd put VERSION s3://scaleway/scaleway-cli/VERSION --acl-public +# Ensure it's at the latest version +$> curl https://fr-1.storage.online.net/scaleway/scaleway-cli/VERSION +# Should display "42.8". +``` + +### Post release commit + +* Edit [README.md](README.md) and create a new *(unreleased)* entry: + + ``` + ### v42.8+dev (unreleased) + + This is the current development version. Update below with your changes. Remove + this line when releasing the package. + + View full [commits list](https://github.com/scaleway/scaleway-cli/compare/v42.8...master) + ``` + +* Edit [pkg/scwversion/version.go](pkg/scwversion/version.go) and set *VERSION* + to *v42.8+dev*. diff --git a/Makefile b/Makefile index 617bca8c9f..73731125c8 100644 --- a/Makefile +++ b/Makefile @@ -9,18 +9,19 @@ GOTEST ?= $(GO) test $(GOTESTFLAGS) GOFMT ?= gofmt -w -s GODIR ?= github.com/scaleway/scaleway-cli GOCOVER ?= $(GOTEST) -covermode=count -v -FPM_VERSION ?= $(shell ./dist/scw-Darwin-i386 --version | sed 's/.*v\([0-9.]*\),.*/\1/g') -FPM_DOCKER ?= \ + +# FPM is a simple way to create debian/rpm/... packages. +FPM_DOCKER = \ -it --rm \ - -v $(PWD)/dist:/output \ + -v $(PWD)/dist/latest:/output \ -w /output \ - tenzer/fpm fpm -FPM_ARGS ?= \ + tenzer/fpm + +FPM_ARGS = \ -C /input/ \ -s dir \ --name=scw \ --no-depends \ - --version=$(FPM_VERSION) \ --license=mit \ -m "Scaleway " @@ -32,9 +33,7 @@ COMMANDS := $(shell go list ./... | grep -v /vendor/ | grep /cmd/) PACKAGES := $(shell go list ./... | grep -v /vendor/ | grep -v /cmd/) REL_COMMANDS := $(subst $(GODIR),.,$(COMMANDS)) REL_PACKAGES := $(subst $(GODIR),.,$(PACKAGES)) -VERSION = $(shell cat .goxc.json | grep "PackageVersion" | egrep -o "([0-9]{1,}\.)+[0-9]{1,}") REV = $(shell git rev-parse --short HEAD || echo "nogit") -TAG = $(shell git describe --tags --always || echo $(VERSION) || echo "nogit") LDFLAGS = "-X `go list ./pkg/scwversion`.GITCOMMIT=$(REV) -s" BUILDER = scaleway-cli-builder @@ -65,71 +64,63 @@ test: $(TEST_LIST) fmt: $(FMT_LIST) -.git: - touch $@ - - $(BUILD_LIST): %_build: %_fmt @go tool vet --all=true $(SOURCES) $(GOBUILD) -ldflags $(LDFLAGS) -o $(NAME) $(subst $(GODIR),.,$*) + $(CLEAN_LIST): %_clean: $(GOCLEAN) $(subst $(GODIR),./,$*) + $(INSTALL_LIST): %_install: $(GOINSTALL) $(subst $(GODIR),./,$*) + $(TEST_LIST): %_test: $(GOTEST) -ldflags $(LDFLAGS) -v $(subst $(GODIR),.,$*) + $(FMT_LIST): %_fmt: @$(GOFMT) $(SOURCES) +prepare-release: build + ### Prepare dist/ directory ### + $(eval VERSION := $(shell ./scw version | sed -n 's/Client version: v\(.*\)/\1/p')) + rm -rf dist/$(VERSION) + rm -rf dist/latest + mkdir -p dist/$(VERSION) + ln -s -f $(VERSION) dist/latest + ### Cross compile scaleway-cli ### + GOOS=linux GOARCH=386 go build -o dist/latest/scw-linux-i386 github.com/scaleway/scaleway-cli/cmd/scw + GOOS=linux GOARCH=amd64 go build -o dist/latest/scw-linux-amd64 github.com/scaleway/scaleway-cli/cmd/scw + GOOS=linux GOARCH=arm go build -o dist/latest/scw-linux-arm github.com/scaleway/scaleway-cli/cmd/scw -release-docker: - docker push scaleway/cli - - -goxc: - rm -rf dist/$(shell cat .goxc.json| jq -r .PackageVersion) - rm -f dist/latest - mkdir -p dist/$(shell cat .goxc.json| jq -r .PackageVersion) - ln -s -f $(shell cat .goxc.json| jq -r .PackageVersion) dist/latest - - $(GOENV) goxc -build-ldflags $(LDFLAGS) + GOOS=darwin GOARCH=386 go build -o dist/latest/scw-darwin-i386 github.com/scaleway/scaleway-cli/cmd/scw + GOOS=darwin GOARCH=amd64 go build -o dist/latest/scw-darwin-amd64 github.com/scaleway/scaleway-cli/cmd/scw - -mv dist/latest/darwin_386/scw dist/latest/scw-Darwin-i386 - -mv dist/latest/darwin_amd64/scw dist/latest/scw-Darwin-amd64 - -mv dist/latest/freebsd_386/scw dist/latest/scw-Freebsd-i386 - -mv dist/latest/freebsd_amd64/scw dist/latest/scw-Freebsd-x86_64 - -mv dist/latest/freebsd_arm/scw dist/latest/scw-Freebsd-arm - -mv dist/latest/linux_386/scw dist/latest/scw-Linux-i386 - -mv dist/latest/linux_amd64/scw dist/latest/scw-Linux-x86_64 - -mv dist/latest/linux_arm/scw dist/latest/scw-Linux-arm - -mv dist/latest/netbsd_386/scw dist/latest/scw-Netbsd-i386 - -mv dist/latest/netbsd_amd64/scw dist/latest/scw-Netbsd-x86_64 - -mv dist/latest/netbsd_arm/scw dist/latest/scw-Netbsd-arm - -mv dist/latest/windows_386/scw.exe dist/latest/scw-Windows-i386.exe - -mv dist/latest/windows_amd64/scw.exe dist/latest/scw-Windows-x86_64.exe + GOOS=freebsd GOARCH=386 go build -o dist/latest/scw-freebsd-i386 github.com/scaleway/scaleway-cli/cmd/scw + GOOS=freebsd GOARCH=amd64 go build -o dist/latest/scw-freebsd-amd64 github.com/scaleway/scaleway-cli/cmd/scw + GOOS=freebsd GOARCH=arm go build -o dist/latest/scw-freebsd-arm github.com/scaleway/scaleway-cli/cmd/scw - -cp dist/latest/scw-Linux-arm dist/latest/scw-Linux-armv7l + GOOS=netbsd GOARCH=386 go build -o dist/latest/scw-netbsd-i386 github.com/scaleway/scaleway-cli/cmd/scw + GOOS=netbsd GOARCH=amd64 go build -o dist/latest/scw-netbsd-amd64 github.com/scaleway/scaleway-cli/cmd/scw + GOOS=netbsd GOARCH=arm go build -o dist/latest/scw-netbsd-arm github.com/scaleway/scaleway-cli/cmd/scw - @rmdir dist/latest/* || true + GOOS=windows GOARCH=386 go build -o dist/latest/scw-windows-i386.exe github.com/scaleway/scaleway-cli/cmd/scw + GOOS=windows GOARCH=amd64 go build -o dist/latest/scw-windows-amd64.exe github.com/scaleway/scaleway-cli/cmd/scw - docker run --rm golang tar -cf - /etc/ssl > dist/latest/ssl.tar + ### Prepare scaleway-cli Docker image ### + docker run --rm golang tar -cf - /etc/ssl > dist/ssl.tar docker build -t scaleway/cli dist docker run scaleway/cli version - docker tag -f scaleway/cli:latest scaleway/cli:$(TAG) - - @echo "Now you can run 'goxc publish-github', 'goxc bintray' and 'make release-docker'" - - -packages: - rm -f dist/*.deb - docker run -v $(PWD)/dist/scw-Linux-x86_64:/input/scw $(FPM_DOCKER) $(FPM_ARGS) -t deb -a x86_64 ./ - docker run -v $(PWD)/dist/scw-Linux-i386:/input/scw $(FPM_DOCKER) $(FPM_ARGS) -t deb -a i386 ./ - docker run -v $(PWD)/dist/scw-Linux-arm:/input/scw $(FPM_DOCKER) $(FPM_ARGS) -t deb -a arm ./ + docker tag scaleway/cli:latest scaleway/cli:$(TAG) + ### Build debian packages ### + docker run -v $(PWD)/dist/latest/scw-linux-amd64:/input/usr/bin/scw $(FPM_DOCKER) $(FPM_ARGS) --version $(VERSION) -t deb -a x86_64 ./ + docker run -v $(PWD)/dist/latest/scw-linux-i386:/input/usr/bin/scw $(FPM_DOCKER) $(FPM_ARGS) --version $(VERSION) -t deb -a i386 ./ + docker run -v $(PWD)/dist/latest/scw-linux-arm:/input/usr/bin/scw $(FPM_DOCKER) $(FPM_ARGS) --version $(VERSION) -t deb -a arm ./ -#publish_packages: -# docker run -v $(PWD)/dist moul/dput ppa:moul/scw dist/scw_$(FPM_VERSION)_arm.changes + ### DONE ### + @echo "Release files have been created into dist/latest. See MAINTAINERS.md." + @echo "The scaleway-cli Docker image has been created. See MAINTAINERS.md." .PHONY: golint diff --git a/contrib/homebrew/scw.rb b/contrib/homebrew/scw.rb deleted file mode 100644 index cc77e97856..0000000000 --- a/contrib/homebrew/scw.rb +++ /dev/null @@ -1,37 +0,0 @@ -require "language/go" - -class Scw < Formula - desc "Manage BareMetal Servers from Command Line (as easily as with Docker)" - homepage "https://github.com/scaleway/scaleway-cli" - url "https://github.com/scaleway/scaleway-cli/archive/v1.12.tar.gz" - sha256 "7a23ef6960fe280dd19f8e2e9b0fff6ffaf4b8446ddc7833b530901875652e2e" - version "1.12" - - head "https://github.com/scaleway/scaleway-cli.git" - - depends_on "go" => :build - - def install - ENV["GOPATH"] = buildpath - ENV["GOBIN"] = buildpath - ENV["GO15VENDOREXPERIMENT"] = "1" - (buildpath/"src/github.com/scaleway/scaleway-cli").install Dir["*"] - - system "go", "build", "-o", "#{bin}/scw", "-v", "-ldflags", "-X github.com/scaleway/scaleway-cli/pkg/scwversion.GITCOMMIT=homebrew", "github.com/scaleway/scaleway-cli/cmd/scw/" - # we remove our .scw-cache.db file, to clean the cache of scw - # this file is created and handled by scw - rm_f "~/.scw-cache.db" - - bash_completion.install "src/github.com/scaleway/scaleway-cli/contrib/completion/bash/scw" - zsh_completion.install "src/github.com/scaleway/scaleway-cli/contrib/completion/zsh/_scw" - end - - def caveats - "Use `scw login` to set up the correct environment to use scaleway-cli." - end - - test do - output = shell_output(bin/"scw version") - assert_match "OS/Arch (client): darwin/amd64", output - end -end diff --git a/dist/Dockerfile b/dist/Dockerfile index 358b68fd17..565836fa84 100644 --- a/dist/Dockerfile +++ b/dist/Dockerfile @@ -1,6 +1,10 @@ FROM scratch MAINTAINER Scaleway (@scaleway) -ADD latest/ssl.tar / -COPY latest/scw-Linux-i386 /bin/scw -VOLUME /root/ + +# ssl.tar is created by `make prepare-release`. It is an extract of the +# /etc/ssl directory of a golang image. +ADD ssl.tar / + +COPY latest/scw-linux-i386 /bin/scw + ENTRYPOINT ["/bin/scw"]