Repository navigation
94 lines (78 loc) · 2.55 KB
/
Copy pathrelease.yml
File metadata and controls
94 lines (78 loc) · 2.55 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
name: Release and Publish
on:
push:
branches:
- main
- develop
workflow_dispatch:
inputs:
type:
description: 'Release type'
required: true
default: 'dev'
type: choice
options:
- dev
- release
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write
jobs:
release:
name: Build and Publish
runs-on: ubuntu-latest
env:
GRADLE_ARGS: ${{ ((github.event_name == 'push' && github.ref_name == 'main') || inputs.type == 'release') && '-Prelease' || '' }}
IS_RELEASE: ${{ (github.event_name == 'push' && github.ref_name == 'main') || inputs.type == 'release' }}
steps:
- name: Check branch
if: env.IS_RELEASE == 'true' && github.ref_name != 'main'
run: |
echo "::error::Releases can only be created from main"
exit 1
- name: Checkout repository
uses: actions/checkout@v7
- name: Set up JDK
uses: actions/setup-java@v6
with:
distribution: 'temurin'
java-version: '25'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v6
with:
cache-disabled: true
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Get Gradle Version
run: echo "GRADLE_VERSION=$(./gradlew properties -q $GRADLE_ARGS | awk '/^version:/ {print $2}')" >> $GITHUB_ENV
- name: Build
run: ./gradlew clean build $GRADLE_ARGS
- name: Publish to SimpleCloud Repository
run: ./gradlew publish $GRADLE_ARGS
env:
SIMPLECLOUD_USERNAME: ${{ secrets.SIMPLECLOUD_USERNAME }}
SIMPLECLOUD_PASSWORD: ${{ secrets.SIMPLECLOUD_PASSWORD }}
- name: Create Release
run: |
jars=()
for jar in $(find . -type f -name "*.jar" -path "*/build/libs/*.jar" -not -path "./build/libs/*"); do
echo "Uploading $jar"
jars+=("$jar")
done
if [ "$IS_RELEASE" = "true" ]; then
flags=()
notes="This release contains release builds for all Gradle modules."
else
flags=(--prerelease)
notes="This release contains dev builds for all Gradle modules."
fi
gh release create "v${GRADLE_VERSION}" \
--target "${{ github.sha }}" \
--title "v${GRADLE_VERSION}" \
--notes "$notes" \
"${flags[@]}" \
"${jars[@]}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}