-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (72 loc) · 2.63 KB
/
Copy pathrelease.yml
File metadata and controls
89 lines (72 loc) · 2.63 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
name: Release
on:
push:
branches: [main]
permissions:
contents: write
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
# Only run on direct pushes to main (merges), not on tags
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for changelog
- name: Get version from package.json
id: pkg
run: echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
- name: Generate release tag
id: tag
run: |
# Get current date in YYYY.MM.DD format
DATE=$(date +'%Y.%m.%d')
# Count existing releases today for suffix
EXISTING=$(git tag -l "v${DATE}*" | wc -l | tr -d ' ')
if [ "$EXISTING" -eq "0" ]; then
TAG="v${DATE}"
else
TAG="v${DATE}.${EXISTING}"
fi
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "Generated tag: ${TAG}"
- name: Generate changelog
id: changelog
run: |
# Get the previous tag
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
# First release - get all commits
CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges -20)
else
# Get commits since last tag
CHANGELOG=$(git log ${PREV_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges)
fi
# Handle multi-line output for GitHub Actions
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag }}
name: Release ${{ steps.tag.outputs.tag }}
body: |
## AutoDev Release ${{ steps.tag.outputs.tag }}
**Package Version:** ${{ steps.pkg.outputs.version }}
### Changes
${{ steps.changelog.outputs.changelog }}
---
*Automatically generated on merge to main*
draft: false
prerelease: false
generate_release_notes: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Summary
run: |
echo "### Release Created! :rocket:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Tag:** ${{ steps.tag.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "**Version:** ${{ steps.pkg.outputs.version }}" >> $GITHUB_STEP_SUMMARY