-
Notifications
You must be signed in to change notification settings - Fork 3
91 lines (80 loc) · 3.01 KB
/
gradle.yml
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
name: Build and Release
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java:
- 17
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.6
- name: Set up JDK 17
uses: actions/setup-java@v4.2.1
with:
distribution: adopt
java-version: '17'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Get current version
id: get_version
run: |
echo "version=$(${{github.workspace}}/gradlew -q pluginVersion)" >> $GITHUB_OUTPUT
- name: Check if version is in development
id: in_dev_check
run: |
CURRENT_VERSION=${{ steps.get_version.outputs.version }}
echo "Current version: $CURRENT_VERSION"
if [[ "$CURRENT_VERSION" == *"InDEV"* ]]; then
echo "Version contains 'InDEV'. Skipping..."
echo "version_in_dev=true" >> $GITHUB_OUTPUT
else
echo "Version is not contains 'InDEV'. Proceeding."
echo "version_in_dev=false" >> $GITHUB_OUTPUT
fi
- name: Check if version changed
if: steps.in_dev_check.outputs.version_in_dev == 'false'
id: version_check
run: |
git fetch --tags
CURRENT_VERSION=${{ steps.get_version.outputs.version }}
echo "Current version: $CURRENT_VERSION"
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null || echo "no-tag-found")
echo "Latest tag: $LATEST_TAG"
if [ "$LATEST_TAG" == "$CURRENT_VERSION" ]; then
echo "Version has not changed. Exiting."
echo "version_changed=false" >> $GITHUB_OUTPUT
else
echo "Version has changed. Proceeding."
echo "version_changed=true" >> $GITHUB_OUTPUT
fi
- name: Build with Gradle
if: steps.in_dev_check.outputs.version_in_dev == 'false' && steps.version_check.outputs.version_changed == 'true'
run: ./gradlew clean plugin-core:shadowJar
- name: Upload JAR file
if: steps.in_dev_check.outputs.version_in_dev == 'false' && steps.version_check.outputs.version_changed == 'true'
uses: actions/upload-artifact@v4.3.3
with:
name: Dream-Template
path: plugin-core/build/libs/*.jar
- name: Download JAR file
if: steps.in_dev_check.outputs.version_in_dev == 'false' && steps.version_check.outputs.version_changed == 'true'
uses: actions/download-artifact@v4.1.7
with:
name: Dream-Template
path: ./plugin-core/build/libs
- name: Create GitHub Release
if: steps.in_dev_check.outputs.version_in_dev == 'false' && steps.version_check.outputs.version_changed == 'true'
id: create_release
uses: softprops/action-gh-release@v2.0.5
with:
name: v${{ steps.get_version.outputs.version }}
tag_name: ${{ steps.get_version.outputs.version }}
files: ./plugin-core/build/libs/*.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}