-
Notifications
You must be signed in to change notification settings - Fork 69
119 lines (100 loc) · 3.54 KB
/
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Release
on:
schedule:
# Every Monday at 07:00 (UTC)
- cron: '00 7 * * MON'
workflow_dispatch:
inputs:
release_branch:
description: Branch to release
required: true
default: staging
type: string
jobs:
initialize:
name: Initialize
runs-on: ubuntu-20.04
outputs:
release_type: ${{ steps.release_type.outputs.release_type }}
releasing_version: ${{ steps.releasing_version.outputs.releasing_version }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.release_branch || github.ref_name }}
- name: Prepare scripts
run: |
cat <<-EOF > bump.py
import sys
release_type = sys.argv[1]
version = sys.argv[2]
parts = version.split('.')
major = int(parts[0][1:])
minor = int(parts[1])
patch = int(parts[2])
if release_type == 'major':
major = major + 1
minor = 0
patch = 0
elif release_type == 'minor':
minor = minor + 1
patch = 0
elif release_type == 'patch':
patch = patch + 1
print('.'.join(['v' + str(major), str(minor), str(patch)]))
EOF
cat <<-EOF > minor.py
import datetime
# The base date can be any end of sprint from the past
base = int(datetime.datetime.strptime("24/04/2022", "%d/%m/%Y").timestamp())
now = int(datetime.datetime.now().timestamp())
diff = now - base
days_elapsed = int(diff / (24*60*60))
weeks_elapsed = int(days_elapsed / 7)
weeks_mod3 = int(weeks_elapsed % 3)
print(weeks_mod3)
EOF
- name: Determine release type
id: release_type
run: |
DO_RELEASE=$(python minor.py)
if [[ $DO_RELEASE == "1" ]]
then
echo "release_type=minor" >> $GITHUB_OUTPUT
else
echo "release_type=skip" >> $GITHUB_OUTPUT
fi
- name: Determine releasing version
if: ${{ steps.release_type.outputs.release_type != 'skip' }}
id: releasing_version
run: |
CURRENT_VERSION=$(awk '/## NEXT/,/url/' config.toml | grep -o '\"v.*\"' | tr -d '\"' | xargs)
# The following command adds the .z part of the version
RAW_VERSION=$(echo "$CURRENT_VERSION.0")
echo "releasing_version=$(python bump.py minor $RAW_VERSION)" >> $GITHUB_OUTPUT
- name: Cleanup
run: rm bump.py minor.py
- name: Log information
run: |
echo "Releasing version: ${{ steps.releasing_version.outputs.releasing_version }}"
release:
name: Release
if: ${{ needs.initialize.outputs.release_type != 'skip' && ((github.event_name == 'schedule' && github.repository == 'kiali/kiali.io') || github.event_name != 'schedule') }}
runs-on: ubuntu-20.04
needs: [initialize]
env:
RELEASING_VERSION: ${{ needs.initialize.outputs.releasing_version }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.release_branch || github.ref_name }}
fetch-depth: 0
- name: Configure git
run: |
git config user.email '[email protected]'
git config user.name 'kiali-bot'
- name: Create release
run: |
echo "Resolved current website version: $RELEASING_VERSION"
./scripts/release.sh -cv $RELEASING_VERSION -rn origin -gd true