generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 22
chore: create release workflow #1454
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
Draft
kevin-kho
wants to merge
9
commits into
kyma-project:main
Choose a base branch
from
kevin-kho:kh-create-release-workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ac02d50
first pass for create-release workflow
kevin-kho 41a0450
moved shell scripts from hack to workflow/scripts
kevin-kho 267147d
added sec-scanner-config version bump
kevin-kho 472bfe2
added test email and name for git
kevin-kho 604b45e
added render-sec-scanners-config-release.sh
kevin-kho 92a82bd
moved create release shell scripts to tools/scripts/release dir
kevin-kho 84286ad
updated create_changelog.sh to no longer add PRs to body
kevin-kho dcb98b1
create-module-config.yaml WIP
kevin-kho 6b34cce
separated create-module-config and update-module-release into two bra…
kevin-kho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: Bump version | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: # github.event.inputs.version | ||
| description: 'Release version ( e.g. "2.1.3")' | ||
| default: "" | ||
| required: true | ||
|
|
||
| jobs: | ||
| bump-version: | ||
| name: Bump version | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
| RELEASE_TAG: ${{github.event.inputs.VERSION}} | ||
| REPOSITORY: ${{github.repository}} | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Generate sec-scanners-config | ||
| run: | | ||
| echo "Creating sec-scanners-config.yaml" | ||
| ./tools/scripts/release/render-sec-scanners-config.sh ${RELEASE_TAG} | ||
|
|
||
| - name: Generate sec-scanners-config-release | ||
| run: | | ||
| echo "Creating sec-scanners-config-release.yaml" | ||
| ./tools/scripts/release/render-sec-scanners-config-release.sh ${RELEASE_TAG} | ||
|
|
||
| - name: Check if generated sec-scanners-config differs and commit | ||
| run: | | ||
| if [ -z "$(git status --porcelain)" ]; then | ||
| echo "No changes found" | ||
| else | ||
| echo "Changes found. Commiting to repo" | ||
| echo "bumped sec-scanners-config.yaml to ${RELEASE_TAG}" | ||
| git config --global user.email "[email protected]" | ||
| git config --global user.name "Test Test" | ||
| git add ./sec-scanners-config.yaml | ||
| git commit -m "bumped sec-scanners-config.yaml to ${RELEASE_TAG}" | ||
| git push | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| name: Create release | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: # github.event.inputs.version | ||
| description: 'Release version ( e.g. "2.1.3")' | ||
| default: "" | ||
| required: true | ||
|
|
||
| jobs: | ||
| create-draft: | ||
| name: Create draft | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
| RELEASE_TAG: ${{github.event.inputs.VERSION}} | ||
| REPOSITORY: ${{github.repository}} | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Create changelog | ||
| run: ./tools/scripts/release/create_changelog.sh $REPOSITORY $RELEASE_TAG | ||
|
|
||
| - name: Create draft release | ||
| id: create-draft | ||
| run: | | ||
| RELEASE_ID=$(./tools/scripts/release/create_draft_release.sh $REPOSITORY $RELEASE_TAG) | ||
| echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Get manifest and example | ||
| run: | | ||
| MANIFEST_FILEPATH=./config/crd/bases/cloud-resources.kyma-project.io_cloudresources.yaml | ||
| EXAMPLE_FILEPATH=./config/samples/cloud-resources_v1beta1_cloudresources.yaml | ||
| ./tools/scripts/upload_manifests.sh $REPOSITORY $MANIFEST_FILEPATH $EXAMPLE_FILEPATH ${{steps.create-draft.outputs.release_id}} | ||
|
|
||
| - name: Add lightweight tag | ||
| run: | | ||
| git tag $RELEASE_TAG | ||
| git push origin $RELEASE_TAG | ||
|
|
||
| outputs: | ||
| release_id: ${{steps.create-draft.outputs.release_id}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,184 @@ | ||
| name: Update Module Manifest | ||
| on: | ||
| release: | ||
| types: [published] | ||
|
|
||
| jobs: | ||
| fetch-vars: | ||
| name: Fetch variables | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} # for github.com | ||
| TOOLS_TOKEN: ${{secrets.TOOLS_TOKEN}} # for github.tools.sap TODO: figure out which token to use | ||
| MODULE_MANIFEST_REPO: ${{vars.MODULE_MANIFEST_REPO}} # github.tools.sap | ||
| CLOUD_MANAGER_REPO: ${{vars.CLOUD_MANAGER_REPO}} # github.com | ||
| outputs: | ||
| MAIN_SHA: ${{steps.main_sha.outputs.main_sha}} | ||
| RELEASE_TAG: ${{steps.get_release_tag.outputs.tag}} | ||
| MODULE_RELEASE_SHA: ${{steps.get_sha_content.outputs.sha}} | ||
| MODULE_RELEASE_CONTENT: ${{steps.get_sha_content.outputs.content}} | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Get Main Sha | ||
| id: main_sha | ||
| run: | | ||
| RES=$(curl -L \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| -H "Authorization: Bearer ${TOOLS_TOKEN}" \ | ||
| -H "X-GitHub-Api-Version: 2022-11-28" \ | ||
| https://github.tools.sap/api/v3/repos/${MODULE_MANIFEST_REPO}/branches/main) | ||
| SHA=$(echo $RES | yq -e ".commit.sha") | ||
| echo "main_sha=$SHA" >> $GITHUB_OUTPUT | ||
| - name: Get Release Tag | ||
| id: get_release_tag | ||
| run: | | ||
| RES=$(curl -L \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| -H "Authorization: Bearer ${GITHUB_TOKEN}" \ | ||
| -H "X-GitHub-Api-Version: 2022-11-28" \ | ||
| https://api.github.com/repos/${CLOUD_MANAGER_REPO}/releases/latest) | ||
|
|
||
| TAG=$(echo $RES | yq -e .tag_name) | ||
| echo "tag=$TAG" >> $GITHUB_OUTPUT | ||
| - name: Get SHA and Content of current module-release | ||
| id: get_sha_content | ||
| run: | | ||
| RES=$(curl -L \ | ||
| -H "Accept: application/vnd.github.object" \ | ||
| -H "Authorization: Bearer ${TOOLS_TOKEN}" \ | ||
| -H "X-GitHub-Api-Version: 2022-11-28" \ | ||
| https://github.tools.sap/api/v3/repos/${MODULE_MANIFEST_REPO}/contents/modules/cloud-manager/module-releases.yaml) | ||
|
|
||
| SHA=$(echo $RES | yq -e .sha) | ||
| CONTENT=$(echo $RES | yq -e .content) | ||
| CONTENT=$(echo $CONTENT | tr -d ' ') | ||
|
|
||
| echo "sha=$SHA" >> $GITHUB_OUTPUT | ||
| echo "content=$CONTENT" >> $GITHUB_OUTPUT | ||
|
|
||
| create-branch: | ||
| name: Create branch | ||
| needs: fetch-vars | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} # for github.com | ||
| TOOLS_TOKEN: ${{secrets.TOOLS_TOKEN}} # for github.tools.sap TODO: figure out which token to use | ||
| MODULE_MANIFEST_REPO: ${{vars.MODULE_MANIFEST_REPO}} # github.tools.sap | ||
| CLOUD_MANAGER_REPO: ${{vars.CLOUD_MANAGER_REPO}} # github.com | ||
| outputs: | ||
| BRANCH_NAME_MODULE_CONFIG: ${{steps.create_branch_module_config.outputs.BRANCH_NAME_MODULE_CONFIG}} | ||
| BRANCH_NAME_MODULE_RELEASE: ${{steps.create_branch_module_release.outputs.BRANCH_NAME_MODULE_RELEASE}} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: create branch # TODO: fix branch name | ||
| id: create_branch_module_config | ||
| run: | | ||
| MAIN_SHA=${{needs.fetch-vars.outputs.MAIN_SHA}} | ||
|
|
||
| BRANCH_NAME=$(echo "cloud-manager-${{needs.fetch-vars.outputs.RELEASE_TAG}}-module-config") | ||
| REF=$(echo "refs/heads/$BRANCH_NAME") | ||
| curl -L \ | ||
| -X POST \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| -H "Authorization: Bearer ${TOOLS_TOKEN}" \ | ||
| -H "X-GitHub-Api-Version: 2022-11-28" \ | ||
| https://github.tools.sap/api/v3/repos/${MODULE_MANIFEST_REPO}/git/refs \ | ||
| -d '{"ref":"'"$REF"'","sha":"'"$MAIN_SHA"'"}' | ||
|
|
||
| echo "BRANCH_NAME_MODULE_CONFIG=$BRANCH_NAME" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: create branch module-release | ||
| id: create_branch_module_release | ||
| run: | | ||
| MAIN_SHA=${{needs.fetch-vars.outputs.MAIN_SHA}} | ||
| BRANCH_NAME=$(echo "cloud-manager-${{needs.fetch-vars.outputs.RELEASE_TAG}}-module-release") | ||
| REF=$(echo "refs/heads/$BRANCH_NAME") | ||
|
|
||
| curl -L \ | ||
| -X POST \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| -H "Authorization: Bearer ${TOOLS_TOKEN}" \ | ||
| -H "X-GitHub-Api-Version: 2022-11-28" \ | ||
| https://github.tools.sap/api/v3/repos/${MODULE_MANIFEST_REPO}/git/refs \ | ||
| -d '{"ref":"'"$REF"'","sha":"'"$MAIN_SHA"'"}' | ||
|
|
||
| echo "BRANCH_NAME_MODULE_RELEASE=$BRANCH_NAME" >> $GITHUB_OUTPUT | ||
|
|
||
| create-module-config: | ||
| name: Create Module Config | ||
| runs-on: ubuntu-latest | ||
| needs: [fetch-vars, create-branch] | ||
| env: | ||
| GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} # for github.com | ||
| TOOLS_TOKEN: ${{secrets.TOOLS_TOKEN}} # for github.tools.sap TODO: figure out which token to use | ||
| MODULE_MANIFEST_REPO: ${{vars.MODULE_MANIFEST_REPO}} # github.tools.sap | ||
| CLOUD_MANAGER_REPO: ${{vars.CLOUD_MANAGER_REPO}} # github.com | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: create module-config.yaml # TODO: fix JSON body | ||
| run: | | ||
| MODULE_CONFIG_BASE=$(./tools/scripts/release/create_module_config.sh | base64) | ||
| MODULE_CONFIG_BASE=$(echo $MODULE_CONFIG_BASE | tr -d ' ') | ||
| BRANCH_NAME=${{needs.create-branch.outputs.BRANCH_NAME_MODULE_CONFIG}} | ||
|
|
||
| curl -L \ | ||
| -X PUT \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| -H "Authorization: Bearer ${TOOLS_TOKEN}" \ | ||
| -H "X-GitHub-Api-Version: 2022-11-28" \ | ||
| https://github.tools.sap/api/v3/repos/${MODULE_MANIFEST_REPO}/contents/modules/cloud-manager/1.4.2/module-config.yaml \ | ||
| -d '{"message":"'"$BRANCH_NAME"'","branch":"'"$BRANCH_NAME"'","content":"'"$MODULE_CONFIG_BASE"'"}' | ||
|
|
||
| update-module-release: | ||
| name: Update Module Release | ||
| runs-on: ubuntu-latest | ||
| needs: [fetch-vars, create-branch, create-module-config] | ||
| env: | ||
| GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} # for github.com | ||
| TOOLS_TOKEN: ${{secrets.TOOLS_TOKEN}} # for github.tools.sap TODO: figure out which token to use | ||
| MODULE_MANIFEST_REPO: ${{vars.MODULE_MANIFEST_REPO}} # github.tools.sap | ||
| CLOUD_MANAGER_REPO: ${{vars.CLOUD_MANAGER_REPO}} # github.com | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Generate module-release.yaml # TODO: fix JSON body | ||
| run: | | ||
| SHA=${{needs.fetch-vars.outputs.MODULE_RELEASE_SHA}} | ||
| CONTENT=${{needs.fetch-vars.outputs.MODULE_RELEASE_CONTENT}} | ||
| BRANCH_NAME=${{needs.create-branch.outputs.BRANCH_NAME_MODULE_RELEASE}} | ||
|
|
||
| DEV_VER=$(echo $CONTENT | base64 -d | yq '.channels[] | select(.channel == "dev") | .version' ) | ||
| EXPERIMENTAL_VER=$(echo $CONTENT | base64 -d | yq '.channels[] | select(.channel == "experimental") | .version' ) | ||
| FAST_VER=$(echo $CONTENT | base64 -d | yq '.channels[] | select(.channel == "fast") | .version' ) | ||
| REGULAR_VER=$(echo $CONTENT | base64 -d | yq '.channels[] | select(.channel == "regular") | .version' ) | ||
|
|
||
| # update dev version & keep others the same | ||
| NEW_DEV_VER=${{needs.fetch-vars.outputs.RELEASE_TAG}} | ||
|
|
||
| MODULE_RELEASE=$(./tools/scripts/release/create_module_release.sh $NEW_DEV_VER $EXPERIMENTAL_VER $FAST_VER $REGULAR_VER | base64) | ||
| MODULE_RELEASE=$(echo $MODULE_RELEASE | tr -d ' ') | ||
|
|
||
| curl -L \ | ||
| -X PUT \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| -H "Authorization: Bearer ${TOOLS_TOKEN}" \ | ||
| -H "X-GitHub-Api-Version: 2022-11-28" \ | ||
| https://github.tools.sap/api/v3/repos/${MODULE_MANIFEST_REPO}/contents/modules/cloud-manager/module-releases.yaml \ | ||
| -d '{"message":"updated cloud-manager module-releases.yaml","branch":"'"$BRANCH_NAME"'","content":"'"$MODULE_RELEASE"'","sha":"'"$SHA"'"}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # This script will create a changelog for a release based on the latest commits. | ||
|
|
||
|
|
||
| # 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=$1 | ||
| RELEASE_TAG=$2 | ||
|
|
||
| GITHUB_URL=https://api.github.com/repos/${REPOSITORY} | ||
| GITHUB_AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}" | ||
| CHANGELOG_FILE="CHANGELOG.md" | ||
|
|
||
| PREVIOUS_RELEASE=$(git describe --tags --abbrev=0) | ||
|
|
||
| echo -e "\n**Full changelog**: https://github.com/$REPOSITORY/compare/${PREVIOUS_RELEASE}...${RELEASE_TAG}" >>${CHANGELOG_FILE} | ||
|
|
||
| # cleanup | ||
| echo "CHANGELOG.md created" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # This script creates a draft release and returns its id . | ||
|
|
||
| # 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=$1 | ||
| RELEASE_TAG=$2 | ||
|
|
||
| GITHUB_URL=https://api.github.com/repos/${REPOSITORY} | ||
| GITHUB_AUTH_HEADER="Authorization: Bearer ${GITHUB_TOKEN}" | ||
| CHANGELOG_FILE=$(cat CHANGELOG.md) | ||
|
|
||
| # Create the json payload to create a draft release. | ||
| 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 | ||
| }') | ||
|
|
||
| # # Send the payload to github to create the draft release. The response contains the id of the release. | ||
| 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") | ||
|
|
||
| # Return the draft release id. | ||
| echo "$(echo $CURL_RESPONSE | jq -r ".id")" | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # TODO: make version and repositoryTag be CLI variables | ||
| cat <<EOF | ||
| name: kyma-project.io/module/cloud-manager | ||
| version: 1.4.1 | ||
| manifest: cloud-resources.kyma-project.io_cloudresources.yaml | ||
| defaultCR: cloud-resources_v1beta1_cloudresources.yaml | ||
| documentation: https://help.sap.com/docs/btp/sap-business-technology-platform/cloud-manager-module?version=Cloud | ||
| repository: https://github.com/kyma-project/cloud-manager.git | ||
| repositoryTag: 1.4.1 | ||
| security: sec-scanners-config-release.yaml | ||
| manager: | ||
| name: cloud-manager | ||
| namespace: kyma-system | ||
| group: apps | ||
| version: v1beta1 | ||
| kind: Deployment | ||
| icons: | ||
| - name: module-icon | ||
| link: https://raw.githubusercontent.com/kyma-project/kyma/refs/heads/main/docs/assets/logo_icon.svg | ||
| EOF |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| DEV_VER=$1 | ||
| EXPERIMENTAL_VER=$2 | ||
| FAST_VER=$3 | ||
| REGULAR_VER=$4 | ||
|
|
||
| cat <<EOF | ||
| targetLandscapes: | ||
| - dev | ||
| - stage | ||
| - prod | ||
| channels: | ||
| - channel: dev | ||
| version: $DEV_VER | ||
| - channel: experimental | ||
| version: $EXPERIMENTAL_VER | ||
| - channel: fast | ||
| version: $FAST_VER | ||
| - channel: regular | ||
| version: $REGULAR_VER | ||
| EOF |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.