Skip to content

Commit c9a5d4a

Browse files
authored
Refactor createReleaseV7.yaml for clarity
Refactor release workflow to improve readability and maintainability.
1 parent 81a41ab commit c9a5d4a

1 file changed

Lines changed: 33 additions & 44 deletions

File tree

.github/workflows/createReleaseV7.yaml

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
##############################
2-
# Workflow: Create Release
3-
# Version: 0.0.7
1+
##############################
2+
# Workflow: Create Release
3+
# Version: 0.0.7
44
##############################
55
name: Create Release
66

@@ -20,6 +20,7 @@ jobs:
2020
runs-on: ubuntu-latest
2121

2222
steps:
23+
# Checkout
2324
- name: Checkout repository
2425
uses: actions/checkout@v4
2526
with:
@@ -46,7 +47,8 @@ jobs:
4647
TYPE="icon"
4748
break
4849
fi
49-
if ! echo "${{ steps.ignore.outputs.ignore }}" | grep -qx "$file"; then
50+
51+
if ! grep -qx "$file" <<< "${{ steps.ignore.outputs.ignore }}"; then
5052
TYPE="normal"
5153
fi
5254
done
@@ -68,68 +70,55 @@ jobs:
6870
if: steps.classify.outputs.type != 'ignored'
6971
run: |
7072
LATEST=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
71-
72-
TYPE="${{ steps.classify.outputs.type }}"
73-
74-
if [[ "$TYPE" == "icon" ]]; then
75-
MAJOR=$(echo $LATEST | cut -d. -f1 | tr -d 'v')
76-
MINOR=$(echo $LATEST | cut -d. -f2)
77-
PATCH=$(echo $LATEST | cut -d. -f3)
73+
74+
MAJOR=$(echo $LATEST | cut -d. -f1 | tr -d 'v')
75+
MINOR=$(echo $LATEST | cut -d. -f2)
76+
PATCH=$(echo $LATEST | cut -d. -f3)
77+
78+
if [ "${{ steps.classify.outputs.type }}" == "icon" ]; then
7879
PATCH=$((PATCH + 1))
7980
VERSION="v$MAJOR.$MINOR.$PATCH"
80-
81-
elif [[ -n "${{ inputs.version }}" ]]; then
81+
82+
elif [ -n "${{ inputs.version }}" ]; then
8283
VERSION="${{ inputs.version }}"
83-
84-
elif [[ "$TYPE" == "normal" && "${{ steps.changelog.outputs.changed }}" == "true" ]]; then
84+
85+
elif [ "${{ steps.changelog.outputs.changed }}" == "true" ]; then
8586
VERSION=$(grep -oP '^## \[\K[^]]+' CHANGELOG.md | head -n 1)
8687
if [ -z "$VERSION" ]; then
8788
echo "No versions found in CHANGELOG.md."
8889
exit 1
8990
fi
90-
9191
else
92-
# fallback patch bump
93-
MAJOR=$(echo $LATEST | cut -d. -f1 | tr -d 'v')
94-
MINOR=$(echo $LATEST | cut -d. -f2)
95-
PATCH=$(echo $LATEST | cut -d. -f3)
9692
PATCH=$((PATCH + 1))
9793
VERSION="v$MAJOR.$MINOR.$PATCH"
9894
fi
9995
10096
[[ "$VERSION" != v* ]] && VERSION="v$VERSION"
97+
10198
echo "VERSION=$VERSION" >> $GITHUB_ENV
10299
echo "VERSION_NO_V=${VERSION#v}" >> $GITHUB_ENV
103100
104-
# Extract Release Notes for normal changes
105-
- name: Extract Release Notes from CHANGELOG.md
106-
if: steps.classify.outputs.type == 'normal' && steps.changelog.outputs.changed == 'true' && inputs.version == ''
101+
# Release Notes
102+
- name: Extract Release Notes
107103
run: |
108-
awk '/## \['"${VERSION_NO_V}"'\]/{flag=1; next} /## \[/{flag=0} flag' CHANGELOG.md > release_notes.txt
109-
if [ ! -s release_notes.txt ]; then
110-
echo "No release notes found for version ${VERSION_NO_V}."
111-
exit 1
112-
fi
104+
if [ "${{ steps.classify.outputs.type }}" == "icon" ]; then
105+
echo "Updated connector icon." > release_notes.txt
113106
114-
# Default Release Notes (manual version input)
115-
- name: Default Release Notes
116-
if: steps.classify.outputs.type == 'normal' && inputs.version != ''
117-
run: |
118-
echo "Release notes not provided for version ${VERSION}." > release_notes.txt
107+
elif [ "${{ steps.classify.outputs.type }}" == "normal" ] && [ "${{ steps.changelog.outputs.changed }}" == "true" ] && [ -z "${{ inputs.version }}" ]; then
108+
awk '/## \['"${VERSION_NO_V}"'\]/{flag=1; next} /## \[/{flag=0} flag' CHANGELOG.md > release_notes.txt
109+
if [ ! -s release_notes.txt ]; then
110+
echo "No release notes found for version ${VERSION_NO_V}."
111+
exit 1
112+
fi
119113
120-
# Icon Release Notes
121-
- name: Icon Release Notes
122-
if: steps.classify.outputs.type == 'icon'
123-
run: |
124-
echo "Updated connector icon." > release_notes.txt
114+
elif [ -n "${{ inputs.version }}" ]; then
115+
echo "Release notes not provided for version ${VERSION}." > release_notes.txt
125116
126-
# Fallback Release Notes (if nothing else)
127-
- name: Fallback Release Notes
128-
if: steps.classify.outputs.type != 'ignored' && [ ! -f release_notes.txt ]
129-
run: |
130-
echo "Auto-generated release for ${VERSION}" > release_notes.txt
117+
else
118+
echo "Auto-generated release for ${VERSION}" > release_notes.txt
119+
fi
131120
132-
# Create GitHub Release
121+
# Create Release
133122
- name: Create GitHub Release
134123
if: steps.classify.outputs.type != 'ignored'
135124
run: |

0 commit comments

Comments
 (0)