1+ name : Release from Changelog
2+
3+ on :
4+ push :
5+ paths :
6+ - " CHANGELOG.md"
7+ branches :
8+ - master
9+
10+ # Grants permission to create releases
11+ permissions :
12+ contents : write
13+
14+ jobs :
15+ build :
16+ name : Bundle the App
17+ runs-on : ubuntu-latest
18+ outputs :
19+ ta_version : ${{ steps.app.outputs.version }}
20+ steps :
21+ - uses : actions/checkout@v4
22+ - name : Get App Info
23+ id : app
24+ run : |
25+ MANIFEST="splunk*/app.manifest"
26+ if [ -f "$MANIFEST" ]; then
27+ app_id=$(cat "$MANIFEST" | jq -r '.info.id.name')
28+ app_version=$(cat "$MANIFEST" | jq -r '.info.id.version')
29+ echo "name=${app_id}" >> $GITHUB_OUTPUT
30+ echo "version=${app_version}" >> $GITHUB_OUTPUT
31+ else
32+ echo "Files Not Found ❌ Please add 'packages/$MANIFEST'"
33+ exit 1
34+ fi
35+ working-directory : ./packages
36+
37+ - name : Bundle app source
38+ env :
39+ APP_NAME : ${{ steps.app.outputs.name }}
40+ APP_VERSION : ${{ steps.app.outputs.version }}
41+ run : |
42+ # Exclude images from README file
43+ sed -i '/^!/d' README.md
44+ cp README.md packages/$APP_NAME
45+ tar -C packages -zcvf $APP_NAME-$APP_VERSION.tar.gz $APP_NAME/
46+
47+ - uses : actions/upload-artifact@v4
48+ with :
49+ name : packaged_app
50+ path : ${{ steps.app.outputs.name }}*.tar.gz
51+
52+ release :
53+ name : Upload Release
54+ runs-on : ubuntu-latest
55+ needs : build
56+ steps :
57+ - uses : actions/checkout@v4
58+ - uses : actions/download-artifact@v4
59+ with :
60+ name : packaged_app
61+ path : dist
62+ - name : Fetch latest release info from CHANGELOG
63+ id : changelog
64+ uses : release-flow/keep-a-changelog-action@v3
65+ with :
66+ command : query
67+ version : latest
68+ - name : Validate version consistency
69+ env :
70+ VERSION : ${{ steps.changelog.outputs.version }}
71+ TA_VERSION : ${{ needs.build.outputs.ta_version }}
72+ run : |
73+ if [ "$VERSION" != "$TA_VERSION" ]; then
74+ echo "❌ Add-On and Changelog version mismatch. Did you forget to bump the Add-On version?"
75+ exit 1
76+ fi
77+ - name : Create GitHub release
78+ env :
79+ VERSION : v${{ steps.changelog.outputs.version }}
80+ RELEASE_NOTES : ${{ steps.changelog.outputs.release-notes }}
81+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
82+ run : |
83+ LATEST_RELEASE=$(gh release view --json tagName --jq '.tagName')
84+ if [ "$VERSION" == "$LATEST_RELEASE" ]; then
85+ echo "Versions match nothing to do!"
86+ else
87+ echo "Releasing $VERSION"
88+ gh release create $VERSION \
89+ --title "$VERSION" \
90+ --notes "$RELEASE_NOTES" \
91+ dist/*.tar.gz
92+ fi
0 commit comments