-
Notifications
You must be signed in to change notification settings - Fork 2
47 lines (43 loc) · 1.7 KB
/
triggerRelease.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: Create Tag And Release
on:
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name (in case not chosen the tag will be minor+1)'
required: false
default: ''
type: string
jobs:
createTagAndRelease:
runs-on: ubuntu-latest
name: Create Tag And Release And Push To Quay
permissions: write-all
outputs:
tagName: ${{ steps.setTag.outputs.tagName }}
steps:
- name: checkout
uses: actions/checkout@v2
- name: Set Tag Name
id: setTag
run: |
if [ -z "${{ github.event.inputs.tag_name }}" ]; then
git fetch --all --tags
newestTag=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "newestTag=$newestTag"
newTag=$(echo "$newestTag" | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}')
echo "newTag=$newTag"
echo "newTagName=$newTag" >> $GITHUB_ENV
echo "::set-output name=tagName::$newTag"
else
echo "newTagName=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
echo "::set-output name=tagName::${{ github.event.inputs.tag_name }}"
fi
- name: Create tag & Release
env:
GH_TOKEN: ${{ github.token }}
run: |
if [[ ${{ env.newTagName }} =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
gh release create ${{ env.newTagName }} --latest --title ${{ env.newTagName }} --generate-notes
else
gh release create v${{ env.newTagName }} --prerelease --title v${{ env.newTagName }} --generate-notes
fi