Skip to content

Commit 3c9bb6d

Browse files
committed
add: make gradlew executable in release workflow
1 parent c68d3e5 commit 3c9bb6d

5 files changed

Lines changed: 298 additions & 262 deletions

File tree

Lines changed: 83 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,115 @@
1-
name: Create Release
1+
name: Build and Release
22

33
on:
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

1018
jobs:
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
-42.4 KB
Binary file not shown.

β€Žgradle/wrapper/gradle-wrapper.propertiesβ€Ž

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
Β (0)