-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (131 loc) Β· 4.93 KB
/
release.yml
File metadata and controls
153 lines (131 loc) Β· 4.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Build and Release
on:
push:
branches: [ main, master ]
paths-ignore:
- '**.md'
- '.gitignore'
- 'LICENSE'
pull_request:
branches: [ main, master ]
paths-ignore:
- '**.md'
- '.gitignore'
- 'LICENSE'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Make Gradle wrapper executable
run: chmod +x ./gradlew
- name: Extract version
id: extract_version
run: |
VERSION=$(grep "^version = " build.gradle | sed "s/version = '\(.*\)'/\1/")
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_OUTPUT
COMMIT_SHA_SHORT=$(git rev-parse --short HEAD)
echo "COMMIT_SHA_SHORT=$COMMIT_SHA_SHORT" >> $GITHUB_ENV
echo "Version: $VERSION (Commit: $COMMIT_SHA_SHORT)"
- name: Check if tag exists
id: check_tag
run: |
if git rev-parse "${{ env.VERSION }}" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Tag ${{ env.VERSION }} already exists"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Tag ${{ env.VERSION }} does not exist"
fi
- name: Build with Gradle
run: ./gradlew clean build --no-daemon
- name: Run tests
run: ./gradlew test --no-daemon
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: PluginUpdateCore-${{ env.VERSION }}-build-${{ env.COMMIT_SHA_SHORT }}
path: build/libs/*.jar
retention-days: 90
- name: Upload test reports on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ env.COMMIT_SHA_SHORT }}
path: build/reports/tests/
retention-days: 7
- name: Create Git Tag
if: github.event_name == 'push' && steps.check_tag.outputs.exists == 'false'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "${{ env.VERSION }}" -m "Release version ${{ env.VERSION }}"
git push origin "${{ env.VERSION }}"
- name: Create GitHub Release
if: github.event_name == 'push' && steps.check_tag.outputs.exists == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.VERSION }}
name: Release ${{ env.VERSION }}
body: |
## PluginUpdateCore ${{ env.VERSION }}
### π¦ Artifacts
- Main JAR: `PluginUpdateCore-${{ env.VERSION }}.jar`
- Sources JAR: `PluginUpdateCore-${{ env.VERSION }}-sources.jar`
- Javadoc JAR: `PluginUpdateCore-${{ env.VERSION }}-javadoc.jar`
### π Changes
Built from commit: `${{ env.COMMIT_SHA_SHORT }}`
### π Documentation
See [README.md](https://github.com/${{ github.repository }}/blob/main/README.md) for usage instructions.
### π Maven Dependency
```xml
<dependency>
<groupId>com.github.NighterDevelopment</groupId>
<artifactId>PluginUpdateCore</artifactId>
<version>${{ env.VERSION }}</version>
</dependency>
```
### π Gradle Dependency (Kotlin DSL)
```kotlin
implementation("com.github.NighterDevelopment:PluginUpdateCore:${{ env.VERSION }}")
```
### π Gradle Dependency (Groovy)
```groovy
implementation 'com.github.NighterDevelopment:PluginUpdateCore:${{ env.VERSION }}'
```
draft: false
prerelease: false
files: |
build/libs/*.jar
fail_on_unmatched_files: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release Summary
if: github.event_name == 'push'
run: |
if [ "${{ steps.check_tag.outputs.exists }}" == "true" ]; then
echo "β
Build completed successfully"
echo "βΉοΈ Release ${{ env.VERSION }} already exists, skipping release creation"
else
echo "β
Build completed successfully"
echo "π Release ${{ env.VERSION }} created successfully"
echo "π¦ Artifacts uploaded to GitHub Release"
fi