Skip to content

Commit a96cfec

Browse files
committed
Add GitHub Actions workflow for automatic releases
Automatically builds and releases the plugin JAR whenever code is merged to main. Skips releases if the version already exists to avoid duplicates.
1 parent 1bae153 commit a96cfec

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- '**.md'
9+
- '.gitignore'
10+
11+
jobs:
12+
build-and-release:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up JDK 11
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: '11'
23+
distribution: 'temurin'
24+
25+
- name: Grant execute permission for gradlew
26+
run: chmod +x gradlew
27+
28+
- name: Build with Gradle
29+
run: ./gradlew clean jar
30+
31+
- name: Get version from build.gradle
32+
id: get_version
33+
run: |
34+
VERSION=$(grep "^version = " build.gradle | cut -d "'" -f 2)
35+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
36+
echo "Building version $VERSION"
37+
38+
- name: Check if release exists
39+
id: check_release
40+
run: |
41+
RELEASE_EXISTS=$(gh release view "v${{ steps.get_version.outputs.VERSION }}" > /dev/null 2>&1 && echo "true" || echo "false")
42+
echo "EXISTS=$RELEASE_EXISTS" >> $GITHUB_OUTPUT
43+
env:
44+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Create GitHub Release
47+
if: steps.check_release.outputs.EXISTS == 'false'
48+
uses: softprops/action-gh-release@v1
49+
with:
50+
tag_name: v${{ steps.get_version.outputs.VERSION }}
51+
name: Release ${{ steps.get_version.outputs.VERSION }}
52+
body: |
53+
## Google Analytics Plugin v${{ steps.get_version.outputs.VERSION }}
54+
55+
### Installation
56+
1. Download `google-analytics-${{ steps.get_version.outputs.VERSION }}.jar`
57+
2. Upload to dotCMS via System → Dynamic Plugins
58+
3. Configure via System → Apps → Google Analytics
59+
60+
### What's Changed
61+
See commit history for details.
62+
63+
**Full Changelog**: https://github.com/${{ github.repository }}/commits/v${{ steps.get_version.outputs.VERSION }}
64+
files: |
65+
build/libs/google-analytics-*.jar
66+
draft: false
67+
prerelease: false
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)