Create release #2
Workflow file for this run
This file contains 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
name: "Create release" | |
env: | |
IMAGE_REPO: europe-docker.pkg.dev/kyma-project/prod/runtime-watcher-skr | |
CODE_REPOSITORY: kyma-project/runtime-watcher | |
on: | |
push: | |
tags: | |
- '[0-9]+.[0-9]+.[0-9]-?*' | |
jobs: | |
validate-release: | |
name: Validate release | |
runs-on: ubuntu-latest | |
outputs: | |
current_release_tag: ${{ steps.get_current_release_tag.outputs.current_release_tag }} | |
last_release_tag: ${{ steps.get_last_release_tag.outputs.last_release_tag }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Find the release tag | |
id: get_current_release_tag | |
run: | | |
echo "Current release tag: ${GITHUB_REF#refs/*/}" | |
echo "current_release_tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | |
- name: Check if release doesn't exist yet | |
env: | |
CURRENT_RELEASE_TAG: ${{ steps.get_current_release_tag.outputs.current_release_tag }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: ./runtime-watcher/scripts/release/get_release_by_tag.sh $CURRENT_RELEASE_TAG | |
- name: Get last release version | |
id: get_last_release_tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
set +e | |
SCRIPT_OUTPUT=$(./runtime-watcher/scripts/release/get_last_release.sh) | |
SCRIPT_EXIT_CODE=$? | |
if [[ $SCRIPT_EXIT_CODE != 0 ]]; then | |
echo "$SCRIPT_OUTPUT" | |
exit $SCRIPT_EXIT_CODE | |
fi | |
set -e | |
echo "Last Release version: $SCRIPT_OUTPUT" | |
echo "last_release_tag=$SCRIPT_OUTPUT" >> $GITHUB_OUTPUT | |
- name: Wait for the Docker image | |
timeout-minutes: 15 | |
env: | |
ITERATIONS: 30 | |
SLEEP_SECONDS: 30 | |
run: ./runtime-watcher/scripts/release/wait_for_image.sh ${{ env.IMAGE_REPO }}:${{ steps.get_current_release_tag.outputs.current_release_tag }} $ITERATIONS $SLEEP_SECONDS | |
draft-release: | |
name: Create draft release | |
runs-on: ubuntu-latest | |
needs: validate-release | |
outputs: | |
release_id: ${{ steps.draft_release.outputs.release_id }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Generate changelog | |
id: generate_changelog | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
CURRENT_RELEASE_TAG: ${{ needs.validate-release.outputs.current_release_tag }} | |
LAST_RELEASE_TAG: ${{ needs.validate-release.outputs.last_release_tag }} | |
run: | | |
echo "Generating changelog for version: ${{ needs.validate-release.outputs.current_release_tag }}" | |
CHANGELOG_FILE_NAME=$(./runtime-watcher/scripts/release/create_changelog.sh $CURRENT_RELEASE_TAG $LAST_RELEASE_TAG) | |
echo "changelog_file_name=$CHANGELOG_FILE_NAME" >> $GITHUB_OUTPUT | |
- name: Create draft release | |
id: draft_release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
CURRENT_RELEASE_TAG: ${{ needs.validate-release.outputs.current_release_tag }} | |
CHANGELOG_FILE_NAME: ${{ steps.generate_changelog.outputs.changelog_file_name }} | |
run: | | |
RELEASE_ID=$(./runtime-watcher/scripts/release/create_draft_release.sh $CURRENT_RELEASE_TAG $CHANGELOG_FILE_NAME) | |
echo "RELEASE_ID=$RELEASE_ID" | |
echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT | |
publish_release: | |
name: Publish release | |
runs-on: ubuntu-latest | |
needs: draft-release | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Publish release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
RELEASE_ID: ${{ needs.draft-release.outputs.release_id }} | |
run: | | |
echo "RELEASE_ID=$RELEASE_ID" | |
./runtime-watcher/scripts/release/publish_release.sh $RELEASE_ID |