-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (92 loc) · 3.36 KB
/
Copy pathrelease.yml
File metadata and controls
104 lines (92 loc) · 3.36 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
name: Release
on:
push:
branches:
- main
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
jobs:
release:
name: Build & Publish Release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
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: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Determine version
id: get_version
run: |
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
VERSION="${GITHUB_REF#refs/tags/v}"
else
VERSION=$(grep -oP 'version\s*=\s*"\K[^"]+' build.gradle.kts)
fi
echo "Detected version: ${VERSION}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "tag=v${VERSION}" >> "$GITHUB_OUTPUT"
- name: Check if release tag already exists
id: check_release
run: |
TAG="${{ steps.get_version.outputs.tag }}"
if git rev-parse "${TAG}" >/dev/null 2>&1; then
if [[ "${GITHUB_REF}" != "refs/tags/${TAG}" ]]; then
echo "Tag ${TAG} already exists on remote and this is not a tag push. Skipping automated release."
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "Tag push matches ${TAG}. Proceeding with release."
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
else
echo "Tag ${TAG} does not exist yet. Proceeding with automated release."
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Build with Gradle
if: steps.check_release.outputs.exists != 'true'
run: ./gradlew clean build shadowJar --no-daemon
- name: Generate Changelog
if: steps.check_release.outputs.exists != 'true'
id: changelog
run: |
PREV_TAG=$(git describe --tags --abbrev=0 "${{ steps.get_version.outputs.tag }}^" 2>/dev/null || git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -n "$PREV_TAG" ]; then
echo "Generating changelog since $PREV_TAG..."
COMMITS=$(git log "${PREV_TAG}..HEAD" --oneline --no-merges)
else
echo "Initial release. Generating changelog from recent commits..."
COMMITS=$(git log --oneline --no-merges -n 30)
fi
{
echo "### Changes in v${{ steps.get_version.outputs.version }}"
echo ""
echo "$COMMITS" | while IFS= read -r line; do
[ -n "$line" ] && echo "- $line"
done
echo ""
echo "---"
echo "**Compatibility:** Paper & Folia 1.21.x | Java 21+"
} > release_notes.md
- name: Create or Update GitHub Release
if: steps.check_release.outputs.exists != 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_version.outputs.tag }}
name: JavaSkript v${{ steps.get_version.outputs.version }}
body_path: release_notes.md
files: build/libs/JavaSkript-*.jar
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}