Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Create release process #3485

Open
wants to merge 55 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
73d6923
wip
dbadura Nov 13, 2024
08b5566
wip
dbadura Nov 13, 2024
490a9e4
wip
dbadura Nov 14, 2024
90cbd2d
wip
dbadura Nov 14, 2024
353bb9b
adjust resources
dbadura Nov 14, 2024
0b63e0a
fix
dbadura Nov 14, 2024
79cd2e8
improvement
dbadura Nov 14, 2024
aff55df
improvement
dbadura Nov 14, 2024
1b38393
improvement
dbadura Nov 14, 2024
b93b089
wip
dbadura Nov 14, 2024
363d030
wip
dbadura Nov 14, 2024
65904af
wip
dbadura Nov 14, 2024
3d62932
Merge branch 'main' into release
dbadura Nov 15, 2024
2959e8e
wip
dbadura Nov 15, 2024
a4254d3
wip
dbadura Nov 15, 2024
745f5ff
wip
dbadura Nov 15, 2024
afca583
wip
dbadura Nov 15, 2024
0289df9
wip
dbadura Nov 15, 2024
6a86da6
wip
dbadura Nov 15, 2024
8ac6710
wip
dbadura Nov 15, 2024
649e43b
wip
dbadura Nov 15, 2024
ff187db
wip
dbadura Nov 15, 2024
a146924
wip
dbadura Nov 15, 2024
28acf1d
wip
dbadura Nov 15, 2024
1cd64b7
wip
dbadura Nov 15, 2024
b1a86f4
wip
dbadura Nov 15, 2024
73dbddd
wip
dbadura Nov 15, 2024
7a9f901
wip
dbadura Nov 15, 2024
8bf89e5
wip
dbadura Nov 15, 2024
bb11c68
wip
dbadura Nov 15, 2024
f3d5cb9
wip
dbadura Nov 15, 2024
5c0d5ae
wip
dbadura Nov 15, 2024
2f2a625
wip
dbadura Nov 15, 2024
f964e7d
wip
dbadura Nov 15, 2024
3542320
wip
dbadura Nov 18, 2024
955e4dc
wip
dbadura Nov 18, 2024
c5092e6
wip
dbadura Nov 18, 2024
56b157a
wip
dbadura Nov 18, 2024
8c9fe4a
wip
dbadura Nov 18, 2024
0753895
wip
dbadura Nov 18, 2024
5b64514
wip
dbadura Nov 18, 2024
919c194
wip
dbadura Nov 18, 2024
b223fc5
wip
dbadura Nov 18, 2024
454e910
wip
dbadura Nov 18, 2024
28bc472
wip
dbadura Nov 18, 2024
dee329d
wip
dbadura Nov 18, 2024
57a5f13
wip
dbadura Nov 19, 2024
1ed8699
wip
dbadura Nov 19, 2024
1750176
wip
dbadura Nov 19, 2024
9788041
wip
dbadura Nov 19, 2024
3d68830
adjustment before review
dbadura Nov 20, 2024
c459a4f
add busola-local build and fix after review
dbadura Nov 22, 2024
9f30817
small fix
dbadura Nov 22, 2024
0a1815e
fix typo
dbadura Nov 22, 2024
e328481
use correct workflow
dbadura Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/scripts/create_changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash

PREVIOUS_RELEASE=$2 # for testability

# 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
set -o pipefail # prevents errors in a pipeline from being masked
RELEASE_TAG=$1

REPOSITORY=${REPOSITORY:-kyma-project/busola}
GITHUB_URL=https://api.github.com/repos/${REPOSITORY}
GITHUB_AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}"
CHANGELOG_FILE="CHANGELOG.md"

if [ "${PREVIOUS_RELEASE}" == "" ]
then
PREVIOUS_RELEASE=$(git describe --tags --abbrev=0)
fi
echo "Previous release: ${PREVIOUS_RELEASE}"

