Skip to content

Commit 81a41ab

Browse files
authored
Update workflow to version 0.0.7
1 parent 678e1e0 commit 81a41ab

2 files changed

Lines changed: 140 additions & 82 deletions

File tree

.github/workflows/createReleaseV6.yaml

Lines changed: 0 additions & 82 deletions
This file was deleted.
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
##############################
2+
# Workflow: Create Release
3+
# Version: 0.0.7
4+
##############################
5+
name: Create Release
6+
7+
on:
8+
workflow_call:
9+
inputs:
10+
version:
11+
description: 'Version number (e.g., v1.0.0). Leave blank to use the latest version from CHANGELOG.md.'
12+
required: false
13+
type: string
14+
15+
permissions:
16+
contents: write
17+
18+
jobs:
19+
create-release:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 2
27+
28+
# Load ignore list
29+
- name: Load ignore list
30+
id: ignore
31+
run: |
32+
IGNORE_FILES=$(cat .github/config/ignoreFiles.json | jq -r '.[]')
33+
echo "ignore<<EOF" >> $GITHUB_OUTPUT
34+
echo "$IGNORE_FILES" >> $GITHUB_OUTPUT
35+
echo "EOF" >> $GITHUB_OUTPUT
36+
37+
# Classify change
38+
- name: Classify change
39+
id: classify
40+
run: |
41+
CHANGED=$(git diff --name-only HEAD^ HEAD)
42+
TYPE="ignored"
43+
44+
for file in $CHANGED; do
45+
if [[ "$file" == "Icon.png" ]]; then
46+
TYPE="icon"
47+
break
48+
fi
49+
if ! echo "${{ steps.ignore.outputs.ignore }}" | grep -qx "$file"; then
50+
TYPE="normal"
51+
fi
52+
done
53+
54+
echo "type=$TYPE" >> $GITHUB_OUTPUT
55+
56+
# Check if CHANGELOG changed
57+
- name: Check if CHANGELOG changed
58+
id: changelog
59+
run: |
60+
if git diff --name-only HEAD^ HEAD | grep -q "CHANGELOG.md"; then
61+
echo "changed=true" >> $GITHUB_OUTPUT
62+
else
63+
echo "changed=false" >> $GITHUB_OUTPUT
64+
fi
65+
66+
# Determine Version
67+
- name: Determine Version
68+
if: steps.classify.outputs.type != 'ignored'
69+
run: |
70+
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)
78+
PATCH=$((PATCH + 1))
79+
VERSION="v$MAJOR.$MINOR.$PATCH"
80+
81+
elif [[ -n "${{ inputs.version }}" ]]; then
82+
VERSION="${{ inputs.version }}"
83+
84+
elif [[ "$TYPE" == "normal" && "${{ steps.changelog.outputs.changed }}" == "true" ]]; then
85+
VERSION=$(grep -oP '^## \[\K[^]]+' CHANGELOG.md | head -n 1)
86+
if [ -z "$VERSION" ]; then
87+
echo "No versions found in CHANGELOG.md."
88+
exit 1
89+
fi
90+
91+
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)
96+
PATCH=$((PATCH + 1))
97+
VERSION="v$MAJOR.$MINOR.$PATCH"
98+
fi
99+
100+
[[ "$VERSION" != v* ]] && VERSION="v$VERSION"
101+
echo "VERSION=$VERSION" >> $GITHUB_ENV
102+
echo "VERSION_NO_V=${VERSION#v}" >> $GITHUB_ENV
103+
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 == ''
107+
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
113+
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
119+
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
125+
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
131+
132+
# Create GitHub Release
133+
- name: Create GitHub Release
134+
if: steps.classify.outputs.type != 'ignored'
135+
run: |
136+
gh release create "${VERSION}" \
137+
--title "${VERSION}" \
138+
--notes-file release_notes.txt
139+
env:
140+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)