-
Notifications
You must be signed in to change notification settings - Fork 1
96 lines (80 loc) · 3.25 KB
/
Copy pathrelease.yml
File metadata and controls
96 lines (80 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Create Release
on:
push:
tags:
- 'v*.*.*' # Triggers on version tags like v1.0.0, v0.2.1, etc.
permissions:
contents: write
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for changelog generation
- name: Extract version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Verify version consistency
env:
EXPECTED_VERSION: ${{ steps.version.outputs.version }}
run: |
# Check frontend package.json
FRONTEND_VERSION=$(grep -o '"version": *"[^"]*"' ushadow/frontend/package.json | head -1 | sed 's/"version": *"\(.*\)"/\1/')
echo "Frontend version: $FRONTEND_VERSION"
# Check backend pyproject.toml
BACKEND_VERSION=$(grep '^version = ' ushadow/backend/pyproject.toml | sed 's/version = "\(.*\)"/\1/')
echo "Backend version: $BACKEND_VERSION"
# Verify all versions match the tag
if [ "$FRONTEND_VERSION" != "$EXPECTED_VERSION" ]; then
echo "❌ Frontend version ($FRONTEND_VERSION) doesn't match tag ($EXPECTED_VERSION)"
exit 1
fi
if [ "$BACKEND_VERSION" != "$EXPECTED_VERSION" ]; then
echo "❌ Backend version ($BACKEND_VERSION) doesn't match tag ($EXPECTED_VERSION)"
exit 1
fi
echo "✅ All versions match tag v$EXPECTED_VERSION"
- name: Generate changelog
id: changelog
env:
TAG_REF: ${{ github.ref }}
run: |
# Get the previous tag
PREVIOUS_TAG=$(git describe --abbrev=0 --tags ${TAG_REF}^ 2>/dev/null || echo "")
if [ -z "$PREVIOUS_TAG" ]; then
echo "First release - no previous tag found"
CHANGELOG="Initial release of Ushadow v${{ steps.version.outputs.version }}"
else
echo "Generating changelog from $PREVIOUS_TAG to ${TAG_REF#refs/tags/}"
# Generate changelog from commits
CHANGELOG=$(git log $PREVIOUS_TAG..HEAD --pretty=format:"- %s (%h)" --no-merges)
# If no commits found, use a default message
if [ -z "$CHANGELOG" ]; then
CHANGELOG="Version bump to v${{ steps.version.outputs.version }}"
fi
fi
# Save changelog to file for the release
echo "$CHANGELOG" > CHANGELOG.txt
cat CHANGELOG.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
name: Ushadow v${{ steps.version.outputs.version }}
body_path: CHANGELOG.txt
draft: false
prerelease: ${{ contains(steps.version.outputs.version, '-') }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release summary
env:
VERSION: ${{ steps.version.outputs.version }}
REPO: ${{ github.repository }}
run: |
echo "🎉 Successfully created release v$VERSION"
echo "Release URL: https://github.com/$REPO/releases/tag/v$VERSION"