diff --git a/Makefile b/Makefile index d9ca275f..4e72ace3 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,27 @@ REPO ?= fission TAG ?= dev DOCKER_FLAGS ?= --push --progress plain -check: test-run build clean +VERSION ?= master +TIMESTAMP ?= $(shell date -u +'%Y-%m-%dT%H:%M:%SZ') +COMMITSHA ?= $(shell git rev-parse HEAD) + +GOOS ?= $(shell go env GOOS) +GOARCH ?= $(shell go env GOARCH) + +FISSION-CLI := fission +ifeq ($(GOOS), windows) + FISSION-CLI := $(FISSION-CLI).exe +endif + +GO ?= go +GO_LDFLAGS := -X github.com/fission/fission/pkg/info.GitCommit=$(COMMITSHA) $(GO_LDFLAGS) +GO_LDFLAGS := -X github.com/fission/fission/pkg/info.BuildDate=$(TIMESTAMP) $(GO_LDFLAGS) +GO_LDFLAGS := -X github.com/fission/fission/pkg/info.Version=$(VERSION) $(GO_LDFLAGS) +GCFLAGS ?= all=-trimpath=$(CURDIR) +ASMFLAGS ?= all=-trimpath=$(CURDIR) + +### Static checks +check: test-run build-fission-cli clean code-checks: hack/verify-gofmt.sh @@ -34,48 +54,59 @@ test-run: code-checks hack/runtests.sh @rm -f coverage.txt -# ensure the changes are buildable -build: build-cli - go build -o cmd/fetcher/fetcher ./cmd/fetcher/ - go build -o cmd/fetcher/builder ./cmd/builder/ - go build -o cmd/reporter/reporter ./cmd/reporter/ +### Binaries +fission-cli: + @mkdir -p build/$(GOOS)/$(GOARCH)/$(VERSION) + GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO) build \ + -gcflags '$(GCFLAGS)' \ + -asmflags '$(ASMFLAGS)' \ + -ldflags "$(GO_LDFLAGS)" \ + -o build/$(GOOS)/$(GOARCH)/$(VERSION)/$(FISSION-CLI) ./cmd/fission-cli -build-cli: - go build -o cmd/fission-cli/fission ./cmd/fission-cli/ +all-fission-cli: + $(MAKE) fission-cli GOOS=windows GOARCH=amd64 + $(MAKE) fission-cli GOOS=linux GOARCH=amd64 + $(MAKE) fission-cli GOOS=linux GOARCH=arm + $(MAKE) fission-cli GOOS=linux GOARCH=arm64 + $(MAKE) fission-cli GOOS=darwin GOARCH=amd64 -install-cli: build-cli - mv cmd/fission-cli/fission /usr/local/bin +install-fission-cli: fission-cli + mv build/$(GOOS)/$(GOARCH)/$(VERSION)/$(FISSION-CLI) /usr/local/bin/ + +### Container images +FISSION_IMGS := fission-bundle-multiarch-img \ + fetcher-multiarch-img \ + builder-multiarch-img\ + pre-upgrade-checks-multiarch-img \ + reporter-multiarch-img verify-builder: @./hack/buildx.sh $(PLATFORMS) -# build images (environment images are not included) -image: - docker build -t fission-bundle -f cmd/fission-bundle/Dockerfile.fission-bundle . - docker build -t fetcher -f cmd/fetcher/Dockerfile.fission-fetcher . - docker build -t builder -f cmd/builder/Dockerfile.fission-builder . - docker build -t reporter -f cmd/builder/Dockerfile.reporter . +local-images: + PLATFORMS=linux/amd64 $(MAKE) all-images -# build multi-architecture images for release. -image-multiarch: verify-builder multiarch-bundle multiarch-fetcher multiarch-builder multiarch-preupgrade multiarch-reporter +all-images: verify-builder $(FISSION_IMGS) -multiarch-bundle: verify-builder - docker buildx build --platform=$(PLATFORMS) -t $(REPO)/fission-bundle:$(TAG) $(DOCKER_FLAGS) -f cmd/fission-bundle/Dockerfile.fission-bundle . +fission-bundle-multiarch-img: cmd/fission-bundle/Dockerfile.fission-bundle +fetcher-multiarch-img: cmd/fetcher/Dockerfile.fission-fetcher +builder-multiarch-img: cmd/builder/Dockerfile.fission-builder +pre-upgrade-checks-multiarch-img: cmd/preupgradechecks/Dockerfile.fission-preupgradechecks +reporter-multiarch-img: cmd/reporter/Dockerfile.reporter -multiarch-fetcher: verify-builder - docker buildx build --platform=$(PLATFORMS) -t $(REPO)/fetcher:$(TAG) $(DOCKER_FLAGS) -f cmd/fetcher/Dockerfile.fission-fetcher . - -multiarch-builder: verify-builder - docker buildx build --platform=$(PLATFORMS) -t $(REPO)/builder:$(TAG) $(DOCKER_FLAGS) -f cmd/builder/Dockerfile.fission-builder . - -multiarch-preupgrade: verify-builder - docker buildx build --platform=$(PLATFORMS) -t $(REPO)/pre-upgrade-checks:$(TAG) $(DOCKER_FLAGS) -f cmd/preupgradechecks/Dockerfile.fission-preupgradechecks . - -multiarch-reporter: verify-builder - docker buildx build --platform=$(PLATFORMS) -t $(REPO)/reporter:$(TAG) $(DOCKER_FLAGS) -f cmd/reporter/Dockerfile.reporter . +%-multiarch-img: + @echo === Building image $(REPO)/$(subst -multiarch-img,,$@):$(TAG) using context $(CURDIR) and dockerfile $< + docker buildx build --platform=$(PLATFORMS) -t $(REPO)/$(subst -multiarch-img,,$@):$(TAG) \ + --build-arg GITCOMMIT=$(COMMITSHA) \ + --build-arg BUILDDATE=$(TIMESTAMP) \ + --build-arg BUILDVERSION=$(VERSION) \ + $(DOCKER_FLAGS) -f $< . +### CRDs generate-crds: - controller-gen crd:trivialVersions=false,preserveUnknownFields=false paths=./pkg/apis/core/v1 output:crd:artifacts:config=crds/v1 + controller-gen crd:trivialVersions=false,preserveUnknownFields=false \ + paths=./pkg/apis/core/v1 \ + output:crd:artifacts:config=crds/v1 create-crds: @kubectl create -k crds/v1 @@ -84,11 +115,17 @@ update-crds: @kubectl replace -k crds/v1 delete-crds: - @./hack/delete-crds.sh + @kubectl delete -k crds/v1 +### Cleanup clean: @rm -f cmd/fission-bundle/fission-bundle @rm -f cmd/fission-cli/fission @rm -f cmd/fetcher/fetcher @rm -f cmd/fetcher/builder @rm -f cmd/reporter/reporter + @rm -f pkg/apis/core/v1/types_swagger_doc_generated.go + +### Misc +generate-swagger-doc: + @cd pkg/apis/core/v1/tool && ./update-generated-swagger-docs.sh diff --git a/charts/README.md b/charts/README.md index ac30565a..41db4199 100644 --- a/charts/README.md +++ b/charts/README.md @@ -43,10 +43,10 @@ Parameter | Description | Default `routerServiceType` | Type of Fission Router service to use. For minikube, set this to NodePort, elsewhere use LoadBalancer or ClusterIP. | `LoadBalancer` `repository` | Image base repository | `index.docker.io` `image` | Fission image repository | `fission/fission-bundle` -`imageTag` | Fission image tag | `1.12.0` +`imageTag` | Fission image tag | `1.13.0` `pullPolicy` | Image pull policy | `IfNotPresent` `fetcher.image` | Fission fetcher repository | `fission/fetcher` -`fetcher.imageTag` | Fission fetcher image tag | `1.12.0` +`fetcher.imageTag` | Fission fetcher image tag | `1.13.0` `controllerPort` | Fission Controller service port | `31313` `routerPort` | Fission Router service port | ` 31314` `functionNamespace` | Namespace in which to run fission functions (this is different from the release namespace) | `fission-function` diff --git a/charts/fission-all/Chart.yaml b/charts/fission-all/Chart.yaml index 60d0cf5d..4ccf0e58 100644 --- a/charts/fission-all/Chart.yaml +++ b/charts/fission-all/Chart.yaml @@ -1,18 +1,18 @@ apiVersion: v2 name: fission-all -version: 1.12.0 +version: 1.13.0 description: Fission is a fast serverless framework for Kubernetes. keywords: - fission - serverless -home: http://fission.io/ +home: https://fission.io/ maintainers: - - name: Soam Vasani - email: soamvasani+1@gmail.com - - name: Ta Ching Chen - email: hello@tachingchen.com + - name: Vishal Biyani + email: vishal@infracloud.io + - name: Sanket Sudake + email: sanket@infracloud.io engine: gotpl -appVersion: 1.12.0 +appVersion: 1.13.0 type: application dependencies: - name: prometheus diff --git a/charts/fission-all/values.yaml b/charts/fission-all/values.yaml index a40cd689..dea3b0c2 100644 --- a/charts/fission-all/values.yaml +++ b/charts/fission-all/values.yaml @@ -20,7 +20,7 @@ image: fission/fission-bundle pullPolicy: IfNotPresent ## Fission image version -imageTag: 1.12.0 +imageTag: 1.13.0 ## Port at which Fission controller service should be exposed controllerPort: 31313 @@ -50,7 +50,7 @@ fetcher: ## Fetcher repository image: fission/fetcher ## Fetcher image version - imageTag: 1.12.0 + imageTag: 1.13.0 ## Fetcher is only for to downloading or uploading archive. ## Normally, you don't need to change the value here, unless necessary. diff --git a/charts/fission-core/Chart.yaml b/charts/fission-core/Chart.yaml index efd500fa..52e5d123 100644 --- a/charts/fission-core/Chart.yaml +++ b/charts/fission-core/Chart.yaml @@ -1,18 +1,18 @@ apiVersion: v2 name: fission-core -version: 1.12.0 +version: 1.13.0 description: Fission is a fast serverless framework for Kubernetes. keywords: - fission - serverless -home: http://fission.io/ +home: https://fission.io/ maintainers: - - name: Soam Vasani - email: soamvasani+1@gmail.com - - name: Ta Ching Chen - email: hello@tachingchen.com + - name: Vishal Biyani + email: vishal@infracloud.io + - name: Sanket Sudake + email: sanket@infracloud.io engine: gotpl -appVersion: 1.12.0 +appVersion: 1.13.0 type: application dependencies: - name: prometheus diff --git a/charts/fission-core/values.yaml b/charts/fission-core/values.yaml index ccf796ad..664fb541 100644 --- a/charts/fission-core/values.yaml +++ b/charts/fission-core/values.yaml @@ -17,7 +17,7 @@ repository: index.docker.io image: fission/fission-bundle ## Fission image version -imageTag: 1.12.0 +imageTag: 1.13.0 ## Image pull policy pullPolicy: IfNotPresent @@ -43,7 +43,7 @@ fetcher: ## Fetcher repository image: fission/fetcher ## Fetcher image version - imageTag: 1.12.0 + imageTag: 1.13.0 ## Fetcher is only for to downloading or uploading archive. ## Normally, you don't need to change the value here, unless necessary. diff --git a/hack/Releasing.txt b/hack/Releasing.md similarity index 56% rename from hack/Releasing.txt rename to hack/Releasing.md index dfba6685..4806c97e 100644 --- a/hack/Releasing.txt +++ b/hack/Releasing.md @@ -1,21 +1,17 @@ -#### Fission release +# Fission release -Prerequisites -------------- +## Prerequisites -1. Get a dockerhub account if you don't have one. +1. Get access to: - Get access to: - - The fission dockerhub account (https://hub.docker.com/r/fission/ if you have access, you will see Fission listed in your organizations: https://hub.docker.com/organizations/ ) - - Fission-charts repo (https://github.com/fission/fission-charts) - - Fission Documentation Repo (https://github.com/fission/docs.fission.io) - - Fission main repo (https://github.com/fission/fission) + a. [The fission dockerhub account](https://hub.docker.com/r/fission/), if you have access, you will see Fission listed in [your organizations](https://hub.docker.com/organizations/) + b. [Fission-charts repo](https://github.com/fission/fission-charts) + c. [Fission Documentation Repo](https://github.com/fission/docs.fission.io) + d. [Fission main repo](https://github.com/fission/fission) -2. Get a Github "personal access token": - https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ +2. Get a Github [personal access token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/) - Save the token to ~/.gh-access-token (make sure that the file is - readable only by you) + Save the token to ~/.github-token (make sure that the file is readable only by you) 3. Go toolchain set up. @@ -23,28 +19,24 @@ Prerequisites `docker login` with your own username; get this username added to the fission team on dockerhub. - -4. Install changelog generator tool "github_changelog_generator": https://github.com/skywinder/github-changelog-generator + +4. Install changelog generator tool [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator) 5. Install realpath if you don't already have it : https://github.com/harto/realpath-osx (You can use the brew method on Mac) -6. Install gothub if you don't already have it : https://github.com/itchio/gothub - You just have to go get github.com/itchio/gothub, that'll install gothub in $GOPATH/bin. Ensure this is already - in $PATH env variable. +6. Install [Github CLI](https://cli.github.com/) - -Check that the build is green! ------------------------------- +## Check that the build is green Fix the build if it is not green. DON'T proceed unless build is GREEN! - -Updating Fission Repo (https://github.com/fission/fission) ------------------------------- +## Updating [Fission Repo](https://github.com/fission/fission) 1. cd to the top of the fission repo, create a branch: + ```shell git checkout -b release-X.Y.Z + ``` 2. Change references of old version to new version in charts directory. You use replace and find all with a quick preview in your IDE. @@ -69,31 +61,30 @@ Updating Fission Repo (https://github.com/fission/fission) 8. Test build from master branch for sanity check and make sure the master build is green -Updating Fission Charts (https://github.com/fission/fission-charts) ------------------------------- +## Updating [Fission Charts](https://github.com/fission/fission-charts) + a. Switch to fission/fission-charts repo and run `index.sh` in that repo. (Don't edit the index.yaml in this repo manually. index.sh generates it, using the helm repo CLI.) b. You should have index.yaml and fission-core-*, fission-all-* charts as change, add, commit and push it to repo. -9. Go to Github Web UI --> Releases, here you will notice a pre-release for the version x.y.z you just created. +1. Go to Github Web UI --> Releases, here you will notice a pre-release for the version x.y.z you just created. Edit it and add links to: - * Install guide in docs - * Changelog.md +a. Install guide in docs +b. Changelog.md Before you save the release - UNCHECK the "This is a pre-release" checkbox. This mark the release as ready for consumption (If release is stable). -Updating Fission Docs (https://github.com/fission/docs.fission.io) ------------------------------- +## Updating [Fission Docs](https://github.com/fission/docs.fission.io) -10. Documentation Update +1. Documentation Update a. Merge documentation PRs that are peer reviewed and get latest master locally. b. In the repo fission/docs.fission.io change version in version.sh file to latest version (x.y.z) and run build.sh script -c. ** ONLY ** in the dist/x.y.z directory i.e. current version directory - replace all references from previous release to current release. Please use your IDE as there will be thousands of references. +c. **ONLY** in the dist/x.y.z directory i.e. current version directory - replace all references from previous release to current release. Please use your IDE as there will be thousands of references. d.VERIFY: There should be changes only in dist/x.y.z - where x.y.z is current version and in following files: @@ -101,14 +92,6 @@ d.VERIFY: There should be changes only in dist/x.y.z - where x.y.z is current ve - dist/index.html - version.sh +## Announce the release -Announce the release --------------------- - -Announce the release on #contributors. - - -Update Fission.io ------------------ - -Tell #marketing channel to update link +Announce the release on Fission Slack and Twitter. diff --git a/hack/release-build.sh b/hack/release-build.sh deleted file mode 100755 index b75da45e..00000000 --- a/hack/release-build.sh +++ /dev/null @@ -1,219 +0,0 @@ -#!/bin/bash - -set -e -#set -x - -DIR=`realpath $(dirname $0)/../` -BUILDDIR=$(realpath $DIR)/build - -# Build CLI binaries for mac/linux/windows -build_all_cli() { - local version=$1 - local date=$2 - local gitcommit=$3 - - build_cli "linux" "linux" $version $date $gitcommit - build_cli "darwin" "osx" $version $date $gitcommit - build_cli "windows" "windows" $version $date $gitcommit -} - -# Build cli binary for one OS, and put it in $BUILDDIR/cli// -build_cli() { - os=$1 - osName=$2 - local version=$3 - local date=$4 - local gitcommit=$5 - arch="amd64" # parameterize if/when we need to - - pushd $DIR/cmd/fission-cli - - if [ "$osName" == "windows" ] - then - binary=fission-cli-${osName}.exe - else - binary=fission-cli-${osName} - fi - - GOOS=$os GOARCH=$arch go build -gcflags=-trimpath=$GOPATH -asmflags=-trimpath=$GOPATH \ - -ldflags "-X github.com/fission/fission/pkg/info.GitCommit=$gitcommit -X github.com/fission/fission/pkg/info.BuildDate=$date -X github.com/fission/fission/pkg/info.Version=$version" -o $binary . - - outdir=$BUILDDIR/cli/$osName/ - mkdir -p $outdir - mv $binary $outdir - - popd -} - -# Build fission-bundle image -build_fission_bundle_image() { - local version=$1 - local date=$2 - local gitcommit=$3 - - local tag=fission/fission-bundle:$version - - docker build -t $tag -f $DIR/cmd/fission-bundle/Dockerfile.fission-bundle --build-arg GITCOMMIT=$gitcommit \ - --build-arg BUILDDATE=$date --build-arg BUILDVERSION=$version $DIR - docker tag $tag fission/fission-bundle:latest -} - -build_fetcher_image() { - local version=$1 - local date=$2 - local gitcommit=$3 - local tag=fission/fetcher:$version - - docker build -t $tag -f $DIR/cmd/fetcher/Dockerfile.fission-fetcher --build-arg GITCOMMIT=$gitcommit \ - --build-arg BUILDDATE=$date --build-arg BUILDVERSION=$version $DIR - docker tag $tag fission/fetcher:latest -} - -push_fetcher_image() { - local version=$1 - local tag=fission/fetcher:$version -} - -build_builder_image() { - local version=$1 - local date=$2 - local gitcommit=$3 - local tag=fission/builder:$version - - docker build -t $tag -f $DIR/cmd/builder/Dockerfile.fission-builder --build-arg GITCOMMIT=$gitcommit \ - --build-arg BUILDDATE=$date --build-arg BUILDVERSION=$version $DIR - docker tag $tag fission/builder:latest -} - -# Build reporter image -build_reporter_image() { - local version=$1 - local date=$2 - local gitcommit=$3 - - local tag=fission/reporter:$version - - docker build -t $tag -f $DIR/cmd/reporter/Dockerfile.reporter \ - --build-arg GITCOMMIT=$gitcommit --build-arg BUILDDATE=$date --build-arg BUILDVERSION=$version $DIR - docker tag $tag fission/reporter:latest -} - -# Build pre-upgrade-checks image -build_pre_upgrade_checks_image() { - local version=$1 - local date=$2 - local gitcommit=$3 - - local tag=fission/pre-upgrade-checks:$version - - docker build -t $tag -f $DIR/cmd/preupgradechecks/Dockerfile.fission-preupgradechecks \ - --build-arg GITCOMMIT=$gitcommit --build-arg BUILDDATE=$date --build-arg BUILDVERSION=$version $DIR - docker tag $tag fission/pre-upgrade-checks:latest -} - -build_charts() { - local version=$1 - mkdir -p $BUILDDIR/charts - pushd $DIR/charts - find . -iname *.~?~ | xargs -r rm - for c in fission-all fission-core - do - helm package -u $c/ - mv *.tgz $BUILDDIR/charts/ - done - popd -} - -build_yamls() { - local version=$1 - - mkdir -p ${BUILDDIR}/yamls - pushd ${DIR}/charts - find . -iname *.~?~ | xargs -r rm - - releaseName=fission-$(echo ${version} | sed 's/\./-/g') - - for c in fission-all fission-core - do - # fetch dependencies - pushd ${c} - helm dependency update - popd - - # for minikube and other environments that don't support LoadBalancer - helm template ${c} -n ${releaseName} --namespace fission --set analytics=false,analyticsNonHelmInstall=true,serviceType=NodePort,routerServiceType=NodePort > ${c}-${version}-minikube.yaml - # for environments that support LoadBalancer - helm template ${c} -n ${releaseName} --namespace fission --set analytics=false,analyticsNonHelmInstall=true > ${c}-${version}.yaml - # for OpenShift - helm template ${c} -n ${releaseName} --namespace fission --set analytics=false,analyticsNonHelmInstall=true,logger.enableSecurityContext=true,prometheus.enabled=false > ${c}-${version}-openshift.yaml - - # copy yaml files to build directory - mv *.yaml ${BUILDDIR}/yamls/ - done - - popd -} - -build_all() { - local version=$1 - - if [ -z "$version" ] - then - echo "Version unspecified" - exit 1 - fi - - local date=$2 - - if [ -z "$date" ] - then - echo "Build date unspecified" - exit 1 - fi - - local gitcommit=$3 - - if [ -z "gitcommit" ] - then - echo "Git commit unspecified" - exit 1 - fi - - if [ -e $BUILDDIR ] - then - echo "Removing existing build dir ($BUILDDIR)." - rm -rf $BUILDDIR - fi - - mkdir -p $BUILDDIR - - # generate swagger (OpenApi 2.0) doc before building bundle image - generate_swagger_doc - - build_fission_bundle_image $version $date $gitcommit - build_fetcher_image $version $date $gitcommit - build_builder_image $version $date $gitcommit - build_all_cli $version $date $gitcommit - build_pre_upgrade_checks_image $version $date $gitcommit - build_reporter_image $version $date $gitcommit - - remove_generated_swagger_doc -} - -generate_swagger_doc() { - pushd $DIR/pkg/apis/core/v1/tool - ./update-generated-swagger-docs.sh - popd -} - -remove_generated_swagger_doc() { - rm $DIR/pkg/apis/core/v1/types_swagger_doc_generated.go -} - -version=${VERSION} -date=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -gitcommit=$(git rev-parse HEAD) - -build_all $version $date $gitcommit -build_charts $version -build_yamls $version diff --git a/hack/release.sh b/hack/release.sh index ce04cc7c..e016c1e3 100755 --- a/hack/release.sh +++ b/hack/release.sh @@ -6,214 +6,57 @@ set -e DIR=$(realpath $(dirname $0))/../ BUILDDIR=$(realpath $DIR)/build +artifacts=() source $(realpath ${DIR}/test/init_tools.sh) # Ensure we're on the master branch check_branch() { local version=$1 curr_branch=$(git rev-parse --abbrev-ref HEAD) - if [ $curr_branch != "release-${version}" ] - then + if [ $curr_branch != "release-${version}" ]; then echo "Not on release-${version} branch." exit 1 fi } # Ensure working dir is clean -check_clean() { - if ! git diff-index --quiet HEAD -- - then +check_clean() { + if ! git diff-index --quiet HEAD --; then echo "Unclean tree" exit 1 fi } -# Push fission-bundle image -push_fission_bundle_image() { - local version=$1 - local tag=fission/fission-bundle:$version - docker push $tag -} - -push_fetcher_image() { - local version=$1 - local tag=fission/fetcher:$version - docker push $tag -} - - -push_builder_image() { - local version=$1 - local tag=fission/builder:$version - docker push $tag -} - -# Push pre-upgrade-checks image -push_pre_upgrade_checks_image() { - local version=$1 - local tag=fission/pre-upgrade-checks:$version - docker push $tag -} - -push_all() { - local version=$1 - push_fission_bundle_image $version - push_fission_bundle_image latest - - push_fetcher_image $version - push_fetcher_image latest - - push_builder_image $version - push_builder_image latest - - push_pre_upgrade_checks_image $version - push_pre_upgrade_checks_image latest -} - - - -# Build and push fission-bundle image -push_multiarch_fission_bundle_image() { - TAG=$1 make multiarch-bundle -} - -push_multiarch_fetcher_image() { - TAG=$1 make multiarch-fetcher -} - - -push_builder_image() { - TAG=$1 make multiarch-builder -} - -# Push pre-upgrade-checks image -push_pre_upgrade_checks_image() { - TAG=$1 make multiarch-preupgrade -} - -push_builder_image() { - TAG=$1 make multiarch-reporter -} - -push_multiarch_all() { - TAG=$version make image-multiarch - TAG=latest make image-multiarch -} - -tag_and_release() { - local version=$1 - local gittag=$version - local prefix="v" - local gopkgtag=${version/#/${prefix}} - - if [[ ${version} == v* ]]; # if version starts with "v", don't append prefix. - then - gopkgtag=${version} - fi - - # tag the release - git tag $gittag - git tag -a $gopkgtag -m "Fission $gopkgtag" - - # push tag - git push origin $gittag - git push origin $gopkgtag - - # create gh release - gothub release \ - --user fission \ - --repo fission \ - --tag $gittag \ - --name "$version" \ - --description "$version" \ - --pre-release -} - attach_github_release_cli() { - local version=$1 - local gittag=$version # cli - echo "Uploading osx cli" - gothub upload \ - --replace \ - --user fission \ - --repo fission \ - --tag $gittag \ - --name fission-cli-osx \ - --file $BUILDDIR/cli/osx/fission-cli-osx - - echo "Uploading linux cli" - gothub upload \ - --replace \ - --user fission \ - --repo fission \ - --tag $gittag \ - --name fission-cli-linux \ - --file $BUILDDIR/cli/linux/fission-cli-linux - - echo "Uploading windows cli" - gothub upload \ - --replace \ - --user fission \ - --repo fission \ - --tag $gittag \ - --name fission-cli-windows.exe \ - --file $BUILDDIR/cli/windows/fission-cli-windows.exe + echo "Artifact for osx amd64 cli" + artifacts+=("$BUILDDIR/darwin/amd64/$version/fission#fission-cli-osx") + echo "Artifact for windows amd64 cli" + artifacts+=("$BUILDDIR/windows/amd64/$version/fission.exe#fission-cli-windows.exe") + echo "Artifact for linux amd64 cli" + artifacts+=("$BUILDDIR/linux/amd64/$version/fission#fission-cli-linux") + echo "Artifact for linux arm cli" + artifacts+=("$BUILDDIR/linux/arm/$version/fission#fission-cli-linux-arm") + echo "Artifact for linux arm64 cli" + artifacts+=("$BUILDDIR/linux/arm64/$version/fission#fission-cli-linux-arm64") } attach_github_release_charts() { local version=$1 - local gittag=$version - - # helm charts - gothub upload \ - --replace \ - --user fission \ - --repo fission \ - --tag $gittag \ - --name fission-all-$version.tgz \ - --file $BUILDDIR/charts/fission-all-$version.tgz - - gothub upload \ - --replace \ - --user fission \ - --repo fission \ - --tag $gittag \ - --name fission-core-$version.tgz \ - --file $BUILDDIR/charts/fission-core-$version.tgz - + echo "fission-all chart" + artifacts+=("$BUILDDIR/charts/fission-all-$version.tgz#fission-all-$version.tgz") + echo "Fission-core chart" + artifacts+=("$BUILDDIR/charts/fission-core-$version.tgz#fission-core-$version.tgz") } attach_github_release_yamls() { local version=$1 - local gittag=$version - for c in fission-all fission-core - do + for c in fission-all fission-core; do # YAML - gothub upload \ - --replace \ - --user fission \ - --repo fission \ - --tag $gittag \ - --name ${c}-${version}-minikube.yaml \ - --file $BUILDDIR/yamls/${c}-${version}-minikube.yaml - - gothub upload \ - --replace \ - --user fission \ - --repo fission \ - --tag $gittag \ - --name ${c}-${version}.yaml \ - --file $BUILDDIR/yamls/${c}-${version}.yaml - - gothub upload \ - --replace \ - --user fission \ - --repo fission \ - --tag $gittag \ - --name ${c}-${version}-openshift.yaml \ - --file $BUILDDIR/yamls/${c}-${version}-openshift.yaml + artifacts+=("$BUILDDIR/yamls/${c}-${version}-minikube.yaml#${c}-${version}-minikube.yaml") + artifacts+=("$BUILDDIR/yamls/${c}-${version}.yaml#${c}-${version}.yaml") + artifacts+=("$BUILDDIR/yamls/${c}-${version}-openshift.yaml#${c}-${version}-openshift.yaml") done } @@ -228,102 +71,232 @@ update_github_charts_repo() { popd } +tag_and_release() { + local version=$1 + local gittag=$version + local prefix="v" + local gopkgtag=${version/#/${prefix}} + + if [[ ${version} == v* ]]; then # if version starts with "v", don't append prefix. + gopkgtag=${version} + fi + + # tag the release + git tag $gittag + git tag -a $gopkgtag -m "Fission $gopkgtag" + + # push tag + git push origin $gittag + git push origin $gopkgtag + + relnotes=" +Install Guide: https://docs.fission.io/installation/ +Full Changelog: https://github.com/fission/fission/blob/master/CHANGELOG.md +" + gh release create $gittag --prerelease --title $gittag --notes $relnotes --target $gitcommit ${artifacts[@]} +} + generate_changelog() { local version=$1 - echo "# ${version}" > new_CHANGELOG.md + echo "# ${version}" >new_CHANGELOG.md echo - echo "[Documentation](https://docs.fission.io/)" >> new_CHANGELOG.md + echo "[Documentation](https://docs.fission.io/)" >>new_CHANGELOG.md echo - create_downloads_table ${version} >> new_CHANGELOG.md + create_downloads_table ${version} >>new_CHANGELOG.md # generate changelog from github github_changelog_generator -u fission -p fission -t ${GITHUB_TOKEN} --future-release ${version} --no-issues -o tmp_CHANGELOG.md sed -i '$ d' tmp_CHANGELOG.md # concatenate two files - cat tmp_CHANGELOG.md >> new_CHANGELOG.md + cat tmp_CHANGELOG.md >>new_CHANGELOG.md mv new_CHANGELOG.md ${DIR}/CHANGELOG.md rm tmp_CHANGELOG.md } -create_downloads_table () { - local release_tag=$1 - local url_prefix="https://github.com/fission/fission/releases/download" +create_downloads_table() { + local release_tag=$1 + local url_prefix="https://github.com/fission/fission/releases/download" - echo "## Downloads for ${version}" - echo + echo "## Downloads for ${version}" + echo - local files=$(find build -name '*' -type f) + local files=$(find build -name '*' -type f) - echo - echo "filename | sha256 hash" - echo "-------- | -----------" - for file in $files; do - echo "[${file##*/}]($url_prefix/$release_tag/${file##*/}) | \`$(shasum -a 256 $file | cut -d' ' -f 1)\`" - done - echo + echo + echo "filename | sha256 hash" + echo "-------- | -----------" + for file in ${artifacts[@]}; do + filepath=$(echo $file | cut -d'#' -f 1) + filename=$(echo $file | cut -d'#' -f 2) + echo "[${filename}]($url_prefix/$release_tag/${filename}) | \`$(shasum -a 256 ${filepath} | cut -d' ' -f 1)\`" + done + echo } export -f create_downloads_table release_environment_check() { - local version=$1 - local chartsrepo=$2 + local version=$1 + local chartsrepo=$2 - check_branch $version - check_clean + check_branch $version + check_clean - if [ ! -f $HOME/.gh-access-token ] - then - echo "Error finding github access token at ${HOME}/.gh-access-token." - exit 1 - fi + if [ ! -f $HOME/.github-token ]; then + echo "Error finding github access token at ${HOME}/.github-token" + exit 1 + fi - if [ ! -d $chartsrepo ] - then - echo "Error finding chart repo at $GOPATH/src/github.com/fission/fission-charts" - exit 1 - fi + if [ ! -d $chartsrepo ]; then + echo "Error finding chart repo at $chartsrepo" + exit 1 + fi - if [ ! -d $FISSION_HOME ] - then - echo "The FISSION_HOME variable should be set to directory where Fission and fission-charts are checked out" - exit 1 - fi + if [ ! -d $FISSION_HOME ]; then + echo "The FISSION_HOME variable should be set to directory where Fission and fission-charts are checked out" + exit 1 + fi } -export GITHUB_TOKEN=$(cat ~/.gh-access-token) +build_charts() { + local version=$1 + mkdir -p $BUILDDIR/charts + pushd $DIR/charts + find . -iname *.~?~ | xargs -r rm + for c in fission-all fission-core; do + helm package -u $c/ + mv *.tgz $BUILDDIR/charts/ + done + popd +} + +build_yamls() { + local version=$1 + + mkdir -p ${BUILDDIR}/yamls + pushd ${DIR}/charts + find . -iname *.~?~ | xargs -r rm + + releaseName=fission-$(echo ${version} | sed 's/\./-/g') + + for c in fission-all fission-core; do + # fetch dependencies + pushd ${c} + helm dependency update + popd + + # for minikube and other environments that don't support LoadBalancer + helm template ${c} -n ${releaseName} --namespace fission --set analytics=false,analyticsNonHelmInstall=true,serviceType=NodePort,routerServiceType=NodePort >${c}-${version}-minikube.yaml + # for environments that support LoadBalancer + helm template ${c} -n ${releaseName} --namespace fission --set analytics=false,analyticsNonHelmInstall=true >${c}-${version}.yaml + # for OpenShift + helm template ${c} -n ${releaseName} --namespace fission --set analytics=false,analyticsNonHelmInstall=true,logger.enableSecurityContext=true,prometheus.enabled=false >${c}-${version}-openshift.yaml + + # copy yaml files to build directory + mv *.yaml ${BUILDDIR}/yamls/ + done + + popd +} + +build_all() { + local version=$1 + + if [ -z "$version" ]; then + echo "Version unspecified" + exit 1 + fi + + local date=$2 + + if [ -z "$date" ]; then + echo "Build date unspecified" + exit 1 + fi + + local gitcommit=$3 + + if [ -z "gitcommit" ]; then + echo "Git commit unspecified" + exit 1 + fi + + if [ -e $BUILDDIR ]; then + echo "Removing existing build dir ($BUILDDIR)." + rm -rf $BUILDDIR + fi + + mkdir -p $BUILDDIR + + # generate swagger (OpenApi 2.0) doc before building bundle image + VERSION=$version TIMESTAMP=$date COMMITSHA=$gitcommit make generate-swagger-doc + + # Build CLI for all platforms + VERSION=$version TIMESTAMP=$date COMMITSHA=$gitcommit make all-fission-cli +} + +build_images() { + local version=$1 + if [ -z "$version" ]; then + echo "Version unspecified" + exit 1 + fi + + local date=$2 + if [ -z "$date" ]; then + echo "Build date unspecified" + exit 1 + fi + + local gitcommit=$3 + if [ -z "gitcommit" ]; then + echo "Git commit unspecified" + exit 1 + fi + + # Build and push all images + VERSION=$version TAG=$version TIMESTAMP=$date COMMITSHA=$gitcommit make all-images + VERSION=$version TAG=latest TIMESTAMP=$date COMMITSHA=$gitcommit make all-images +} + +check_commands() { + if ! command -v hub >/dev/null; then + echo "Github CLI hub not found. Please get from https://cli.github.com/" + fi +} + +export GITHUB_TOKEN=$(cat ~/.github-token) version=$1 -chartsrepo=$2 - -if [ -z $chartsrepo ] -then - chartsrepo="$DIR../fission-charts" +if [ -z $version ]; then + echo "Release version not mentioned" + exit 1 fi +date=$(date -u +'%Y-%m-%dT%H:%M:%SZ') +gitcommit=$(git rev-parse HEAD) + +chartsrepo=$2 +if [ -z $chartsrepo ]; then + chartsrepo="$DIR../fission-charts" +fi + +check_commands release_environment_check $version $chartsrepo +build_all $version $date $gitcommit +# build_images $version $date $gitcommit +build_charts $version +build_yamls $version -# Build release-builder image -#docker build -t fission-release-builder -f $FISSION_HOME/fission/hack/Dockerfile . - -# Build all binaries & container images in docker -# Here we mount docker.sock into container so that docker client can communicate with host docker daemon. -# For more detail please visit https://docs.docker.com/machine/overview/ -docker run --rm -it -v $FISSION_HOME:/go/src/github.com/fission -v /var/run/docker.sock:/var/run/docker.sock \ - -e VERSION=$version -w "/go/src/github.com/fission/fission/hack" fission-release-builder sh -c "./release-build.sh" - -push_multiarch_all $version - -tag_and_release $version attach_github_release_cli $version attach_github_release_charts $version attach_github_release_yamls $version update_github_charts_repo $version $chartsrepo - generate_changelog $version +tag_and_release $version echo "############ DONE #############" echo "Congratulation, ${version} is ready to ship !!"