-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (139 loc) · 5.12 KB
/
release.yml
File metadata and controls
163 lines (139 loc) · 5.12 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
154
155
156
157
158
159
160
161
162
163
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/actions/wrapper-validation@v4
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Make Gradle wrapper executable
run: chmod +x ./gradlew
- name: Extract version
id: extract_version
run: |
VERSION=$(grep -E '^version\s*=' build.gradle.kts | sed -E 's/version\s*=\s*"([^"]+)"/\1/')
if [ -z "$VERSION" ]; then
echo "Unable to extract project version from build.gradle.kts" >&2
exit 1
fi
if ! git check-ref-format --allow-onelevel "$VERSION"; then
echo "Extracted version '$VERSION' is not a valid Git tag name" >&2
exit 1
fi
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 -q --verify "refs/tags/$VERSION" >/dev/null; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "Tag $VERSION already exists"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "Tag $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 "$VERSION" -m "Release version $VERSION"
git push origin "$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