-
Notifications
You must be signed in to change notification settings - Fork 14
99 lines (98 loc) · 3.84 KB
/
create-release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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