1+ name : Create Release
2+
3+ on :
4+ push :
5+ branches :
6+ - master
7+
8+ jobs :
9+ create-release :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - uses : actions/checkout@v4
13+ with :
14+ fetch-depth : 0
15+
16+ - name : Get previous version
17+ id : previous_version
18+ run : |
19+ # Find the last commit that modified manifest.json
20+ LAST_VERSION_COMMIT=$(git log -1 --format=%H -- manifest.json)
21+ if [ -z "$LAST_VERSION_COMMIT" ]; then
22+ echo "No previous version found"
23+ echo "previous_version=none" >> $GITHUB_OUTPUT
24+ exit 0
25+ fi
26+
27+ # Get the version from that commit
28+ PREV_VERSION=$(git show $LAST_VERSION_COMMIT:manifest.json | jq -r .version)
29+ if [ -z "$PREV_VERSION" ]; then
30+ echo "Failed to extract previous version"
31+ exit 1
32+ fi
33+ echo "previous_version=$PREV_VERSION" >> $GITHUB_OUTPUT
34+
35+ - name : Get current version
36+ id : current_version
37+ run : |
38+ CURRENT_VERSION=$(cat manifest.json | jq -r .version)
39+ if [ -z "$CURRENT_VERSION" ]; then
40+ echo "Failed to extract current version"
41+ exit 1
42+ fi
43+ echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
44+
45+ - name : Generate Release Notes
46+ if : steps.previous_version.outputs.previous_version != steps.current_version.outputs.current_version
47+ id : release_notes
48+ run : |
49+ # Get commit messages between previous and current version
50+ COMMITS=$(git log --pretty=format:"* %s (%h)" HEAD^..HEAD | grep -v "chore: bump version" | grep -v "chore: release")
51+
52+ # Create release notes with version and commit messages
53+ RELEASE_NOTES="## What's New in v${{ steps.current_version.outputs.current_version }}
54+
55+ # ## Changes
56+ $COMMITS"
57+
58+ # Escape newlines for GitHub Actions
59+ RELEASE_NOTES="${RELEASE_NOTES//'%'/'%25'}"
60+ RELEASE_NOTES="${RELEASE_NOTES//$'\n'/'%0A'}"
61+ RELEASE_NOTES="${RELEASE_NOTES//$'\r'/'%0D'}"
62+
63+ echo "release_notes<<EOF" >> $GITHUB_OUTPUT
64+ echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT
65+ echo "EOF" >> $GITHUB_OUTPUT
66+
67+ - name : Create Release
68+ if : steps.previous_version.outputs.previous_version != steps.current_version.outputs.current_version
69+ id : create_release
70+ uses : actions/create-release@v1
71+ env :
72+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
73+ with :
74+ tag_name : v${{ steps.current_version.outputs.current_version }}
75+ release_name : Release v${{ steps.current_version.outputs.current_version }}
76+ body : ${{ steps.release_notes.outputs.release_notes }}
77+ draft : false
78+ prerelease : false
79+
80+ - name : Upload Release Asset
81+ if : steps.previous_version.outputs.previous_version != steps.current_version.outputs.current_version
82+ uses : actions/upload-release-asset@v1
83+ env :
84+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
85+ with :
86+ upload_url : ${{ steps.create_release.outputs.upload_url }}
87+ asset_path : ./manifest.json
88+ asset_name : manifest.json
89+ asset_content_type : application/json
90+
91+ - name : Create Extension Zip
92+ if : steps.previous_version.outputs.previous_version != steps.current_version.outputs.current_version
93+ run : |
94+ chmod +x create-release-zip.sh
95+ ./create-release-zip.sh || exit 1
96+
97+ - name : Upload Extension Zip
98+ if : steps.previous_version.outputs.previous_version != steps.current_version.outputs.current_version
99+ uses : actions/upload-release-asset@v1
100+ env :
101+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
102+ with :
103+ upload_url : ${{ steps.create_release.outputs.upload_url }}
104+ asset_path : ./extension.zip
105+ asset_name : ValueTime-v${{ steps.current_version.outputs.current_version }}.zip
106+ asset_content_type : application/zip
107+
108+ - name : Cleanup
109+ if : always()
110+ run : |
111+ rm -f extension.zip
0 commit comments