echo "## What has changed" >> ${CHANGELOG_FILE}

git log "${PREVIOUS_RELEASE}"..HEAD --pretty=tformat:"%h" --reverse | while read -r COMMIT
do
COMMIT_AUTHOR=$(curl -H "${GITHUB_AUTH_HEADER}" -sS "${GITHUB_URL}/commits/${COMMIT}" | jq -r '.author.login')
if [ "${COMMIT_AUTHOR}" != "kyma-bot" ]; then
git show -s "${COMMIT}" --format="* %s by @${COMMIT_AUTHOR}" >> ${CHANGELOG_FILE}
fi
done

NEW_CONTRIB=$(mktemp --suffix=.new XXXXX)

join -v2 \
<(curl -H "${GITHUB_AUTH_HEADER}" -sS "${GITHUB_URL}/compare/$(git rev-list --max-parents=0 HEAD)...${PREVIOUS_RELEASE}" | jq -r '.commits[].author.login' | sort -u) \
<(curl -H "${GITHUB_AUTH_HEADER}" -sS "${GITHUB_URL}/compare/${PREVIOUS_RELEASE}...HEAD" | jq -r '.commits[].author.login' | sort -u) >"${NEW_CONTRIB}"

if [ -s "${NEW_CONTRIB}" ]
then
echo -e "\n## New contributors" >> ${CHANGELOG_FILE}
while read -r user
do
REF_PR=$(grep "@${user}" ${CHANGELOG_FILE} | head -1 | grep -o " (#[0-9]\+)" || true)
if [ -n "${REF_PR}" ] #reference found
then
REF_PR=" in ${REF_PR}"
fi
echo "* @${user} made first contribution${REF_PR}" >> ${CHANGELOG_FILE}
done <"${NEW_CONTRIB}"
fi

echo -e "\n**Full changelog**: https://github.com/$REPOSITORY/compare/${PREVIOUS_RELEASE}...${RELEASE_TAG}" >> ${CHANGELOG_FILE}

# cleanup
rm "${NEW_CONTRIB}" || echo "cleaned up"
38 changes: 38 additions & 0 deletions .github/scripts/create_draft_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

# This script returns the id of the draft release

# 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
set -o pipefail # prevents errors in a pipeline from being masked

RELEASE_TAG=$1
>&2 echo "Creating draft release: ${RELEASE_TAG}"

REPOSITORY=${REPOSITORY:-kyma-project/busola}
GITHUB_URL=https://api.github.com/repos/${REPOSITORY}
GITHUB_AUTH_HEADER="Authorization: Bearer ${GITHUB_TOKEN}"
CHANGELOG_FILE=$(cat CHANGELOG.md)

JSON_PAYLOAD=$(jq -n \
--arg tag_name "$RELEASE_TAG" \
--arg name "$RELEASE_TAG" \
--arg body "$CHANGELOG_FILE" \
'{
"tag_name": $tag_name,
"name": $name,
"body": $body,
"draft": true
}')

CURL_RESPONSE=$(curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "${GITHUB_AUTH_HEADER}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
${GITHUB_URL}/releases \
-d "$JSON_PAYLOAD")

echo "$(echo $CURL_RESPONSE | jq -r ".id")"
30 changes: 30 additions & 0 deletions .github/scripts/publish_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

# This script publishes a draft release

# 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
set -o pipefail # prevents errors in a pipeline from being masked

RELEASE_ID=${RELEASE_ID?"Release id is not defined"}
IS_LATEST_RELEASE=${IS_LATEST_RELEASE?"latest release not defined"}

REPOSITORY=${REPOSITORY:-kyma-project/busola}
GITHUB_URL=https://api.github.com/repos/${REPOSITORY}
GITHUB_AUTH_HEADER="Authorization: Bearer ${GITHUB_TOKEN}"

