Skip to content

Commit e698cb1

Browse files
committed
workflow update
1 parent fb69279 commit e698cb1

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed

.github/workflows/README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# GitHub Actions Workflows
2+
3+
This directory contains GitHub Actions workflows for automated CI/CD processes.
4+
5+
## Release Workflows
6+
7+
### `simple-release.yml` - Update Release with Changelog
8+
This workflow updates an existing release with changelog notes:
9+
10+
**Triggers:** When a tag matching `v*` is pushed
11+
12+
**What it does:**
13+
1. Finds the existing GitHub release for the tag
14+
2. Extracts changelog notes from `CHANGELOG.md`
15+
3. Updates the release description with the latest changelog content
16+
17+
## How to Use
18+
19+
### Creating/Updating a Release
20+
21+
1. **Update your CHANGELOG.md** with the new version's changes
22+
2. **Commit and push** your changes
23+
3. **Create and push a tag:**
24+
```bash
25+
git tag v0.8.1
26+
git push origin v0.8.1
27+
```
28+
4. **The workflow will automatically:**
29+
- Find the existing release for that tag
30+
- Extract the changelog section for that version
31+
- Update the release description with the latest changelog content
32+
33+
**Note:** You can push the same tag multiple times to update the release description with the latest changelog content.
34+
35+
### Changelog Format
36+
37+
The workflow expects your `CHANGELOG.md` to follow this format:
38+
```markdown
39+
# v0.8.1
40+
## Changes
41+
- New feature 1
42+
- New feature 2
43+
44+
## Fixed
45+
- Bug fix 1
46+
47+
# v0.8.0
48+
## Changes
49+
- Previous version changes...
50+
```
51+
52+
The workflow will extract everything from the version header to the next version header (or end of file).
53+
54+
## Requirements
55+
56+
- `GITHUB_TOKEN` secret (automatically provided by GitHub)
57+
- Your `CHANGELOG.md` should follow the expected format
58+
- Tags should follow semantic versioning (e.g., `v0.8.1`)
59+
- The release must already exist (you'll need to create it manually the first time)
60+
61+
## Notes
62+
63+
- The workflow automatically detects the version from the tag name
64+
- It strips the `v` prefix when looking for changelog sections
65+
- If no changelog is found for a version, it will note this in the release
66+
- This workflow updates existing releases rather than creating new ones
67+
- You can push the same tag multiple times to refresh the release content

.github/workflows/simple-release.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Update Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: 'Tag to update (e.g., v0.8.1)'
11+
required: true
12+
type: string
13+
14+
jobs:
15+
update-release:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Extract version from tag
24+
id: extract_version
25+
run: |
26+
# Handle both automatic tag pushes and manual workflow dispatch
27+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
28+
# Manual trigger - use input parameter
29+
TAG="${{ github.event.inputs.tag }}"
30+
VERSION=${TAG#v}
31+
else
32+
# Automatic trigger - extract from git tag
33+
TAG=${GITHUB_REF#refs/tags/}
34+
VERSION=${TAG#v}
35+
fi
36+
echo "version=$VERSION" >> $GITHUB_OUTPUT
37+
echo "tag=$TAG" >> $GITHUB_OUTPUT
38+
39+
- name: Extract changelog section
40+
id: changelog
41+
run: |
42+
# Find the changelog section for this version
43+
if grep -q "^# v${{ steps.extract_version.outputs.version }}$" CHANGELOG.md; then
44+
# Extract from the version header to the next version header or end of file
45+
awk '
46+
/^# v${{ steps.extract_version.outputs.version }}$/ {
47+
in_section = 1;
48+
next
49+
}
50+
/^# v[0-9]+\.[0-9]+\.[0-9]+$/ && in_section {
51+
exit
52+
}
53+
in_section {
54+
print
55+
}
56+
' CHANGELOG.md > release_body.txt
57+
58+
echo "" >> release_body.txt
59+
echo "---" >> release_body.txt
60+
echo "" >> release_body.txt
61+
echo "This release was automatically updated from tag ${{ steps.extract_version.outputs.tag }}." >> release_body.txt
62+
else
63+
echo "No changelog found for version ${{ steps.extract_version.outputs.version }}" > release_body.txt
64+
fi
65+
66+
- name: Get Release ID
67+
id: get_release
68+
run: |
69+
# Get the release ID for this tag
70+
RELEASE_ID=$(gh api repos/${{ github.repository }}/releases/tags/${{ steps.extract_version.outputs.tag }} --jq '.id')
71+
echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT
72+
env:
73+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
75+
- name: Update Release
76+
run: |
77+
# Update the existing release with new changelog content
78+
gh api repos/${{ github.repository }}/releases/${{ steps.get_release.outputs.release_id }} \
79+
--method PATCH \
80+
--field body=@release_body.txt
81+
env:
82+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)