-
Notifications
You must be signed in to change notification settings - Fork 65
47 lines (45 loc) · 1.59 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
name: version
on:
pull_request:
paths:
- "VERSION.txt"
jobs:
validate-version:
runs-on: ubuntu-latest
steps:
- name: Check out base branch
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: Get old version
run: |
old_version="$(head -1 VERSION.txt)"
echo "Old version: $old_version"
echo "old_version=$old_version" >> $GITHUB_ENV
- name: Check out head branch
uses: actions/checkout@v3
- name: Get new version
run: |
new_version="$(head -1 VERSION.txt)"
echo "New version: $new_version"
echo "new_version=$new_version" >> $GITHUB_ENV
- name: Compare versions
run: dpkg --compare-versions "${{ env.old_version }}" lt "${{ env.new_version }}"
- name: Check stable version validity
if: github.event.pull_request.base.ref == 'master'
run: |
pattern=^\(0\|[1-9][0-9]*\)\.\(0\|[1-9][0-9]*\)\.\(0\|[1-9][0-9]*\)$
if [[ ${{ env.new_version }} =~ $pattern ]]; then
echo "New version is valid."; exit 0
else
echo "New version is invalid."; exit 1
fi
- name: Check development version validity
if: github.event.pull_request.base.ref != 'master'
run: |
pattern=^\(0\|[1-9][0-9]*\)\.\(0\|[1-9][0-9]*\)dev\(0\|[1-9][0-9]*\)$
if [[ ${{ env.new_version }} =~ $pattern ]]; then
echo "New version is valid."; exit 0
else
echo "New version is invalid."; exit 1
fi