1- name : Create Release
1+ name : Build and Release
22
33on :
44 push :
5- branches :
6- - main
7- - master
5+ branches : [ main, master ]
6+ paths-ignore :
7+ - ' **.md'
8+ - ' .gitignore'
9+ - ' LICENSE'
10+ pull_request :
11+ branches : [ main, master ]
12+ paths-ignore :
13+ - ' **.md'
14+ - ' .gitignore'
15+ - ' LICENSE'
816 workflow_dispatch :
917
1018jobs :
11- release :
19+ build :
1220 runs-on : ubuntu-latest
1321 permissions :
1422 contents : write
15-
23+ packages : write
24+
1625 steps :
1726 - name : Checkout code
1827 uses : actions/checkout@v4
1928 with :
2029 fetch-depth : 0
2130
22- - name : Validate Gradle Wrapper
23- uses : gradle/actions/wrapper-validation@v3
24-
2531 - name : Set up JDK 21
2632 uses : actions/setup-java@v4
2733 with :
2834 java-version : ' 21'
2935 distribution : ' temurin'
36+ cache : gradle
37+
38+ - name : Validate Gradle wrapper
39+ uses : gradle/wrapper-validation-action@v2
3040
3141 - name : Setup Gradle
3242 uses : gradle/actions/setup-gradle@v3
3343
34- - name : Make gradlew executable
35- run : |
36- chmod +x gradlew
37- git update-index --chmod=+x gradlew
44+ - name : Make Gradle wrapper executable
45+ run : chmod +x ./gradlew
3846
39- - name : Extract version from build.gradle
40- id : get_version
47+ - name : Extract version
48+ id : extract_version
4149 run : |
4250 VERSION=$(grep "^version = " build.gradle | sed "s/version = '\(.*\)'/\1/")
51+ echo "VERSION=$VERSION" >> $GITHUB_ENV
4352 echo "version=$VERSION" >> $GITHUB_OUTPUT
44- echo "Extracted version: $VERSION"
53+ COMMIT_SHA_SHORT=$(git rev-parse --short HEAD)
54+ echo "COMMIT_SHA_SHORT=$COMMIT_SHA_SHORT" >> $GITHUB_ENV
55+ echo "Version: $VERSION (Commit: $COMMIT_SHA_SHORT)"
4556
4657 - name : Check if tag exists
4758 id : check_tag
4859 run : |
49- if git rev-parse "v${{ steps.get_version.outputs.version }}" >/dev/null 2>&1; then
60+ if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then
5061 echo "exists=true" >> $GITHUB_OUTPUT
51- echo "Tag v${{ steps.get_version.outputs.version }} already exists"
62+ echo "Tag v${{ env.VERSION }} already exists"
5263 else
5364 echo "exists=false" >> $GITHUB_OUTPUT
54- echo "Tag v${{ steps.get_version.outputs.version }} does not exist"
65+ echo "Tag v${{ env.VERSION }} does not exist"
5566 fi
5667
5768 - name : Build with Gradle
58- if : steps.check_tag.outputs.exists == 'false'
59- run : ./gradlew clean build
69+ run : ./gradlew clean build --no-daemon
70+
71+ - name : Run tests
72+ run : ./gradlew test --no-daemon
73+
74+ - name : Upload build artifacts
75+ uses : actions/upload-artifact@v4
76+ with :
77+ name : PluginLangCore-${{ env.VERSION }}-build-${{ env.COMMIT_SHA_SHORT }}
78+ path : build/libs/*.jar
79+ retention-days : 90
80+
81+ - name : Upload test reports on failure
82+ if : failure()
83+ uses : actions/upload-artifact@v4
84+ with :
85+ name : test-reports-${{ env.COMMIT_SHA_SHORT }}
86+ path : build/reports/tests/
87+ retention-days : 7
6088
6189 - name : Create Git Tag
62- if : steps.check_tag.outputs.exists == 'false'
90+ if : github.event_name == 'push' && steps.check_tag.outputs.exists == 'false'
6391 run : |
6492 git config user.name "github-actions[bot]"
6593 git config user.email "github-actions[bot]@users.noreply.github.com"
66- git tag -a "v${{ steps.get_version.outputs.version }}" -m "Release version ${{ steps.get_version.outputs.version }}"
67- git push origin "v${{ steps.get_version.outputs.version }}"
94+ git tag -a "v${{ env.VERSION }}" -m "Release version ${{ env.VERSION }}"
95+ git push origin "v${{ env.VERSION }}"
6896
6997 - name : Create GitHub Release
70- if : steps.check_tag.outputs.exists == 'false'
71- uses : softprops/action-gh-release@v1
98+ if : github.event_name == 'push' && steps.check_tag.outputs.exists == 'false'
99+ uses : softprops/action-gh-release@v2
72100 with :
73- tag_name : v${{ steps.get_version.outputs.version }}
74- name : Release v${{ steps.get_version.outputs.version }}
101+ tag_name : v${{ env.VERSION }}
102+ name : Release v${{ env.VERSION }}
75103 body : |
76- ## PluginLangCore v${{ steps.get_version.outputs.version }}
104+ ## PluginLangCore v${{ env.VERSION }}
77105
78106 ### π¦ Artifacts
79- - Main JAR: `PluginLangCore-${{ steps.get_version.outputs.version }}.jar`
80- - Sources JAR: `PluginLangCore-${{ steps.get_version.outputs.version }}-sources.jar`
81- - Javadoc JAR: `PluginLangCore-${{ steps.get_version.outputs.version }}-javadoc.jar`
107+ - Main JAR: `PluginLangCore-${{ env.VERSION }}.jar`
108+ - Sources JAR: `PluginLangCore-${{ env.VERSION }}-sources.jar`
109+ - Javadoc JAR: `PluginLangCore-${{ env.VERSION }}-javadoc.jar`
110+
111+ ### π Changes
112+ Built from commit: `${{ env.COMMIT_SHA_SHORT }}`
82113
83114 ### π Documentation
84115 See [README.md](https://github.com/${{ github.repository }}/blob/main/README.md) for usage instructions.
@@ -88,22 +119,35 @@ jobs:
88119 <dependency>
89120 <groupId>io.github.pluginlangcore</groupId>
90121 <artifactId>pluginlangcore</artifactId>
91- <version>${{ steps.get_version.outputs.version }}</version>
122+ <version>${{ env.VERSION }}</version>
92123 </dependency>
93124 ```
94125
95- ### π Gradle Dependency
126+ ### π Gradle Dependency (Kotlin DSL)
127+ ```kotlin
128+ implementation("io.github.pluginlangcore:pluginlangcore:${{ env.VERSION }}")
129+ ```
130+
131+ ### π Gradle Dependency (Groovy)
96132 ```groovy
97- implementation 'io.github.pluginlangcore:pluginlangcore:${{ steps.get_version.outputs.version }}'
133+ implementation 'io.github.pluginlangcore:pluginlangcore:${{ env.VERSION }}'
98134 ```
99135 draft : false
100136 prerelease : false
101137 files : |
102138 build/libs/*.jar
139+ fail_on_unmatched_files : false
103140 env :
104141 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
105142
106- - name : Skip release
107- if : steps.check_tag.outputs.exists == 'true'
108- run : echo "Release v${{ steps.get_version.outputs.version }} already exists, skipping..."
109-
143+ - name : Release Summary
144+ if : github.event_name == 'push'
145+ run : |
146+ if [ "${{ steps.check_tag.outputs.exists }}" == "true" ]; then
147+ echo "β
Build completed successfully"
148+ echo "βΉοΈ Release v${{ env.VERSION }} already exists, skipping release creation"
149+ else
150+ echo "β
Build completed successfully"
151+ echo "π Release v${{ env.VERSION }} created successfully"
152+ echo "π¦ Artifacts uploaded to GitHub Release"
153+ fi
0 commit comments