-
Notifications
You must be signed in to change notification settings - Fork 14
48 lines (46 loc) · 1.41 KB
/
update-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
name: Update Release Version
on:
release:
types: [released]
workflow_dispatch:
inputs:
version:
description: 'Version that should be released'
required: true
default: '1.2.3'
jobs:
update-version:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
ref: 'main'
fetch-depth: 0
- name: Version from Workflow Dispatch
if: github.event_name == 'workflow_dispatch'
run: |
V=$(echo ${{ github.event.inputs.version }} | sed 's/v//g')
echo "VERSION=${V}" >> $GITHUB_ENV
- name: Version from Release Tag
if: github.event_name == 'release'
run: |
V=$(echo ${{ github.event.release.tag_name }} | sed 's/v//g')
echo "VERSION=${V}" >> $GITHUB_ENV
- name: Verify valid version
id: vars
run: |
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version: $VERSION"
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Commit VERSION file
run: |
echo ${VERSION} > VERSION
echo "VERSION is $VERSION"
git add VERSION
git config --global user.email "[email protected]"
git config --global user.name "Mondoo Tools"
git commit -m "Update VERSION to $VERSION"
git push -f