Add automatic release tagging workflow
- Creates date-based version tags (v2025.01.08) on push to main - Handles multiple releases per day with patch numbers (v2025.01.08.1, v2025.01.08.2) - Runs tests and build before tagging to ensure quality - Generates release notes with changelog since last tag - Includes installation instructions in release notes - Uses Forgejo-compatible actions and git configuration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
a4e0c0a528
commit
7624faaedb
1 changed files with 121 additions and 0 deletions
121
.forgejo/workflows/auto-tag.yml
Normal file
121
.forgejo/workflows/auto-tag.yml
Normal file
|
@ -0,0 +1,121 @@
|
|||
name: Auto Tag Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
auto-tag:
|
||||
runs-on: self-hosted
|
||||
name: Create Auto Tag
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: https://code.forgejo.org/actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Run tests
|
||||
run: npm test
|
||||
|
||||
- name: Build project
|
||||
run: npm run build
|
||||
|
||||
- name: Generate version tag
|
||||
id: version
|
||||
run: |
|
||||
# Get the current date in YYYY.MM.DD format
|
||||
DATE_VERSION=$(date +%Y.%m.%d)
|
||||
|
||||
# Check if a tag with today's date already exists
|
||||
if git tag -l | grep -q "^v${DATE_VERSION}$"; then
|
||||
# If it exists, add a patch number
|
||||
PATCH_NUM=$(git tag -l "v${DATE_VERSION}.*" | wc -l)
|
||||
PATCH_NUM=$((PATCH_NUM + 1))
|
||||
VERSION="v${DATE_VERSION}.${PATCH_NUM}"
|
||||
else
|
||||
VERSION="v${DATE_VERSION}"
|
||||
fi
|
||||
|
||||
echo "Generated version: $VERSION"
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Create and push tag
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
|
||||
# Configure git
|
||||
git config --local user.email "action@forgejo.org"
|
||||
git config --local user.name "Forgejo Action"
|
||||
|
||||
# Create annotated tag with commit info
|
||||
COMMIT_MSG=$(git log -1 --pretty=%B)
|
||||
git tag -a "$VERSION" -m "Release $VERSION
|
||||
|
||||
Latest changes:
|
||||
$COMMIT_MSG
|
||||
|
||||
Auto-generated on $(date)"
|
||||
|
||||
# Push the tag
|
||||
git push origin "$VERSION"
|
||||
|
||||
echo "✅ Created and pushed tag: $VERSION"
|
||||
|
||||
- name: Create release notes
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
|
||||
# Get the previous tag to generate changelog
|
||||
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
|
||||
|
||||
echo "# Release $VERSION" > RELEASE_NOTES.md
|
||||
echo "" >> RELEASE_NOTES.md
|
||||
echo "**Release Date:** $(date '+%Y-%m-%d %H:%M:%S UTC')" >> RELEASE_NOTES.md
|
||||
echo "**Commit:** ${{ github.sha }}" >> RELEASE_NOTES.md
|
||||
echo "" >> RELEASE_NOTES.md
|
||||
|
||||
if [ -n "$PREV_TAG" ]; then
|
||||
echo "## Changes since $PREV_TAG" >> RELEASE_NOTES.md
|
||||
echo "" >> RELEASE_NOTES.md
|
||||
|
||||
# Get commits since last tag
|
||||
git log $PREV_TAG..HEAD --pretty=format:"- %s" >> RELEASE_NOTES.md
|
||||
else
|
||||
echo "## Latest Changes" >> RELEASE_NOTES.md
|
||||
echo "" >> RELEASE_NOTES.md
|
||||
git log -5 --pretty=format:"- %s" >> RELEASE_NOTES.md
|
||||
fi
|
||||
|
||||
echo "" >> RELEASE_NOTES.md
|
||||
echo "" >> RELEASE_NOTES.md
|
||||
echo "## Installation" >> RELEASE_NOTES.md
|
||||
echo "" >> RELEASE_NOTES.md
|
||||
echo '```bash' >> RELEASE_NOTES.md
|
||||
echo "# Clone the repository" >> RELEASE_NOTES.md
|
||||
echo "git clone https://git.deco.sh/deco/ice.git" >> RELEASE_NOTES.md
|
||||
echo "cd ice" >> RELEASE_NOTES.md
|
||||
echo "" >> RELEASE_NOTES.md
|
||||
echo "# Checkout this release" >> RELEASE_NOTES.md
|
||||
echo "git checkout $VERSION" >> RELEASE_NOTES.md
|
||||
echo "" >> RELEASE_NOTES.md
|
||||
echo "# Install and build" >> RELEASE_NOTES.md
|
||||
echo "npm install" >> RELEASE_NOTES.md
|
||||
echo "npm run build" >> RELEASE_NOTES.md
|
||||
echo "npm start" >> RELEASE_NOTES.md
|
||||
echo '```' >> RELEASE_NOTES.md
|
||||
|
||||
echo "Release notes created:"
|
||||
cat RELEASE_NOTES.md
|
Loading…
Add table
Add a link
Reference in a new issue