Skip to content

Commit 26cad2f

Browse files
committed
wip
1 parent 4252154 commit 26cad2f

File tree

2 files changed

+187
-1
lines changed

2 files changed

+187
-1
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release
1+
name: Apps release
22
on:
33
push:
44
tags:
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
name: Github Release
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
tag:
6+
description: "Release tag (e.g., v1.2.3)"
7+
required: true
8+
type: string
9+
10+
permissions:
11+
contents: write
12+
id-token: write
13+
14+
jobs:
15+
create-draft-release:
16+
name: Create Draft Release
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Validate semver tag
20+
run: |
21+
TAG="${{ github.event.inputs.tag }}"
22+
23+
# Check if tag matches semver pattern (v followed by MAJOR.MINOR.PATCH with optional pre-release and build metadata)
24+
# Supports: v1.2.3, v1.2.3-rc.4, v1.2.3-beta.1, v1.2.3-alpha.1+build.123
25+
if ! echo "$TAG" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$'; then
26+
echo "::error::Invalid tag format: $TAG"
27+
echo "::error::Tag must be in semver format: v<MAJOR>.<MINOR>.<PATCH>[-PRERELEASE][+BUILD]"
28+
echo "::error::Examples: v1.2.3, v1.2.3-rc.4, v1.2.3-beta.1, v1.2.3-alpha.1+build.123"
29+
exit 1
30+
fi
31+
32+
echo "::notice::Tag validation passed: $TAG"
33+
34+
- name: Checkout code
35+
uses: actions/checkout@v6
36+
with:
37+
fetch-depth: 0
38+
39+
- name: Extract version from tag
40+
id: extract-version
41+
run: |
42+
TAG="${{ github.event.inputs.tag }}"
43+
VERSION="${TAG#v}"
44+
echo "tag=$TAG" >> $GITHUB_OUTPUT
45+
echo "version=$VERSION" >> $GITHUB_OUTPUT
46+
echo "::notice::Tag: $TAG"
47+
echo "::notice::Version: $VERSION"
48+
49+
- name: Find previous tag
50+
id: prev-tag
51+
run: |
52+
TAG="${{ steps.extract-version.outputs.tag }}"
53+
PREV_TAG=$(git tag -l "v*.*.*" --sort=-version:refname | grep -v "^${TAG}$" | head -n1)
54+
55+
if [ -z "$PREV_TAG" ]; then
56+
echo "::notice::No previous tag found, using initial commit"
57+
PREV_TAG=$(git rev-list --max-parents=0 HEAD)
58+
fi
59+
60+
echo "prev-tag=$PREV_TAG" >> $GITHUB_OUTPUT
61+
echo "::notice::Previous tag: $PREV_TAG"
62+
63+
- name: Get list of Docker images
64+
id: get-images
65+
run: |
66+
# Find all apps with Dockerfiles
67+
IMAGES=""
68+
for app_dir in apps/*/; do
69+
if [ -f "${app_dir}Dockerfile" ]; then
70+
APP_NAME=$(basename "$app_dir")
71+
IMAGE_NAME="ev-node-${APP_NAME}"
72+
IMAGES="${IMAGES}ghcr.io/${{ github.repository_owner }}/${IMAGE_NAME}:${{ steps.extract-version.outputs.tag }}\n"
73+
fi
74+
done
75+
76+
# Remove trailing newline
77+
IMAGES=$(echo -e "$IMAGES" | sed '/^$/d')
78+
79+
# Escape for GitHub Actions output
80+
IMAGES="${IMAGES//'%'/'%25'}"
81+
IMAGES="${IMAGES//$'\n'/'%0A'}"
82+
IMAGES="${IMAGES//$'\r'/'%0D'}"
83+
84+
echo "images=$IMAGES" >> $GITHUB_OUTPUT
85+
echo "::notice::Found Docker images"
86+
87+
- name: Generate changelog prompt
88+
id: changelog-prompt
89+
run: |
90+
PREV_TAG="${{ steps.prev-tag.outputs.prev-tag }}"
91+
TAG="${{ steps.extract-version.outputs.tag }}"
92+
VERSION="${{ steps.extract-version.outputs.version }}"
93+
94+
cat > claude-prompt.txt << 'EOF_PROMPT'
95+
Read the file CHANGELOG.md and find the section for version $VERSION (tag $TAG).
96+
97+
Generate professional release notes for GitHub based on the changes listed for this specific version.
98+
99+
Create release notes with the following structure:
100+
101+
ev-node VERSION
102+
103+
⚠️ This is a draft release. Please verify its content before publishing
104+
105+
[Brief summary paragraph about this release - what type of release it is (feature/bugfix/maintenance), upgrade recommendations]
106+
107+
**Tested upgrade paths**
108+
- [List version upgrade paths that were tested, or state "TBD - to be tested before publishing"]
109+
110+
**Changelog**
111+
112+
**Added**
113+
- BREAKING: [Feature description with context about what users need to do]
114+
- [Other new features]
115+
116+
**Changed**
117+
- BREAKING: [Change description with migration instructions]
118+
- [Other changes]
119+
120+
**Removed**
121+
- BREAKING: [Removed feature with alternatives or migration path]
122+
- [Other removals]
123+
124+
**Fixed**
125+
- [Bug fixes]
126+
127+
**Images**
128+
EOF_PROMPT
129+
130+
# Replace placeholders with actual values
131+
sed -i "s/\$VERSION/${VERSION}/g" claude-prompt.txt
132+
sed -i "s/\$TAG/${TAG}/g" claude-prompt.txt
133+
134+
# Add the images list
135+
echo "${{ steps.get-images.outputs.images }}" | while IFS= read -r image; do
136+
echo "- $image" >> claude-prompt.txt
137+
done
138+
139+
cat >> claude-prompt.txt << 'EOF_PROMPT'
140+
141+
Guidelines:
142+
- Replace VERSION with the actual version number
143+
- Replace YYYY-MM-DD with the actual release date
144+
- Focus on BREAKING changes - clearly mark them and explain what users need to do
145+
- For breaking changes, include specific migration steps or configuration changes needed
146+
- Use clear, professional language
147+
- Include technical details and PR numbers if available in the changelog
148+
- Group related changes together
149+
- Omit empty sections
150+
- Format as clean markdown
151+
152+
Output the release notes as your response.
153+
EOF_PROMPT
154+
155+
{
156+
echo 'prompt<<EOF_CLAUDE_PROMPT'
157+
cat claude-prompt.txt
158+
echo EOF_CLAUDE_PROMPT
159+
} >> $GITHUB_OUTPUT
160+
161+
- name: Generate release notes with Claude
162+
id: claude-release
163+
uses: anthropics/claude-code-action@v1
164+
with:
165+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
166+
prompt: ${{ steps.changelog-prompt.outputs.prompt }}
167+
trusted_bots: "*"
168+
allowed_tools: "Read(CHANGELOG.md)"
169+
claude_args: |
170+
--json-schema '{"type":"object","properties":{"release_notes":{"type":"string"},"release_date":{"type":"string","description":"Release date in YYYY-MM-DD format"}},"required":["release_notes","release_date"]}'
171+
172+
- name: Create Draft GitHub Release
173+
id: create-release
174+
uses: softprops/action-gh-release@v2
175+
with:
176+
draft: true
177+
name: ${{ steps.extract-version.outputs.tag }} (${{ fromJSON(steps.claude-release.outputs.structured_output).release_date }})
178+
tag_name: ${{ steps.extract-version.outputs.tag }}
179+
body: ${{ fromJSON(steps.claude-release.outputs.structured_output).release_notes }}
180+
env:
181+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
182+
183+
- name: Output release URL
184+
run: |
185+
RELEASE_URL="https://github.com/${{ github.repository }}/releases/tag/${{ steps.extract-version.outputs.tag }}"
186+
echo "::notice::Draft release created: $RELEASE_URL"

0 commit comments

Comments
 (0)