-
-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (118 loc) · 4.84 KB
/
publish.yml
File metadata and controls
138 lines (118 loc) · 4.84 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
name: Package & Release Plugin
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
release:
types: [ created ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: "8.11.1"
- name: Build with Gradle (Kotlin DSL)
run: gradle --no-daemon clean jar sourcesJar javadocJar
- name: Upload plugin artifact
uses: actions/upload-artifact@v4
with:
name: Plugin
path: build/libs/${{ github.event.repository.name }}-*.jar
- name: Get Plugin Version
id: version
run: |
VERSION=$(gradle -q properties --property version | awk '/^version:/ {print $2}')
if [ -z "$VERSION" ]; then
echo "Could not determine project version"
exit 1
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Delete existing GitHub release (if exists)
run: |
RELEASE_ID=$(gh release view ${{ env.VERSION }} --json id -q '.id' || echo "")
if [ -n "$RELEASE_ID" ]; then
echo "Deleting existing release..."
gh release delete ${{ env.VERSION }} --yes
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Delete existing tag (if exists)
run: |
if git rev-parse "${{ env.VERSION }}" >/dev/null 2>&1; then
echo "Deleting existing tag..."
git tag -d ${{ env.VERSION }}
git push origin :refs/tags/${{ env.VERSION }}
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Rename & Upload Latest Release
run: |
cp build/libs/${{ github.event.repository.name }}-${{ env.VERSION }}.jar build/libs/${{ github.event.repository.name }}-latest.jar
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.VERSION }}
name: Release ${{ env.VERSION }}
draft: false
prerelease: false
files: |
build/libs/${{ github.event.repository.name }}-latest.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Maven repository
uses: actions/checkout@v4
with:
repository: CroaBeast/repo
path: maven-repo
token: ${{ secrets.MAVEN_DEPLOY_TOKEN }}
- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Deploy to Maven repository
run: |
mkdir -p maven-repo/me/croabeast/${{ github.event.repository.name }}/${{ env.VERSION }}
cp build/libs/${{ github.event.repository.name }}-${{ env.VERSION }}.jar maven-repo/me/croabeast/${{ github.event.repository.name }}/${{ env.VERSION }}/
cp build/libs/${{ github.event.repository.name }}-${{ env.VERSION }}-javadoc.jar maven-repo/me/croabeast/${{ github.event.repository.name }}/${{ env.VERSION }}/
cp build/libs/${{ github.event.repository.name }}-${{ env.VERSION }}-sources.jar maven-repo/me/croabeast/${{ github.event.repository.name }}/${{ env.VERSION }}/
cat > maven-repo/me/croabeast/${{ github.event.repository.name }}/${{ env.VERSION }}/${{ github.event.repository.name }}-${{ env.VERSION }}.pom << EOF
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>me.croabeast</groupId>
<artifactId>${{ github.event.repository.name }}</artifactId>
<version>${{ env.VERSION }}</version>
<packaging>jar</packaging>
</project>
EOF
cat > maven-repo/me/croabeast/${{ github.event.repository.name }}/maven-metadata.xml << EOF
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>me.croabeast</groupId>
<artifactId>${{ github.event.repository.name }}</artifactId>
<versioning>
<latest>${{ env.VERSION }}</latest>
<release>${{ env.VERSION }}</release>
<versions>
<version>${{ env.VERSION }}</version>
</versions>
<lastUpdated>$(date +%Y%m%d%H%M%S)</lastUpdated>
</versioning>
</metadata>
EOF
cd maven-repo
git add .
git commit -m "Deploy ${{ github.event.repository.name }} ${{ env.VERSION }}"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}