Skip to content

Commit

Permalink
Setup publishing actions
Browse files Browse the repository at this point in the history
  • Loading branch information
stashymane committed Mar 19, 2024
1 parent 6123f93 commit a85481a
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
- name: Fix Gradle permissions
run: chmod +x ./gradlew
- name: Build with Gradle
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
with:
arguments: build
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Publish release to repositories

on:
push:
tags:
- "*"
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'

- name: Make gradlew executable
if: runner.os == 'Linux'
run: chmod +x ./gradlew

- name: Publish on Maven repository
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
with:
arguments: publish
env:
ORG_GRADLE_PROJECT_repoUser: ${{ secrets.REPO_USER }}
ORG_GRADLE_PROJECT_repoToken: ${{ secrets.REPO_TOKEN }}
21 changes: 21 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlinx.serialization)
id("maven-publish")
}

group = "dev.stashy"
Expand All @@ -22,4 +23,24 @@ tasks.test {

kotlin {
jvmToolchain(21)
}

publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
}
}

repositories {
maven("https://repo.stashy.dev/releases") {
credentials {
val repoUser: String? by project
val repoToken: String? by project

username = repoUser ?: ""
password = repoToken ?: ""
}
}
}
}

0 comments on commit a85481a

Please sign in to comment.