CURL_RESPONSE=$(curl -w "%{http_code}" -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "${GITHUB_AUTH_HEADER}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
${GITHUB_URL}/releases/${RELEASE_ID} \
-d '{"draft": false, "make_latest": '"$IS_LATEST_RELEASE"'}')

HTTP_CODE=$(tail -n1 <<< "${CURL_RESPONSE}")
if [[ "${HTTP_CODE}" != "200" ]]; then
echo "${CURL_RESPONSE}"
exit 1
fi
48 changes: 48 additions & 0 deletions .github/scripts/upload_assets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/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
set -o pipefail # prevents errors in a pipeline from being masked

REPOSITORY=${REPOSITORY:-kyma-project/busola}
RELEASE_TAG=${RELEASE_TAG?"Release tag is not defined"}
RELEASE_ID=${RELEASE_ID?"Release id is not defined"}


uploadFile() {
filePath=${1}
ghAsset=${2}

echo "Uploading ${filePath} as ${ghAsset}"
response=$(curl -s -o output.txt -w "%{http_code}" \
--request POST --data-binary @"$filePath" \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: text/yaml" \
$ghAsset)
if [[ "$response" != "201" ]]; then
echo "Unable to upload the asset ($filePath): "
echo "HTTP Status: $response"
cat output.txt
exit 1
else
echo "$filePath uploaded"
fi
}

BUSOLA_K8S="busola.yaml"
generate_k8s() {
set -x
cd resources
(cd base/web && kustomize edit set image busola-web=europe-docker.pkg.dev/kyma-project/prod/busola-web:"${RELEASE_TAG}")
(cd base/backend && kustomize edit set image busola-backend=europe-docker.pkg.dev/kyma-project/prod/busola-backend:"${RELEASE_TAG}")
kustomize build base/ > ../"${BUSOLA_K8S}"
cd -
}

echo "Updating github release with assets"
UPLOAD_URL="https://uploads.github.com/repos/${REPOSITORY}/releases/${RELEASE_ID}/assets"

generate_k8s
uploadFile ${BUSOLA_K8S} "${UPLOAD_URL}?name=${BUSOLA_K8S}"
9 changes: 7 additions & 2 deletions .github/workflows/busola-backend-build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Busola Backend Build

on:
workflow_call:
inputs:
tag:
description: "Additional tag for built images"
required: true
type: string
push:
branches:
- main
Expand All @@ -26,5 +32,4 @@ jobs:
name: busola-backend
dockerfile: Dockerfile
context: backend
export-tags: true
tags: latest
tags: ${{ inputs.tag != '' && inputs.tag || 'latest' }}
11 changes: 8 additions & 3 deletions .github/workflows/busola-build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Busola Build

on:
workflow_call:
inputs:
tag:
description: "Additional tag for built images"
required: true
type: string
push:
branches:
- main
Expand Down Expand Up @@ -37,6 +43,5 @@ jobs:
with:
name: busola
dockerfile: Dockerfile
context: .
export-tags: true
tags: latest
tags: ${{ inputs.tag != '' && inputs.tag || 'latest' }}
build-args: ${{ inputs.tag != '' && format('tag={0}', inputs.tag) || '' }}
12 changes: 8 additions & 4 deletions .github/workflows/busola-web-build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
name: Busola Web Build

on:
workflow_call:
inputs:
tag:
description: "Additional tag for built images"
required: true
type: string
push:
branches:
- main
- release
paths:
- ".github/workflows/busola-web-build.yml"
- "kyma/**"
Expand Down Expand Up @@ -36,6 +41,5 @@ jobs:
with:
name: busola-web
dockerfile: Dockerfile.web
context: .
export-tags: true
tags: latest
tags: ${{ inputs.tag != '' && inputs.tag || 'latest' }}
build-args: ${{ inputs.tag != '' && format('tag={0}', inputs.tag) || '' }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure after first release on dev, that it is working and displayed correctly

Loading
Loading