Skip to content

Commit 4b5d2b5

Browse files
Hopefully figure out Maven publishing
Why does Gradle have to be like this?
1 parent 66fcbc8 commit 4b5d2b5

3 files changed

Lines changed: 80 additions & 3 deletions

File tree

.github/workflows/publish.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Publish Release
2+
run-name: "Publish release from ${{ github.ref_name }}"
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
distinct_id:
8+
type: string
9+
required: false
10+
11+
permissions:
12+
# Needed to push the tag.
13+
contents: write
14+
15+
jobs:
16+
publish:
17+
runs-on: ubuntu-latest
18+
steps:
19+
20+
- name: Echo distinct ID ${{ inputs.distinct_id }}
21+
run: echo ${{ inputs.distinct_id }}
22+
23+
- name: Checkout repository
24+
uses: actions/checkout@v6
25+
with:
26+
# Include all tags in case the new tag already exists.
27+
fetch-tags: true
28+
29+
- name: Set up Java 25
30+
uses: actions/setup-java@v5
31+
with:
32+
java-version: "25"
33+
distribution: "microsoft"
34+
35+
- name: Grant execute permission for gradlew
36+
run: chmod +x gradlew
37+
38+
- name: Setup Gradle
39+
uses: gradle/actions/setup-gradle@v6
40+
41+
- name: Build
42+
run: ./gradlew build --stacktrace --warning-mode=fail
43+
44+
- name: Create and push tag
45+
if: ${{ github.ref_type != 'tag' }}
46+
run: |
47+
VERSION=$(grep "^version=" gradle.properties | cut -d'=' -f2 | tr -d ' \r')
48+
git config --global user.name "Wurst-Bot"
49+
git config --global user.email "contact.wurstimperium@gmail.com"
50+
git tag "$VERSION"
51+
git push origin "$VERSION"
52+
53+
- name: Publish to staging Maven repository
54+
run: ./gradlew publishAllPublicationsToStagingRepository --stacktrace
55+
56+
- name: Set up SSH
57+
run: |
58+
mkdir -p ~/.ssh
59+
chmod 700 ~/.ssh
60+
printf '%s\n' "${{ secrets.MAVEN_DEPLOY_SSH_KEY }}" > ~/.ssh/id_ed25519
61+
chmod 600 ~/.ssh/id_ed25519
62+
printf '%s\n' "${{ secrets.MAVEN_DEPLOY_KNOWN_HOSTS }}" > ~/.ssh/known_hosts
63+
chmod 644 ~/.ssh/known_hosts
64+
65+
- name: Upload to Maven server
66+
run: |
67+
rsync -rltvz \
68+
build/maven-repo/ \
69+
"${{ secrets.MAVEN_DEPLOY_USER }}@${{ secrets.MAVEN_DEPLOY_HOST }}:"

build.gradle

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ plugins {
33
id "maven-publish"
44
}
55

6-
group = "net.wimods.gradle"
7-
version = "0.1.0"
8-
96
gradlePlugin {
107
plugins {
118
githubCompileSummary {
@@ -14,3 +11,12 @@ gradlePlugin {
1411
}
1512
}
1613
}
14+
15+
publishing {
16+
repositories {
17+
maven {
18+
name = "staging"
19+
url = layout.buildDirectory.dir("maven-repo")
20+
}
21+
}
22+
}

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
group=net.wimods.gradle
2+
version=0.1.0

0 commit comments

Comments
 (0)