-
Notifications
You must be signed in to change notification settings - Fork 19
114 lines (100 loc) · 3.7 KB
/
version.yml
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
name: OasisPlatform Version
on:
workflow_dispatch:
inputs:
platform_version:
description: 'Update platform version [semvar]'
required: true
oasislmf_version:
description: 'Update oasislmf package [semvar]'
required: false
ods_tools_version:
description: 'Update the ods-tools package [semvar]'
required: false
workflow_call:
inputs:
platform_version:
description: 'Update version, semvar, input "{n}.{n}.{n}" or for pre-release "{n}.{n}.{n}rc{n}" [3.0.0, 3.0.0rc1] '
required: true
type: string
oasislmf_version:
description: 'Update the package version'
required: false
type: string
ods_tools_version:
description: 'Update the package version'
required: false
type: string
jobs:
version:
runs-on: ubuntu-latest
steps:
- name: Check valid semvar
run: |
VALID=$(echo ${{ inputs.platform_version }} | grep -oPc "^(\d+)\.(\d+)\.(\d+)rc(\d+)|(\d+)\.(\d+)\.(\d+)$")
[[ "$VALID" -eq "1" ]] || exit 1
- name: Check backport branch matches version (Platform)
if: startsWith(github.ref_name, 'backports/')
run: |
BRANCH_VER=$(echo ${{ github.ref_name }} | grep -oP "(\d+)\.(\d+)")
VALID=$(echo ${{ inputs.platform_version }} | grep $BRANCH_VER -c)
if [[ ! "$VALID" == 1 ]]; then
echo "Release Tag ${{ inputs.platform_version }} doesn't match branch ${{ github.ref_name }}"
exit 1
fi
- name: Check backport branch matches version (Oasislmf)
if: startsWith(github.ref_name, 'backports/') && inputs.oasislmf_version != ''
run: |
BRANCH_VER=$(echo ${{ github.ref_name }} | grep -oP "(\d+)\.(\d+)")
VALID=$(echo ${{ inputs.oasislmf_version }} | grep $BRANCH_VER -c)
if [[ ! "$VALID" == 1 ]]; then
echo "Release Tag ${{ inputs.oasislmf_version }} doesn't match branch ${{ github.ref_name }}"
exit 1
fi
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
fetch-depth: 0 # fetch the whole repo for complete history
- name: Setup github user
run: |
git config --global user.email ${{ env.GIT_EMAIL }}
git config --global user.name ${{ env.GIT_USERNAME }}
git config --global pull.ff only
env:
GIT_EMAIL: ${{ secrets.BUILD_GIT_EMAIL }}
GIT_USERNAME: ${{ secrets.BUILD_GIT_USERNAME }}
- name: Update Platform Version
run: |
echo ${{ inputs.platform_version }} > VERSION
git add VERSION
- name: Set up Python 3.12
if: inputs.oasislmf_version != ''
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install piptools
run: pip install pip-tools
- name: Update Oasislmf Version
if: inputs.oasislmf_version != ''
run: |
requ_list=( 'requirements-server' 'requirements-worker' 'requirements')
for fl in "${requ_list[@]}"; do
pip-compile --upgrade-package oasislmf==${{ inputs.oasislmf_version }} $fl.in
git add $fl.txt
done
- name: Update ods-tools Version
if: inputs.ods_tools_version != ''
run: |
requ_list=( 'requirements-server' 'requirements-worker' 'requirements')
for fl in "${requ_list[@]}"; do
pip-compile --upgrade-package ods-tools==${{ inputs.ods_tools_version }} $fl.in
git add $fl.txt
done
- name: Git Commit
run: |
[[ -z $(git status -s) ]] || git commit -m "Set version ${{ inputs.platform_version }}"
- name: Push
run: git push
env:
GITHUB_TOKEN: ${{ secrets.BUILD_GIT_TOKEN }}