Skip to content

Commit 9e0445d

Browse files
committed
tech: improve prerelease action
1 parent b117c18 commit 9e0445d

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

.github/workflows/prerelease.yml

+26-10
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@ name: prerelease
22

33
on:
44
# Run Every Wednesday at 01:00 AM UTC
5-
schedule:
6-
- cron: '0 2 * * 3'
5+
# schedule:
6+
# - cron: '0 2 * * 3'
77
workflow_dispatch:
88
inputs:
9-
release-as-minor:
10-
description: "Minor Release (default: Patch)"
11-
type: boolean
12-
default: false
9+
release-tag:
10+
description: "Release tag (default: Patch)"
11+
required: true
12+
type: choice
13+
default: 'patch'
14+
options:
15+
- patch
16+
- minor
17+
- major
18+
1319
skip-release:
1420
description: "Skip the tag creation step (default: false)"
1521
type: boolean
@@ -63,19 +69,22 @@ jobs:
6369
- name: Prepare Release
6470
if: steps.changes.outputs.HAS_CHANGES == 'true'
6571
env:
66-
IS_MINOR: ${{ contains(inputs.release-as-minor, 'true') }}
72+
RELEASE_TAG: ${{ inputs.release-tag }}
6773
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
6874
run: |
6975
CURRENT_VERSION_PARTS=(${CURRENT_VERSION//./ })
7076
MAJOR=${CURRENT_VERSION_PARTS[0]}
7177
MINOR=${CURRENT_VERSION_PARTS[1]}
7278
PATCH=${CURRENT_VERSION_PARTS[2]}
7379
74-
if [[ $IS_MINOR == "true" ]]
75-
then
80+
if [[ $RELEASE_TAG == "major" ]]; then
81+
MAJOR=$((MAJOR+1))
82+
MINOR=0
83+
PATCH=0
84+
elif [[ $RELEASE_TAG == "minor" ]]; then
7685
MINOR=$((MINOR+1))
7786
PATCH=0
78-
else
87+
elif [[ $RELEASE_TAG == "patch" ]]; then
7988
PATCH=$((PATCH+1))
8089
fi
8190
@@ -86,9 +95,16 @@ jobs:
8695
echo "New Version will be: $NEW_VERSION"
8796
echo "## Updating ${CURRENT_VERSION} to ${NEW_VERSION}" >> $GITHUB_STEP_SUMMARY
8897
98+
echo "## Commits that will be added to the release" >> $GITHUB_STEP_SUMMARY
99+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
100+
git log --oneline $CURRENT_VERSION...master | cat >> $GITHUB_STEP_SUMMARY
101+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
102+
103+
89104
- name: Release New Version
90105
if: ${{ success() && github.ref_name == 'master' && steps.changes.outputs.HAS_CHANGES == 'true' && !inputs.skip-release }}
91106
env:
107+
# Github actions need special tokens to be able to trigger other workflows
92108
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
93109
run: |
94110
git tag -a ${NEW_VERSION} -m "New version ${NEW_VERSION}"

0 commit comments

Comments
 (0)