Skip to content

Commit eec265b

Browse files
committed
ci: add GitHub workflows for auto-versioning and dynamic badge updates
1 parent 383f556 commit eec265b

2 files changed

Lines changed: 31 additions & 41 deletions

File tree

.github/workflows/auto-version-and-release.yml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,34 +163,36 @@ jobs:
163163
fi
164164
165165
# Create changelog entry
166-
cat > changelog_temp.md << EOF
167-
## [$NEW_VERSION] - $DATE
166+
echo 'release_notes<<EOF' >> $GITHUB_OUTPUT
167+
echo "## [$NEW_VERSION] - $DATE" >> $GITHUB_OUTPUT
168+
echo "" >> $GITHUB_OUTPUT
169+
echo "### Changes" >> $GITHUB_OUTPUT
170+
echo "$COMMITS" >> $GITHUB_OUTPUT
171+
echo "" >> $GITHUB_OUTPUT
172+
echo 'EOF' >> $GITHUB_OUTPUT
173+
174+
# Store in variable for file operations
175+
CHANGELOG_ENTRY="## [$NEW_VERSION] - $DATE
168176
169177
### Changes
170178
$COMMITS
171179

172-
EOF
173-
CHANGELOG_ENTRY=$(cat changelog_temp.md)
174-
rm changelog_temp.md
180+
"
175181
176182
# Update CHANGELOG.md
177183
if [ -f "$CHANGELOG_FILE" ]; then
178-
# Insert new entry after the first line (assuming it's a header)
179-
sed -i "1a\\
180-
$CHANGELOG_ENTRY" $CHANGELOG_FILE
184+
# Prepend new entry to existing changelog
185+
echo -e "$CHANGELOG_ENTRY\n$(cat $CHANGELOG_FILE)" > $CHANGELOG_FILE
181186
else
182-
# Create new changelog
187+
# Create new changelog file
183188
echo "# Changelog
184189

185190
All notable changes to this project will be documented in this file.
186191

187192
$CHANGELOG_ENTRY" > $CHANGELOG_FILE
188193
fi
189194

190-
# Output release notes
191-
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
192-
echo "$CHANGELOG_ENTRY" >> $GITHUB_OUTPUT
193-
echo "EOF" >> $GITHUB_OUTPUT
195+
echo "Updated CHANGELOG.md"
194196

195197
- name: Update README version badge
196198
run: |

.github/workflows/update-badges.yml

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -102,36 +102,24 @@ jobs:
102102
echo "downloads_badge=$DOWNLOADS_BADGE" >> $GITHUB_OUTPUT
103103
echo "issues_badge=$ISSUES_BADGE" >> $GITHUB_OUTPUT
104104
105+
- name: Create badges markdown
106+
run: |
107+
# Create badges.md file with proper GitHub Actions syntax
108+
echo "# Repository Badges" > badges.md
109+
echo "" >> badges.md
110+
echo "[![Version](${{ steps.badges.outputs.version_badge }})](https://github.com/${{ github.repository }}/releases)" >> badges.md
111+
echo "[![Repository Size](${{ steps.badges.outputs.size_badge }})](https://github.com/${{ github.repository }})" >> badges.md
112+
echo "[![Lines of Code](${{ steps.badges.outputs.lines_badge }})](https://github.com/${{ github.repository }})" >> badges.md
113+
echo "[![Last Commit](${{ steps.badges.outputs.last_commit_badge }})](https://github.com/${{ github.repository }}/commits)" >> badges.md
114+
echo "[![License](https://img.shields.io/github/license/${{ github.repository }}?style=flat-square&color=blue)](LICENSE)" >> badges.md
115+
echo "[![Stars](https://img.shields.io/github/stars/${{ github.repository }}?style=flat-square&color=yellow)](https://github.com/${{ github.repository }}/stargazers)" >> badges.md
116+
echo "[![Forks](https://img.shields.io/github/forks/${{ github.repository }}?style=flat-square&color=green)](https://github.com/${{ github.repository }}/network/members)" >> badges.md
117+
echo "[![Issues](https://img.shields.io/github/issues/${{ github.repository }}?style=flat-square&color=red)](https://github.com/${{ github.repository }}/issues)" >> badges.md
118+
echo "" >> badges.md
119+
echo "**Current Version: ${{ steps.stats.outputs.version }}**" >> badges.md
120+
105121
- name: Update README badges
106122
run: |
107-
# Create badge section for README
108-
VERSION_BADGE="${{ steps.badges.outputs.version_badge }}"
109-
LICENSE_BADGE="${{ steps.badges.outputs.license_badge }}"
110-
SHELL_BADGE="${{ steps.badges.outputs.shell_badge }}"
111-
DOCKER_BADGE="${{ steps.badges.outputs.docker_badge }}"
112-
SIZE_BADGE="${{ steps.badges.outputs.size_badge }}"
113-
LINES_BADGE="${{ steps.badges.outputs.lines_badge }}"
114-
STATUS_BADGE="${{ steps.badges.outputs.status_badge }}"
115-
LAST_COMMIT_BADGE="${{ steps.badges.outputs.last_commit_badge }}"
116-
RELEASE_BADGE="${{ steps.badges.outputs.release_badge }}"
117-
DOWNLOADS_BADGE="${{ steps.badges.outputs.downloads_badge }}"
118-
ISSUES_BADGE="${{ steps.badges.outputs.issues_badge }}"
119-
REPO="${{ github.repository }}"
120-
121-
cat > badges.md << EOF
122-
[![Version](${VERSION_BADGE})](${RELEASE_BADGE})
123-
[![License](${LICENSE_BADGE})](https://opensource.org/licenses/MIT)
124-
[![Shell Requirement](${SHELL_BADGE})](https://www.gnu.org/software/bash/)
125-
[![Docker Compatible](${DOCKER_BADGE})](https://www.docker.com/)
126-
[![Script Size](${SIZE_BADGE})]()
127-
[![Lines of Code](${LINES_BADGE})]()
128-
[![Status](${STATUS_BADGE})]()
129-
[![Last Commit](${LAST_COMMIT_BADGE})](https://github.com/${REPO}/commits/main)
130-
[![GitHub Release](${RELEASE_BADGE})](https://github.com/${REPO}/releases/latest)
131-
[![Downloads](${DOWNLOADS_BADGE})](https://github.com/${REPO}/releases)
132-
[![Issues](${ISSUES_BADGE})](https://github.com/${REPO}/issues)
133-
EOF
134-
135123
# Update README with new badges
136124
if grep -q "^\[\!\[Version\]" readme.md; then
137125
# Replace existing badges section

0 commit comments

Comments
 (0)