This repository has been archived by the owner on Jul 27, 2023. It is now read-only.
generated from xpdustry/template-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (65 loc) · 3 KB
/
build.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
name: Build
on: [ push, pull_request ]
jobs:
build:
# Only run on PRs if the source branch is on someone else's repo
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 17
distribution: 'temurin'
- uses: gradle/wrapper-validation-action@v1
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Build artifact
id: build
run: |
./gradlew build
echo '::set-output name=ARTIFACT_PATH::'$(./gradlew getArtifactPath -q)
- name: Publish to Xpdustry
if: ${{ github.event_name != 'pull_request' }}
run: ./gradlew publish
env:
ORG_GRADLE_PROJECT_xpdustryUsername: "${{ secrets.XPDUSTRY_MAVEN_USERNAME }}"
ORG_GRADLE_PROJECT_xpdustryPassword: "${{ secrets.XPDUSTRY_MAVEN_PASSWORD }}"
ORG_GRADLE_PROJECT_signingKey: "${{ secrets.XPDUSTRY_MAVEN_SIGNING_KEY }}"
ORG_GRADLE_PROJECT_signingPassword: "${{ secrets.XPDUSTRY_MAVEN_SIGNING_PASSWORD }}"
- name: Determine Status
run: |
if [ "$(./gradlew properties | awk '/^version:/ { print $2; }' | grep '\-SNAPSHOT')" ]; then
echo "STATUS=snapshot" >> $GITHUB_ENV
else
echo "STATUS=release" >> $GITHUB_ENV
fi
- name: Set up Release
if: "${{ env.STATUS == 'release' }}"
id: release
run: |
tag=$(cat plugin.json | grep "version*") # Cut the line with the version in plugin.json
tag=$(echo $tag | cut -d ":" -f 2,3) # Split with ":" and take the version number
tag=$(echo $tag | tr -d \"," ") # Trim the " and , and spaces
echo '::set-output name=RELEASE_TAG::'$tag
r=$(cat CHANGELOG.md)
r="${r//'%'/'%25'}" # Multiline escape sequences for %
r="${r//$'\n'/'%0A'}" # Multiline escape sequences for '\n'
r="${r//$'\r'/'%0D'}" # Multiline escape sequences for '\r'
echo "::set-output name=CHANGELOG::$r"
- name: Upload artifact to Release
if: "${{ env.STATUS == 'release' }}"
uses: svenstaro/upload-release-action@v2
with:
release_name: v${{ steps.release.outputs.RELEASE_TAG }} release
body: ${{ steps.release.outputs.CHANGELOG }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
asset_name: ${{ github.event.repository.name }}.jar
file: ${{ steps.build.outputs.ARTIFACT_PATH }}
tag: v${{ steps.release.outputs.RELEASE_TAG }}
- name: Upload artifact to Actions
uses: actions/upload-artifact@v2
with:
name: ${{ github.event.repository.name }}
path: ${{ steps.build.outputs.ARTIFACT_PATH }}