Skip to content

Commit 4d3a199

Browse files
committed
ci:added pipelines to release and bump
1 parent a1f0c12 commit 4d3a199

2 files changed

Lines changed: 122 additions & 0 deletions

File tree

.github/workflows/bumpversion.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Bump Version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
bumpPart:
7+
description: 'Bump part (major, minor or patch)'
8+
required: true
9+
default: "minor"
10+
11+
jobs:
12+
bump:
13+
name: Bump App Version
14+
runs-on: ubuntu-latest
15+
# Sanity check on the input
16+
if: contains(['major', 'minor', 'patch'], ${{ github.event.inputs.bumpPart }})
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Bump version
20+
id: bumpversion
21+
uses: jasonamyers/github-bumpversion-action@v1.0.5
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
DEFAULT_BUMP: ${{ github.event.inputs.bumpPart }}
25+
- name: Push
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
run: |
29+
remote_repo="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
30+
git push "$remote_repo" HEAD:"${GITHUB_REF#refs/heads/}"

.github/workflows/release.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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

Comments
 (0)