From 58bd36e79ee097dbf8a1e905935200b1bb1a8b1c Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Mon, 5 Nov 2018 15:02:16 +0100 Subject: [PATCH] Automate github releases (#1263) --- Makefile | 28 +++++++++++++++++++++++++- README.md | 17 ++++++++++++++++ VERSION | 1 + _assets/ci/Jenkinsfile-manual | 38 +++++++++++------------------------ 4 files changed, 57 insertions(+), 27 deletions(-) create mode 100644 VERSION diff --git a/Makefile b/Makefile index 50e39831f..a2a327c47 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,11 @@ .PHONY: statusgo statusd-prune all test xgo clean help .PHONY: statusgo-android statusgo-ios +RELEASE_TAG := $(shell cat VERSION) +RELEASE_BRANCH := "develop" +RELEASE_DIRECTORY := /tmp/release-$(RELEASE_TAG) +PRE_RELEASE := "1" + help: ##@other Show this help @perl -e '$(HELP_FUN)' $(MAKEFILE_LIST) @@ -201,12 +206,33 @@ xgo: install-os-dependencies: _assets/scripts/install_deps.sh -setup: install-os-dependencies dep-install lint-install mock-install gen-install update-fleet-config ##@other Prepare project for first build +setup: install-os-dependencies dep-install lint-install mock-install deploy-install gen-install update-fleet-config ##@other Prepare project for first build generate: ##@other Regenerate assets and other auto-generated stuff go generate ./static ./static/migrations $(shell cd ./services/shhext/chat && exec protoc --go_out=. ./*.proto) +prepare-release: clean-release + mkdir -p $(RELEASE_DIRECTORY) + mv build/bin/statusgo-android-16.aar $(RELEASE_DIRECTORY)/status-go-android.aar + mv build/bin/statusgo-ios-9.3-framework/status-go-ios.zip $(RELEASE_DIRECTORY)/status-go-ios.zip + ${MAKE} clean + zip -r $(RELEASE_DIRECTORY)/status-go-desktop.zip . -x *.git* + +clean-release: + rm -rf $(RELEASE_DIRECTORY) + +release: + @read -p "Are you sure you want to create a new GitHub $(shell if [[ $(PRE_RELEASE) = "0" ]] ; then echo release; else echo pre-release ; fi) against $(RELEASE_BRANCH) branch? (y/n): " REPLY; \ + if [ $$REPLY = "y" ]; then \ + github-release $(shell if [[ $(PRE_RELEASE) != "0" ]] ; then echo "-prerelease" ; fi) "status-im/status-go" "$(RELEASE_TAG)" "$(RELEASE_BRANCH)" "" "$(RELEASE_DIRECTORY)/*" ; \ + else \ + echo "Aborting." && exit 1; \ + fi + +deploy-install: + go get -u github.com/c4milo/github-release + gen-install: go get -u github.com/jteeuwen/go-bindata/... go get -u github.com/golang/protobuf/protoc-gen-go diff --git a/README.md b/README.md index e6e71fe56..5b3dc80a3 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,20 @@ # License [Mozilla Public License 2.0](https://github.com/status-im/status-go/blob/develop/LICENSE.md) + +### Releasing + +To create a release, first increase the `VERSION` file according to semantic versioning. + +You can then build the artifacts for the specific platform. + +Once done, you can run: + +`make prepare-release` + +and + +`make release release_branch={{release_branch}}` + +Where `release_branch` is the branch you are targeting. +You will also need to specify some form of credentials, `GITHUB_TOKEN` environment variable for example. diff --git a/VERSION b/VERSION new file mode 100644 index 000000000..19270385e --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.16.5 diff --git a/_assets/ci/Jenkinsfile-manual b/_assets/ci/Jenkinsfile-manual index 9a5225e6b..e43838fc9 100644 --- a/_assets/ci/Jenkinsfile-manual +++ b/_assets/ci/Jenkinsfile-manual @@ -71,32 +71,18 @@ node('linux') { stage('Deploy') { dir(cloneDir) { - // For branch builds, replace the old artifact. For develop keep all of them. - def version = sh( - script: "git describe --exact-match --tag 2>/dev/null || git describe --always", - returnStdout: true - ).trim() - def server = Artifactory.server 'artifacts' - def uploadSpec = """{ - "files": [ - { - "pattern": "build/bin/statusgo-android-16.aar", - "target": "libs-release-local/status-im/status-go/${version}/status-go-${version}.aar" - }, - { - "pattern": "build/bin/statusgo-ios-9.3-framework/status-go-ios.zip", - "target": "libs-release-local/status-im/status-go-ios-simulator/${version}/status-go-ios-simulator-${version}.zip" - } - ] - }""" - - def buildInfo = Artifactory.newBuildInfo() - buildInfo.env.capture = false - buildInfo.name = 'status-go (' + gitBranch + '-' + gitShortSHA + ')' - server.upload(uploadSpec, buildInfo) - server.publishBuildInfo(buildInfo) - - slackSend color: 'good', message: 'status-go `' + version + '` was built successfully. ' + env.BUILD_URL + sh "make prepare-release" + withCredentials([[ + $class: 'UsernamePasswordMultiBinding', + credentialsId: 'status-im-auto', + usernameVariable: 'GITHUB_USER', + passwordVariable: 'GITHUB_TOKEN' + ]]) { + sh """ + yes | make release release_branch=${gitBranch} + """ + } + sh "make clean-release" } } }