fix: Goreleaser for build and release (#2189)

* Add goreleaser for building binaries
* Update CONTRIBUTING.md
* Break release scripts for goreleaser

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
Sanket Sudake
2021-09-21 15:29:40 +05:30
committed by GitHub
parent b55dc1fd78
commit 1347d73b04
17 changed files with 474 additions and 803 deletions
+8 -2
View File
@@ -83,14 +83,20 @@ jobs:
sudo install skaffold /usr/local/bin/
skaffold version
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
install-only: true
- name: Build and Install Fission
run: |
kubectl create ns fission
kubectl create -k crds/v1
skaffold run -p kind-ci
make create-crds
SKAFFOLD_PROFILE=kind-ci make skaffold-deploy
- name: Build and Install Fission CLI
run: |
make build-fission-cli
sudo make install-fission-cli
sudo chmod +x /usr/local/bin/fission
+5
View File
@@ -56,6 +56,11 @@ jobs:
image: ${{ matrix.kindimage }}
version: v0.11.1
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
install-only: true
- name: Setup kubectl & fetch node information
run: |
kubectl cluster-info --context kind-kind
+2
View File
@@ -31,3 +31,5 @@ vendor/
local/
build/
dist/
manifest/
+245
View File
@@ -0,0 +1,245 @@
project_name: fission
release:
github:
owner: fission
name: fission
prerelease: true
draft: true
header: |
Release Highlights: https://docs.fission.io/docs/releases/{{ .Tag }}/
Install Guide: https://docs.fission.io/installation/
Full Changelog: https://github.com/fission/fission/blob/master/CHANGELOG.md
extra_files:
- glob: ./manifest/charts/*
- glob: ./manifest/yamls/*
before:
hooks:
- go mod tidy
snapshot:
name_template: "{{ .Tag }}"
builds:
- &build-linux
id: builder
ldflags:
- -s -w
- -X github.com/fission/fission/pkg/info.GitCommit={{.ShortCommit}}
- -X github.com/fission/fission/pkg/info.BuildDate={{.Date}}
- -X github.com/fission/fission/pkg/info.Version={{.Tag}}
gcflags:
- all=-trimpath={{.Env.PWD}}
asmflags:
- all=-trimpath={{.Env.PWD}}
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
- arm64
- arm
goarm:
- 7
binary: builder
dir: ./cmd/builder
- <<: *build-linux
id: fetcher
binary: fetcher
dir: ./cmd/fetcher
- <<: *build-linux
id: fission-bundle
binary: fission-bundle
dir: ./cmd/fission-bundle
- <<: *build-linux
id: fission-cli
goos:
- linux
- windows
- darwin
binary: fission
dir: ./cmd/fission-cli
ignore:
- goos: windows
goarch: arm64
- goos: darwin
goarch: arm
goarm: 7
- goos: windows
goarch: arm
goarm: 7
- <<: *build-linux
id: pre-upgrade-checks
binary: pre-upgrade-checks
dir: ./cmd/preupgradechecks
- <<: *build-linux
id: reporter
binary: reporter
dir: ./cmd/reporter
dockers:
- &docker-amd64
use: buildx
goos: linux
goarch: amd64
ids:
- builder
image_templates:
- "fission/builder:latest-amd64"
- "fission/builder:{{ .Tag }}-amd64"
dockerfile: cmd/builder/Dockerfile.fission-builder
build_flag_templates:
- "--platform=linux/amd64"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Tag}}"
- <<: *docker-amd64
ids:
- fetcher
image_templates:
- "fission/fetcher:latest-amd64"
- "fission/fetcher:{{ .Tag }}-amd64"
dockerfile: cmd/fetcher/Dockerfile.fission-fetcher
- <<: *docker-amd64
ids:
- fission-bundle
image_templates:
- "fission/fission-bundle:latest-amd64"
- "fission/fission-bundle:{{ .Tag }}-amd64"
dockerfile: cmd/fission-bundle/Dockerfile.fission-bundle
- <<: *docker-amd64
ids:
- pre-upgrade-checks
image_templates:
- "fission/pre-upgrade-checks:latest-amd64"
- "fission/pre-upgrade-checks:{{ .Tag }}-amd64"
dockerfile: cmd/preupgradechecks/Dockerfile.fission-preupgradechecks
- <<: *docker-amd64
ids:
- reporter
image_templates:
- "fission/reporter:latest-amd64"
- "fission/reporter:{{ .Tag }}-amd64"
dockerfile: cmd/reporter/Dockerfile.reporter
- &docker-arm64
use: buildx
goos: linux
goarch: arm64
ids:
- builder
image_templates:
- "fission/builder:latest-arm64"
- "fission/builder:{{ .Tag }}-arm64"
dockerfile: cmd/builder/Dockerfile.fission-builder
build_flag_templates:
- "--platform=linux/arm64"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Tag}}"
- <<: *docker-arm64
ids:
- fetcher
image_templates:
- "fission/fetcher:latest-arm64"
- "fission/fetcher:{{ .Tag }}-arm64"
dockerfile: cmd/fetcher/Dockerfile.fission-fetcher
- <<: *docker-arm64
ids:
- fission-bundle
image_templates:
- "fission/fission-bundle:latest-arm64"
- "fission/fission-bundle:{{ .Tag }}-arm64"
dockerfile: cmd/fission-bundle/Dockerfile.fission-bundle
- <<: *docker-arm64
ids:
- pre-upgrade-checks
image_templates:
- "fission/pre-upgrade-checks:latest-arm64"
- "fission/pre-upgrade-checks:{{ .Tag }}-arm64"
dockerfile: cmd/preupgradechecks/Dockerfile.fission-preupgradechecks
- <<: *docker-arm64
ids:
- reporter
image_templates:
- "fission/reporter:latest-arm64"
- "fission/reporter:{{ .Tag }}-arm64"
dockerfile: cmd/reporter/Dockerfile.reporter
- &docker-armv7
use: buildx
goos: linux
goarch: arm
goarm: 7
ids:
- builder
image_templates:
- "fission/builder:latest-armv7"
- "fission/builder:{{ .Tag }}-armv7"
dockerfile: cmd/builder/Dockerfile.fission-builder
build_flag_templates:
- "--platform=linux/arm/v7"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Tag}}"
- <<: *docker-armv7
ids:
- fetcher
image_templates:
- "fission/fetcher:latest-armv7"
- "fission/fetcher:{{ .Tag }}-armv7"
dockerfile: cmd/fetcher/Dockerfile.fission-fetcher
- <<: *docker-armv7
ids:
- fission-bundle
image_templates:
- "fission/fission-bundle:latest-armv7"
- "fission/fission-bundle:{{ .Tag }}-armv7"
dockerfile: cmd/fission-bundle/Dockerfile.fission-bundle
- <<: *docker-armv7
ids:
- pre-upgrade-checks
image_templates:
- "fission/pre-upgrade-checks:latest-armv7"
- "fission/pre-upgrade-checks:{{ .Tag }}-armv7"
dockerfile: cmd/preupgradechecks/Dockerfile.fission-preupgradechecks
- <<: *docker-armv7
ids:
- reporter
image_templates:
- "fission/reporter:latest-armv7"
- "fission/reporter:{{ .Tag }}-armv7"
dockerfile: cmd/reporter/Dockerfile.reporter
docker_manifests:
- name_template: fission/builder:{{ .Tag }}
image_templates:
- fission/builder:{{ .Tag }}-amd64
- fission/builder:{{ .Tag }}-arm64
- fission/builder:{{ .Tag }}-armv7
- name_template: fission/fetcher:{{ .Tag }}
image_templates:
- fission/fetcher:{{ .Tag }}-amd64
- fission/fetcher:{{ .Tag }}-arm64
- fission/fetcher:{{ .Tag }}-armv7
- name_template: fission/fission-bundle:{{ .Tag }}
image_templates:
- fission/fission-bundle:{{ .Tag }}-amd64
- fission/fission-bundle:{{ .Tag }}-arm64
- fission/fission-bundle:{{ .Tag }}-armv7
- name_template: fission/pre-upgrade-checks:{{ .Tag }}
image_templates:
- fission/pre-upgrade-checks:{{ .Tag }}-amd64
- fission/pre-upgrade-checks:{{ .Tag }}-arm64
- fission/pre-upgrade-checks:{{ .Tag }}-armv7
- name_template: fission/reporter:{{ .Tag }}
image_templates:
- fission/reporter:{{ .Tag }}-amd64
- fission/reporter:{{ .Tag }}-arm64
- fission/reporter:{{ .Tag }}-armv7
changelog:
skip: true
archives:
- id: fission
builds:
- fission-cli
name_template: "{{ .ProjectName }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}"
format: binary
checksum:
name_template: "checksums.txt"
algorithm: sha256
+2 -231
View File
@@ -5,235 +5,6 @@ There are many areas we can use contributions - ranging from code, documentation
First, please read the [code of conduct](CODE_OF_CONDUCT.md). By participating, you're expected to uphold this code.
Table of Contents
=================
Please refer contributing docs for detailed guide.
* [Choose something to work on](#choose-something-to-work-on)
* [Get Help.](#get-help)
* [Contributing - building &amp; deploying](#contributing---building--deploying)
* [Prerequisite](#prerequisite)
* [Getting Started](#getting-started)
* [Use Skaffold with Kind/K8S Cluster to build and deploy](#use-skaffold-with-kindk8s-cluster-to-build-and-deploy)
* [Validating Installation](#validating-installation)
* [Understanding code structure](#understanding-code-structure)
* [cmd](#cmd)
* [pkg](#pkg)
* [Charts](#charts)
* [Environments](#environments)
# Choose something to work on
* The easiest way to start is to look at existing [issues](https://github.com/fission/fission/issues) and see if there's something there that you'd like to work on. You can filter issues with label "[Good first issue](https://github.com/fission/fission/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)" which are relatively self sufficient issues and great for first time contributors.
- If you are going to pick up an issue, it would be good to add a comment stating the intention.
- If the contribution is a big change/new feature, please raise an issue and discuss the needs, design in the issue in detail.
* For contributing a new Fission environment, please check the [environments repo](https://github.com/fission/environments)
* For contributing a new Keda Connector, please check the [Keda Connectors repo](https://github.com/fission/keda-connectors)
### Get Help.
Do reach out on Slack or Twitter and we are happy to help.
* Drop by the [slack channel](http://slack.fission.io).
* Say hi on [twitter](https://twitter.com/fissionio).
# Contributing - building & deploying
## Prerequisite
- You'll need the `go` compiler and tools installed. Currently version 1.12.x of Go is needed.
- You'll also need [docker](https://docs.docker.com/install) for building images locally.
- You will need a Kubernetes cluster and you can use one of options from below.
- [Minikube](https://github.com/kubernetes/minikube)
- [Kind](https://kind.sigs.k8s.io/)
- Cluster in cloud such as GKE (Google Kubernetes Engine cluster)/ EKS (Elastic Kubernetes Service)/ AKS (Azure Kubernetes Service)
- Kubectl and Helm installed.
- [Skaffold](https://skaffold.dev/docs/install/) for local development workflow to make it easier to build and deploy Fission.
- And of course some basic concepts of Fission such as environment, function are good to be aware of!
## Getting Started
Get the code locally and after you have made changes - you can verify formatting and other basic checks.
```sh
# Clone the repo
$ git clone https://github.com/fission/fission.git $GOPATH/src/github.com/fission/fission
$ cd $GOPATH/src/github.com/fission/fission
$ go mod vendor
# Run checks on your changes
$ ./hack/verify-gofmt.sh
$ ./hack/verify-govet.sh
```
### Use Skaffold with Kind/K8S Cluster to build and deploy
You should bring up Kind/Minikube cluster or if using a cloud provider cluster then Kubecontext should be pointing to appropriate cluster.
* For building & deploying to Cloud Provider K8S cluster such as GKE/EKS/AKS:
```
$ skaffold config set default-repo vishalbiyani // (vishalbiyani - should be your registry/Docker Hub handle)
$ skaffold run
```
* For building & deploying to Kind cluster use Kind profile
```
$ kind create cluster
$ kubectl create ns fission
$ skaffold run -p kind
```
## Validating Installation
If you are using Helm, you should see release installed:
```
helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
fission fission 1 2020-05-19 16:31:46.947562 +0530 IST success fission-all-1.11.0 1.11.0
```
Also you should see the Fission services deployed and running:
```
$ kubectl get pods -n fission
NAME READY STATUS RESTARTS AGE
buildermgr-6f778d4ff9-dqnq5 1/1 Running 0 6h9m
controller-d44bd4f4d-5q4z5 1/1 Running 0 6h9m
executor-557c68c6fd-dg8ld 1/1 Running 0 6h9m
influxdb-845548c959-2954p 1/1 Running 0 6h9m
kubewatcher-5784c454b8-5mqsk 1/1 Running 0 6h9m
logger-bncqn 2/2 Running 0 6h9m
mqtrigger-kafka-765b674ff-jk5x9 1/1 Running 0 6h9m
mqtrigger-nats-streaming-797498966c-xgxmk 1/1 Running 3 6h9m
nats-streaming-6bf48bccb6-fmmr9 1/1 Running 0 6h9m
router-db76576bd-xxh7r 1/1 Running 0 6h9m
storagesvc-799dcb5bdf-f69k9 1/1 Running 0 6h9m
timer-7d85d9c9fb-knctw 1/1 Running 0 6h9m
```
## Understanding code structure
### cmd
`cmd` package is entry point for all runtime components and also has Dockerfile for each component. The actual logic here will be pretty light and most of logic of each component is in `pkg` (Discussed later)
| Component | Runtime Component |Used in|
| :------------- |:------------- |:-|
| fetcher | Docker Image |Environments|
| fission-bundle | Docker Image |Binary for all components|
| fission-cli | CLI Binary |CLI by user|
| preupgradechecks | Docker Image |Pre-install upgrade|
```
.
cmd
├── fetcher
│   ├── Dockerfile.fission-fetcher
│   ├── app
│   └── main.go
├── fission-bundle
│   ├── Dockerfile.fission-bundle
│   ├── main.go
│   └── mqtrigger
├── fission-cli
│   ├── app
│   ├── fission-cli
│   └── main.go
└── preupgradechecks
├── Dockerfile.fission-preupgradechecks
├── main.go
└── preupgradechecks.go
```
**fetcher** : is a very lightweight component and all of related logic is in fetcher package itself. Fetcher helps in fetching and uploading code and in specializing environments.
**fission-bundle** : is a component which is a single binary for all components. Based on arguments you pass to fission-bundle - it becomes that component. For ex.
```
/fission-bundle --controllerPort "8888" # Runs Controller
/fission-bundle --kubewatcher --routerUrl http://router.fission # Runs Kubewatcher
```
So most server side components running on server side are fission-bundle binary wrapped in container and used with different arguments. Various arguments and environment variables are passed from manifests/helm chart
**fission-cli** : is the cli used by end user to interact Fission
**preupgradechecks** : is again a small independent component to do pre-install upgrade tasks.
### pkg
Pkg is where most of core components and logic reside. The structure is fairly self-explanatory for example all of executor related functionality will be in executor package and so on.
```
.
├── pkg
│   ├── apis
│   ├── builder
│   ├── buildermgr
│   ├── cache
│   ├── canaryconfigmgr
│   ├── controller
│   ├── crd
│   ├── error
│   ├── executor
│   ├── fetcher
│   ├── fission-cli
│   ├── generator
│   ├── info
│   ├── kubewatcher
│   ├── logger
│   ├── mqtrigger
│   ├── plugin
│   ├── publisher
│   ├── router
│   ├── storagesvc
│   ├── throttler
│   ├── timer
│   └── utils
```
### Charts
Fission currently has two charts - and we recommend using fission-all for development.
```
.
├── charts
│   ├── README.md
│   ├── fission-all
│   └── fission-core
```
### Environments
Each of runtime environments is in fission/environments repo and fairly independent. If you are enhancing or creating a new environment - most likely you will end up making changes in that repo.
```
.
├── environments
│   ├── binary
│   ├── dotnet
│   ├── dotnet20
│   ├── go
│   ├── jvm
│   ├── nodejs
│   ├── perl
│   ├── php7
│   ├── python
│   ├── ruby
│   └── tensorflow-serving
```
[https://docs.fission.io/docs/contributing/](https://docs.fission.io/docs/contributing/)
+25 -76
View File
@@ -14,33 +14,23 @@
.DEFAULT_GOAL := check
# Platforms to build in multi-architecture images.
PLATFORMS ?= linux/amd64,linux/arm64,linux/arm/v7
SKAFFOLD_PROFILE ?= kind
# Repository prefix and tag to push multi-architecture images to.
REPO ?= fission
TAG ?= dev
DOCKER_FLAGS ?= --push --progress plain
VERSION ?= master
VERSION ?= v0.0.0
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)
BINDIR ?= build/bin
FISSION-CLI-SUFFIX :=
ifeq ($(GOOS), windows)
FISSION-CLI-SUFFIX := .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)
# Show this help.
help:
@awk '/^#/{c=substr($$0,3);next}c&&/^[[:alpha:]][[:alnum:]_-]+:/{print substr($$1,1,index($$1,":")),c}1{c=0}' $(MAKEFILE_LIST) | column -s: -t
### Static checks
check: test-run build-fission-cli clean
@@ -56,61 +46,11 @@ test-run: code-checks
@rm -f coverage.txt
### Binaries
%-cli:
@mkdir -p $(BINDIR)
GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO) build \
-gcflags '$(GCFLAGS)' \
-asmflags '$(ASMFLAGS)' \
-ldflags "$(GO_LDFLAGS)" \
-o $(BINDIR)/$(subst -cli,,$@)-$(VERSION)-$(GOOS)-$(GOARCH)$(FISSION-CLI-SUFFIX) ./$<
build-fission-cli:
@GOOS=$(GOOS) GOARCH=$(GOARCH) GORELEASER_CURRENT_TAG=$(VERSION) goreleaser build --snapshot --rm-dist --single-target --id fission-cli
fission-cli: cmd/fission-cli
fission-bundle-cli: cmd/fission-bundle
fetcher-cli: cmd/fetcher
builder-cli: cmd/builder
preupgradechecks-cli: cmd/preupgradechecks
reporter-cli: cmd/reporter
local-bins: fission-cli fission-bundle-cli fetcher-cli builder-cli preupgradechecks-cli reporter-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-fission-cli: fission-cli
mv $(BINDIR)/fission-$(VERSION)-$(GOOS)-$(GOARCH)$(FISSION-CLI-SUFFIX) /usr/local/bin/fission
### 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)
local-images:
PLATFORMS=linux/amd64 $(MAKE) all-images
all-images: verify-builder $(FISSION_IMGS)
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-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 $< .
install-fission-cli:
mv dist/fission-cli_$(GOOS)_$(GOARCH)/fission$(FISSION-CLI-SUFFIX) /usr/local/bin/fission
### Codegen
codegen:
@@ -133,12 +73,7 @@ delete-crds:
### 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
@rm -f dist/
### Misc
generate-swagger-doc:
@@ -146,6 +81,20 @@ generate-swagger-doc:
all-generators: codegen generate-crds generate-swagger-doc
skaffold-prebuild:
@GOOS=linux GOARCH=amd64 GORELEASER_CURRENT_TAG=$(VERSION) goreleaser build --snapshot --rm-dist --single-target
@cp -v cmd/builder/Dockerfile.fission-builder dist/builder_linux_amd64/Dockerfile
@cp -v cmd/fetcher/Dockerfile.fission-fetcher dist/fetcher_linux_amd64/Dockerfile
@cp -v cmd/fission-bundle/Dockerfile.fission-bundle dist/fission-bundle_linux_amd64/Dockerfile
@cp -v cmd/reporter/Dockerfile.reporter dist/reporter_linux_amd64/Dockerfile
@cp -v cmd/preupgradechecks/Dockerfile.fission-preupgradechecks dist/pre-upgrade-checks_linux_amd64/Dockerfile
skaffold-deploy: skaffold-prebuild
skaffold run -p $(SKAFFOLD_PROFILE)
### Release
release:
@./hack/generate-helm-manifest.sh $(VERSION)
@./hack/release.sh $(VERSION)
@./hack/release-tag.sh $(VERSION)
@./hack/release-tag.sh $(VERSION)
@./hack/changelog.sh
+2 -43
View File
@@ -1,45 +1,4 @@
FROM golang:1.16-alpine as godep
RUN apk add bash ca-certificates git gcc g++ libc-dev
ARG GOPKG=github.com/fission/fission
ENV GO111MODULE=on
WORKDIR /go/src/${GOPKG}
# To reuse build cache, copy go.mod & go.sum and download dependencies first.
COPY go.* ./
RUN go mod download
FROM godep as builder
ARG GOPKG
WORKDIR /go/src/${GOPKG}
# Copy whole fission directory to work dir
COPY ./ ./
WORKDIR /go/src/${GOPKG}/cmd/builder
ARG GITCOMMIT=unknown
# E.g. GITCOMMIT=$(git rev-parse HEAD)
ARG BUILDVERSION=unknown
# E.g. BUILDVERSION=$(git rev-parse HEAD)
ARG BUILDDATE=unknown
# E.g. BUILDDATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
RUN CGO_ENABLED=0 go build \
-o /go/bin/builder \
-gcflags=-trimpath=$GOPATH \
-asmflags=-trimpath=$GOPATH \
-ldflags "-X github.com/fission/fission/pkg/info.GitCommit=${GITCOMMIT} -X github.com/fission/fission/pkg/info.BuildDate=${BUILDDATE} -X github.com/fission/fission/pkg/info.Version=${BUILDVERSION}"
FROM alpine:3.14 as base
FROM alpine:3.14
RUN apk add --update ca-certificates
COPY --from=builder /go/bin/builder /
EXPOSE 8001
COPY builder /builder
ENTRYPOINT ["/builder"]
+2 -43
View File
@@ -1,45 +1,4 @@
FROM golang:1.16-alpine as godep
RUN apk add bash ca-certificates git gcc g++ libc-dev
ARG GOPKG=github.com/fission/fission
ENV GO111MODULE=on
WORKDIR /go/src/${GOPKG}
# To reuse build cache, copy go.mod & go.sum and download dependencies first.
COPY go.* ./
RUN go mod download
FROM godep as builder
ARG GOPKG
WORKDIR /go/src/${GOPKG}
# Copy whole fission directory to work dir
COPY ./ ./
WORKDIR /go/src/${GOPKG}/cmd/fetcher
ARG GITCOMMIT=unknown
# E.g. GITCOMMIT=$(git rev-parse HEAD)
ARG BUILDVERSION=unknown
# E.g. BUILDVERSION=$(git rev-parse HEAD)
ARG BUILDDATE=unknown
# E.g. BUILDDATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
RUN CGO_ENABLED=0 go build \
-o /go/bin/fetcher \
-gcflags=-trimpath=$GOPATH \
-asmflags=-trimpath=$GOPATH \
-ldflags "-X github.com/fission/fission/pkg/info.GitCommit=${GITCOMMIT} -X github.com/fission/fission/pkg/info.BuildDate=${BUILDDATE} -X github.com/fission/fission/pkg/info.Version=${BUILDVERSION}"
FROM alpine:3.14 as base
FROM alpine:3.14
RUN apk add --update ca-certificates
COPY --from=builder /go/bin/fetcher /
EXPOSE 8000
COPY fetcher /
ENTRYPOINT ["/fetcher"]
+2 -42
View File
@@ -1,44 +1,4 @@
FROM golang:1.16-alpine as godep
RUN apk add bash ca-certificates git gcc g++ libc-dev
ARG GOPKG=github.com/fission/fission
ENV GO111MODULE=on
WORKDIR /go/src/${GOPKG}
# To reuse build cache, copy go.mod & go.sum and download dependencies first.
COPY go.* ./
RUN go mod download
FROM godep as builder
ARG GOPKG
WORKDIR /go/src/${GOPKG}
# Copy whole fission directory to work dir
COPY ./ ./
WORKDIR /go/src/${GOPKG}/cmd/fission-bundle
ARG GITCOMMIT=unknown
# E.g. GITCOMMIT=$(git rev-parse HEAD)
ARG BUILDVERSION=unknown
# E.g. BUILDVERSION=$(git rev-parse HEAD)
ARG BUILDDATE=unknown
# E.g. BUILDDATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
RUN CGO_ENABLED=0 go build \
-o /go/bin/fission-bundle \
-gcflags=-trimpath=$GOPATH \
-asmflags=-trimpath=$GOPATH \
-ldflags "-X github.com/fission/fission/pkg/info.GitCommit=${GITCOMMIT} -X github.com/fission/fission/pkg/info.BuildDate=${BUILDDATE} -X github.com/fission/fission/pkg/info.Version=${BUILDVERSION}"
FROM alpine:3.14 as base
FROM alpine:3.14
RUN apk add --update ca-certificates
COPY --from=builder /go/bin/fission-bundle /
COPY fission-bundle /
ENTRYPOINT ["/fission-bundle"]
@@ -1,45 +1,4 @@
FROM golang:1.16-alpine as godep
RUN apk add bash ca-certificates git gcc g++ libc-dev
ARG GOPKG=github.com/fission/fission
ENV GO111MODULE=on
WORKDIR /go/src/${GOPKG}
# To reuse build cache, copy go.mod & go.sum and download dependencies first.
COPY go.* ./
RUN go mod download
FROM godep as builder
ARG GOPKG
WORKDIR /go/src/${GOPKG}
# Copy whole fission directory to work dir
COPY ./ ./
WORKDIR /go/src/${GOPKG}/cmd/preupgradechecks
ARG GITCOMMIT=unknown
# E.g. GITCOMMIT=$(git rev-parse HEAD)
ARG BUILDVERSION=unknown
# E.g. BUILDVERSION=$(git rev-parse HEAD)
ARG BUILDDATE=unknown
# E.g. BUILDDATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
RUN CGO_ENABLED=0 go build \
-o /go/bin/pre-upgrade-checks \
-gcflags=-trimpath=$GOPATH \
-asmflags=-trimpath=$GOPATH \
-ldflags "-X github.com/fission/fission/pkg/info.GitCommit=${GITCOMMIT} -X github.com/fission/fission/pkg/info.BuildDate=${BUILDDATE} -X github.com/fission/fission/pkg/info.Version=${BUILDVERSION}"
FROM alpine:3.14 as base
FROM alpine:3.14
RUN apk add --update ca-certificates
COPY --from=builder /go/bin/pre-upgrade-checks /
COPY pre-upgrade-checks /
ENTRYPOINT ["/pre-upgrade-checks"]
EXPOSE 8001
+2 -41
View File
@@ -1,43 +1,4 @@
FROM golang:1.16-alpine as godep
RUN apk add bash ca-certificates git gcc g++ libc-dev
ARG GOPKG=github.com/fission/fission
ENV GO111MODULE=on
WORKDIR /go/src/${GOPKG}
# To reuse build cache, copy go.mod & go.sum and download dependencies first.
COPY go.* ./
RUN go mod download
FROM godep as builder
ARG GOPKG
WORKDIR /go/src/${GOPKG}
# Copy whole fission directory to work dir
COPY ./ ./
WORKDIR /go/src/${GOPKG}/cmd/reporter
ARG GITCOMMIT=unknown
# E.g. GITCOMMIT=$(git rev-parse HEAD)
ARG BUILDVERSION=unknown
# E.g. BUILDVERSION=$(git rev-parse HEAD)
ARG BUILDDATE=unknown
# E.g. BUILDDATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
RUN CGO_ENABLED=0 go build \
-o /go/bin/reporter \
-gcflags=-trimpath=$GOPATH \
-asmflags=-trimpath=$GOPATH \
-ldflags "-X github.com/fission/fission/pkg/info.GitCommit=${GITCOMMIT} -X github.com/fission/fission/pkg/info.BuildDate=${BUILDDATE} -X github.com/fission/fission/pkg/info.Version=${BUILDVERSION}"
FROM alpine:3.14 as base
FROM alpine:3.14
RUN apk add --update ca-certificates
COPY --from=builder /go/bin/reporter /
COPY reporter /
ENTRYPOINT ["/reporter"]
+9
View File
@@ -0,0 +1,9 @@
#!/bin/bash
set -e
#set -x
DIR=$(realpath $(dirname "$0"))/../
export GITHUB_TOKEN=$(cat ~/.github-token)
github_changelog_generator -u fission -p fission -t "${GITHUB_TOKEN}" --no-issues -o tmp_CHANGELOG.md
mv tmp_CHANGELOG.md "${DIR}"/CHANGELOG.md
+122
View File
@@ -0,0 +1,122 @@
#!/bin/bash
set -e
set -x
DIR=$(realpath $(dirname "$0"))/../
MANIFESTDIR=$(realpath "$DIR")/manifest
source $(realpath "${DIR}"/test/init_tools.sh)
doit() {
echo "! $*"
"$@"
}
check_charts_repo() {
local chartsrepo=$1
if [ ! -d "$chartsrepo" ]; then
echo "Error finding chart repo at $chartsrepo"
exit 1
fi
echo "check_charts_repo == PASSED"
}
update_chart_version() {
local version=$1
sed -i "s/^version.*/version\: ${version}/" charts/fission-core/Chart.yaml
sed -i "s/^version.*/version\: ${version}/" charts/fission-all/Chart.yaml
sed -i "s/appVersion.*/appVersion\: ${version}/" charts/fission-core/Chart.yaml
sed -i "s/appVersion.*/appVersion\: ${version}/" charts/fission-all/Chart.yaml
sed -i "s/\bimageTag:.*/imageTag\: ${version}/" charts/fission-core/values.yaml
sed -i "s/\bimageTag:.*/imageTag\: ${version}/" charts/fission-all/values.yaml
}
lint_charts() {
helm lint charts/fission-all charts/fission-core
if [ $? -ne 0 ]; then
echo "helm lint failed"
exit 1
fi
}
build_charts() {
mkdir -p "$MANIFESTDIR"/charts
pushd "$DIR"/charts
find . -iname *.~?~ | xargs -r rm
for c in fission-all fission-core; do
doit helm package -u $c/
mv ./*.tgz "$MANIFESTDIR"/charts/
done
popd
}
build_yamls() {
local version=$1
mkdir -p "${MANIFESTDIR}"/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}
doit helm dependency update
popd
echo "Release name", "$releaseName"
cmdprefix="helm template ${releaseName} ${c} --namespace fission --validate"
# for minikube and other environments that don't support LoadBalancer
command="$cmdprefix --set analytics=false,analyticsNonHelmInstall=true,serviceType=NodePort,routerServiceType=NodePort"
echo "$command"
$command >${c}-"${version}"-minikube.yaml
# for environments that support LoadBalancer
command="$cmdprefix --set analytics=false,analyticsNonHelmInstall=true"
echo "$command"
$command >${c}-"${version}".yaml
# for OpenShift
command="$cmdprefix --set analytics=false,analyticsNonHelmInstall=true,logger.enableSecurityContext=true,prometheus.enabled=false"
echo "$command"
$command >${c}-"${version}"-openshift.yaml
# copy yaml files to build directory
mv ./*.yaml "${MANIFESTDIR}"/yamls/
done
popd
}
update_github_charts_repo() {
local version=$1
local chartsrepo=$2
pushd "$chartsrepo"
cp "$MANIFESTDIR"/charts/fission-all-"${version}".tgz .
cp "$MANIFESTDIR"/charts/fission-core-"${version}".tgz .
./index.sh
popd
}
version=$1
if [ -z "$version" ]; then
echo "Release version not mentioned"
exit 1
fi
echo "Current version for release: $version"
chartsrepo="$DIR../fission-charts"
check_charts_repo "$chartsrepo"
# Build manifests and charts
lint_charts
update_chart_version "$version"
lint_charts
build_yamls "$version"
build_charts
update_github_charts_repo "$version" "$chartsrepo"
Regular → Executable
+2 -13
View File
@@ -9,18 +9,7 @@ if [ -z $version ]; then
exit 1
fi
gittag=$version
prefix="v"
gopkgtag=${version/#/${prefix}}
if [[ ${version} == v* ]]; then # if version starts with "v", don't append prefix.
gopkgtag=${version}
fi
# tag the release
doit git tag $gittag
doit git tag -a $gopkgtag -m "Fission $gopkgtag"
doit git tag $version
# push tag
doit git push origin $gittag
doit git push origin $gopkgtag
doit git push origin $version
+27 -249
View File
@@ -4,24 +4,29 @@ set -e
#set -x
DIR=$(realpath $(dirname "$0"))/../
BUILDDIR=$(realpath "$DIR")/build
artifacts=()
source $(realpath "${DIR}"/test/init_tools.sh)
MANIFESTDIR=$(realpath "$DIR")/manifest
doit() {
echo "! $*"
"$@"
}
# 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
echo "Not on release-${version} branch."
check_commands() {
if ! command -v goreleaser >/dev/null; then
echo "Goreleaser CLI not found. Please get from https://goreleaser.com/install/"
exit 1
fi
echo "check_commands == PASSED"
}
# Ensure we're on the master branch
check_branch() {
curr_branch=$(git rev-parse --abbrev-ref HEAD)
if [ "$curr_branch" != "master" ]; then
echo "Not on master branch."
exit 1
fi
echo "check_branch == PASSED"
}
# Ensure working dir is clean
@@ -30,232 +35,15 @@ check_clean() {
echo "Unclean tree"
exit 1
fi
echo "check_clean == PASSED"
}
attach_github_release_cli() {
# cli
echo "Artifact for osx amd64 cli"
artifacts+=("$BUILDDIR/bin/fission-$version-darwin-amd64")
echo "Artifact for windows amd64 cli"
artifacts+=("$BUILDDIR/bin/fission-$version-windows-amd64.exe")
echo "Artifact for linux amd64 cli"
artifacts+=("$BUILDDIR/bin/fission-$version-linux-amd64")
echo "Artifact for linux arm cli"
artifacts+=("$BUILDDIR/bin/fission-$version-linux-arm")
echo "Artifact for linux arm64 cli"
artifacts+=("$BUILDDIR/bin/fission-$version-linux-arm64")
}
attach_github_release_charts() {
local version=$1
echo "fission-all chart"
artifacts+=("$BUILDDIR/charts/fission-all-$version.tgz")
echo "Fission-core chart"
artifacts+=("$BUILDDIR/charts/fission-core-$version.tgz")
}
attach_github_release_yamls() {
local version=$1
for c in fission-all fission-core; do
# YAML
artifacts+=("$BUILDDIR/yamls/${c}-${version}-minikube.yaml")
artifacts+=("$BUILDDIR/yamls/${c}-${version}.yaml")
artifacts+=("$BUILDDIR/yamls/${c}-${version}-openshift.yaml")
done
}
update_github_charts_repo() {
local version=$1
local chartsrepo=$2
pushd "$chartsrepo"
cp "$BUILDDIR"/charts/fission-all-"${version}".tgz .
cp "$BUILDDIR"/charts/fission-core-"${version}".tgz .
./index.sh
popd
}
gh_release() {
local version=$1
cp "${DIR}"/hack/notes.md relnotes.md
create_downloads_table ${version} >> relnotes.md
doit gh release create "$version" --draft --prerelease --title "$version" --notes-file $(realpath "${DIR}"/relnotes.md) --target "$gitcommit" "${artifacts[@]}"
}
generate_changelog() {
local version=$1
echo "# ${version}" >new_CHANGELOG.md
echo
echo "[Documentation](https://docs.fission.io/)" >>new_CHANGELOG.md
echo
# 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
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"
echo
echo
echo "#### Downloads for ${version}"
echo
echo
echo "filename | sha256 hash"
echo "-------- | -----------"
for file in ${artifacts[@]}; do
filename=${file##*/}
echo "[${filename}]($url_prefix/$release_tag/${filename}) | \`$(shasum -a 256 ${file} | cut -d' ' -f 1)\`"
done
echo
}
export -f create_downloads_table
release_environment_check() {
local version=$1
local chartsrepo=$2
check_branch "$version"
check_clean
check_github_token() {
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 $chartsrepo"
exit 1
fi
}
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
doit 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}
doit helm dependency update
popd
echo "Release name", "$releaseName"
cmdprefix="helm template ${releaseName} ${c} --namespace fission --validate"
# for minikube and other environments that don't support LoadBalancer
command="$cmdprefix --set analytics=false,analyticsNonHelmInstall=true,serviceType=NodePort,routerServiceType=NodePort"
echo "$command"
$command >${c}-"${version}"-minikube.yaml
# for environments that support LoadBalancer
command="$cmdprefix --set analytics=false,analyticsNonHelmInstall=true"
echo "$command"
$command >${c}-"${version}".yaml
# for OpenShift
command="$cmdprefix --set analytics=false,analyticsNonHelmInstall=true,logger.enableSecurityContext=true,prometheus.enabled=false"
echo "$command"
$command >${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
REPO=fission VERSION=$version TAG=latest TIMESTAMP=$date COMMITSHA=$gitcommit make all-images
REPO=fission VERSION=$version TAG=$version 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
echo "check_github_token == PASSED"
}
export GITHUB_TOKEN=$(cat ~/.github-token)
@@ -266,29 +54,19 @@ if [ -z "$version" ]; then
exit 1
fi
date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
gitcommit=$(git rev-parse HEAD)
echo "Current version for release: $version"
chartsrepo=$2
if [ -z "$chartsrepo" ]; then
chartsrepo="$DIR../fission-charts"
fi
chartsrepo="$DIR../fission-charts"
# Prechecks
check_clean
check_commands
release_environment_check "$version" "$chartsrepo"
build_all "$version" "$date" "$gitcommit"
build_charts "$version"
build_yamls "$version"
check_branch
check_github_token
attach_github_release_cli "$version"
attach_github_release_charts "$version"
attach_github_release_yamls "$version"
update_github_charts_repo "$version" "$chartsrepo"
gh_release "$version"
generate_changelog "$version"
build_images "$version" "$date" "$gitcommit"
export GORELEASER_CURRENT_TAG=$version
echo "Release version $GORELEASER_CURRENT_TAG "
goreleaser release
echo "############ DONE #############"
echo "Congratulation, ${version} is ready to ship !!"
+10 -15
View File
@@ -1,7 +1,7 @@
####################################
# This file can be used with Skaffold (https://github.com/GoogleContainerTools/skaffold) to
# build and deploy Fission to Kubernetes cluster.
# Skaffold version v1.26.1 is used for this configuration.
# Skaffold version v1.31.0 is used for this configuration.
############## Usage ##############
# Skaffold CLI should be installed on your machine.
# For building & deploying to Cloud Provider
@@ -10,23 +10,18 @@
# For building & deploying to Kind cluster use Kind profile
# $ `skaffold run -p kind`
####################################
apiVersion: skaffold/v2beta17
apiVersion: skaffold/v2beta22
kind: Config
build:
artifacts:
- image: fission
context: .
docker:
dockerfile: cmd/fission-bundle/Dockerfile.fission-bundle
- image: fission-bundle
context: dist/fission-bundle_linux_amd64
- image: fetcher
docker:
dockerfile: cmd/fetcher/Dockerfile.fission-fetcher
- image: preupgradechecks
docker:
dockerfile: cmd/preupgradechecks/Dockerfile.fission-preupgradechecks
context: dist/fetcher_linux_amd64
- image: pre-upgrade-checks
context: dist/pre-upgrade-checks_linux_amd64
- image: reporter
docker:
dockerfile: cmd/reporter/Dockerfile.reporter
context: dist/reporter_linux_amd64
deploy:
helm:
releases:
@@ -36,9 +31,9 @@ deploy:
- ./charts/fission-all/values.yaml
artifactOverrides:
fetcher.image: fetcher
image: fission
image: fission-bundle
postInstallReportImage: reporter
preUpgradeChecksImage: preupgradechecks
preUpgradeChecksImage: pre-upgrade-checks
namespace: fission
setValues:
analytics: "false"
+7 -5
View File
@@ -82,11 +82,12 @@ test_fission_objects() {
build_docker_images() {
echo "Building new docker images"
doit docker build -t fission-bundle -f cmd/fission-bundle/Dockerfile.fission-bundle .
doit docker build -t fetcher -f cmd/fetcher/Dockerfile.fission-fetcher .
doit docker build -t builder -f cmd/builder/Dockerfile.fission-builder .
doit docker build -t reporter -f cmd/reporter/Dockerfile.reporter .
doit docker build -t preupgradechecks -f cmd/preupgradechecks/Dockerfile.fission-preupgradechecks .
make skaffold-prebuild
doit docker build -t fission-bundle dist/fission-bundle_linux_amd64
doit docker build -t fetcher dist/fetcher_linux_amd64
doit docker build -t builder dist/builder_linux_amd64
doit docker build -t reporter dist/reporter_linux_amd64
doit docker build -t preupgradechecks dist/pre-upgrade-checks_linux_amd64
}
kind_image_load() {
@@ -100,6 +101,7 @@ kind_image_load() {
install_fission_cli() {
echo "Installing new Fission cli"
doit make build-fission-cli
doit sudo make install-fission-cli
sudo chmod +x /usr/local/bin/fission
}