generated from onedr0p/cluster-template
-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (41 loc) · 1.48 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
---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: "Release"
on:
workflow_dispatch:
schedule:
- cron: "0 0 1 * *"
jobs:
release:
if: ${{ github.repository == 'onedr0p/cluster-template' }}
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create Release
shell: bash
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
# Retrieve previous release tag
previous_tag="$(gh release list --limit 1 | awk '{ print $1 }')"
previous_major="${previous_tag%%\.*}"
previous_minor="${previous_tag#*.}"
previous_minor="${previous_minor%.*}"
previous_patch="${previous_tag##*.}"
# Determine next release tag
next_major_minor="$(date +'%Y').$(date +'%-m')"
if [[ "${previous_major}.${previous_minor}" == "${next_major_minor}" ]]; then
echo "Month release already exists for year, incrementing patch number by 1"
next_patch="$((previous_patch + 1))"
else
echo "Month release does not exist for year, setting patch number to 0"
next_patch="0"
fi
# Create release
release_tag="${next_major_minor}.${next_patch}"
gh release create "${release_tag}" \
--repo="${GITHUB_REPOSITORY}" \
--title="${release_tag}" \
--generate-notes