Skip to content

Commit adc9f08

Browse files
authored
feat: setup publishing
1 parent 3892cf9 commit adc9f08

File tree

4 files changed

+111
-0
lines changed

4 files changed

+111
-0
lines changed

.github/workflows/build.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Build
2+
on:
3+
push:
4+
branches: ['**']
5+
pull_request:
6+
branches: ['**']
7+
8+
jobs:
9+
build:
10+
if: github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name
11+
name: Build
12+
runs-on: 'ubuntu-latest'
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: actions/setup-java@v3
16+
with:
17+
distribution: 'temurin'
18+
java-version: 21
19+
- uses: gradle/wrapper-validation-action@v1
20+
- uses: gradle/gradle-build-action@v2
21+
with:
22+
arguments: build --stacktrace

.github/workflows/deploy-release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Deploy
2+
on:
3+
push:
4+
tags: ['v*']
5+
6+
jobs:
7+
deploy:
8+
name: Deploy
9+
runs-on: 'ubuntu-latest'
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-java@v3
13+
with:
14+
distribution: 'temurin'
15+
java-version: 21
16+
- uses: gradle/wrapper-validation-action@v1
17+
- uses: gradle/gradle-build-action@v2
18+
name: Deploy
19+
with:
20+
arguments: build publish --stacktrace
21+
env:
22+
ORG_GRADLE_PROJECT_papermcUsername: ${{ secrets.DEPLOY_USER }}
23+
ORG_GRADLE_PROJECT_papermcPassword: ${{ secrets.DEPLOY_PASS }}
24+
- name: Get tag name
25+
id: get_tag
26+
shell: bash
27+
run: |
28+
tag_name="$(echo $GITHUB_REF | cut -d / -f 3)"
29+
echo "tag=$tag_name" >> $GITHUB_OUTPUT
30+
- name: Create GitHub Release
31+
uses: softprops/action-gh-release@v1
32+
with:
33+
tag_name: ${{ steps.get_tag.outputs.tag }}
34+
name: 'Release ${{ steps.get_tag.outputs.tag }}'
35+
prerelease: false
36+
draft: false
37+
files: |
38+
build/libs/*.jar
39+
codebook-cli/build/libs/*-all.jar
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/deploy-snapshot.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Deploy Snapshot
2+
on:
3+
push:
4+
branches: ['main']
5+
paths-ignore:
6+
- 'README.md'
7+
- '.editorconfig'
8+
- '.gitignore'
9+
- '.gitattributes'
10+
11+
jobs:
12+
deploy:
13+
name: Deploy Snapshot
14+
runs-on: 'ubuntu-latest'
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-java@v3
18+
with:
19+
distribution: 'temurin'
20+
java-version: 21
21+
- uses: gradle/wrapper-validation-action@v1
22+
- uses: gradle/gradle-build-action@v2
23+
name: Setup Gradle
24+
- name: Get project version
25+
id: get_version
26+
shell: bash
27+
run: |
28+
project_version=$(./gradlew -q --console=plain printVersion)
29+
echo "version=$project_version" >> $GITHUB_OUTPUT
30+
- name: Deploy snapshot version
31+
if: endsWith(steps.get_version.outputs.version, '-SNAPSHOT')
32+
run: ./gradlew build publish --stacktrace
33+
env:
34+
ORG_GRADLE_PROJECT_papermcUsername: ${{ secrets.DEPLOY_USER }}
35+
ORG_GRADLE_PROJECT_papermcPassword: ${{ secrets.DEPLOY_PASS }}

build.gradle.kts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@ publishing {
6363
artifactId = rootProject.name
6464
from(components["java"])
6565
}
66+
67+
repositories {
68+
val isSnapshot = rootProject.version.toString().endsWith("-SNAPSHOT")
69+
val url = if (isSnapshot) {
70+
"https://repo.papermc.io/repository/maven-snapshots/"
71+
} else {
72+
"https://repo.papermc.io/repository/maven-releases/"
73+
}
74+
maven(url) {
75+
name = "papermc"
76+
credentials(PasswordCredentials::class)
77+
}
78+
}
6679
}
6780

6881
tasks.register("printVersion") {

0 commit comments

Comments
 (0)