Skip to content

Commit

Permalink
Automated releases (#11)
Browse files Browse the repository at this point in the history
* Dummy change

* Disable image building on pr job

* Remove dummy change

* Add release files

* Add execute permissions

* Clear blocking pipeline
  • Loading branch information
werdes72 authored Sep 7, 2022
1 parent f73d7a7 commit f5712aa
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 2 deletions.
34 changes: 34 additions & 0 deletions .github/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "changelog-generator",
"version": "0.2.0",
"description": "Changelog Generator",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/kyma-project/api-gateway"
},
"changelog": {
"repo": "kyma-project/api-gateway",
"labels": {
"area/application-connector": "Application Connector",
"area/serverless": "Serverless",
"area/service-catalog": "Service Catalog",
"area/cluster": "Cluster",
"area/eventing": "Eventing",
"area/security": "Security",
"area/service-mesh": "Service Mesh",
"area/installation": "Installation",
"area/monitoring": "Monitoring",
"area/logging": "Logging",
"area/tracing": "Tracing",
"area/console": "Console",
"area/luigi": "Luigi",
"area/documentation": "Documentation",
"area/community": "Community",
"area/ci": "CI",
"area/core-and-supporting": "Core and Supporting",
"area/cli": "CLI"
},
"cacheDir": ".changelog"
}
}
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,23 @@ lint: ## Run golangci-lint against code.
GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANG_CI_LINT_VERSION)
$(LOCALBIN)/golangci-lint run

.PHONY: archive
archive:
cp -r bin/* $(ARTIFACTS)

.PHONY: release
release:
./hack/release.sh

##@ ci targets
.PHONY: ci-pr
ci-pr: build test docker-build docker-push docker-build-certificates docker-push-certificates
ci-pr: build test

.PHONY: ci-main
ci-main: build docker-build docker-push docker-build-certificates docker-push-certificates

.PHONY: ci-release
ci-release: build docker-build docker-push docker-build-certificates docker-push-certificates
ci-release: build docker-build docker-push docker-build-certificates docker-push-certificates archive release

.PHONY: clean
clean:
Expand Down
45 changes: 45 additions & 0 deletions hack/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash

# standard bash error handling
set -o nounset # treat unset variables as an error and exit immediately.
set -o errexit # exit immediately when a command fails.
set -E # needs to be set if we want the ERR trap

readonly API_GATEWAY_DIR="/home/prow/go/src/github.com/kyma-project/api-gateway"

# locally delete the stable tag in order to have all the change logs listed under the new release version
delete_stable_tag() {
if [[ $(git tag -l stable) ]]; then
git tag -d stable
fi
}

get_new_release_version() {
# get the list of tags in a reverse chronological order
TAG_LIST=($(git tag --sort=-creatordate))
NEW_RELEASE_VERSION=${TAG_LIST[0]}
}

get_current_release_version() {
# get the list of tags in a reverse chronological order excluding release candidate tags
TAG_LIST_WITHOUT_RC=($(git tag --sort=-creatordate | grep -v -e "-rc"))
if [[ $NEW_RELEASE_VERSION == *"-rc"* ]]; then
CURRENT_RELEASE_VERSION=${TAG_LIST_WITHOUT_RC[0]}
else
CURRENT_RELEASE_VERSION=${TAG_LIST_WITHOUT_RC[1]}
fi
}

main() {
git remote add origin git@github.com:kyma-project/api-gateway.git
delete_stable_tag
get_new_release_version
get_current_release_version

# generate release changelog
docker run --rm -v "${API_GATEWAY_DIR}":/repository -w /repository -e FROM_TAG="${CURRENT_RELEASE_VERSION}" -e NEW_RELEASE_TITLE="${NEW_RELEASE_VERSION}" -e GITHUB_AUTH="${BOT_GITHUB_TOKEN}" -e CONFIG_FILE=.github/package.json eu.gcr.io/kyma-project/changelog-generator:0.2.0 sh /app/generate-release-changelog.sh
# release api-gateway with release notes generated by changelog-generator
curl -sL https://git.io/goreleaser | VERSION=v0.118.2 bash -s -- --release-notes .changelog/release-changelog.md
}

main

0 comments on commit f5712aa

Please sign in to comment.