Skip to content

Commit

Permalink
Merge pull request #4 from DanilaVaratyntsev/master
Browse files Browse the repository at this point in the history
Setting up deploy to maven central
  • Loading branch information
DanilaVaratyntsev authored Sep 10, 2023
2 parents 0770de3 + 498b2e2 commit 05cbb00
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 5 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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.
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle

name: Gradle Package

on:
push:
branches: [ "master" ]

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

steps:
- uses: actions/checkout@v3
- id: install-secret-key
name: Install gpg secret key
run: |
cat <(echo -e "${{ secrets.PGP_PRIVATE_KEY }}") | base64 --decode > /tmp/pgp_private_key.kbx
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- uses: gradle/gradle-build-action@v2
id: setup-gradle
with:
gradle-version: "7.4"
- name: Build with Gradle
run: gradle build -dsigning.keyId=${{ secrets.PGP_KEY_ID }} -dsigning.password=${{ secrets.PGP_PASSWORD }} -dsigning.secretKeyRingFile="/tmp/pgp_private_key.kbx"

- name: Publish
run: gradle build -dsigning.keyId=${{ secrets.PGP_KEY_ID }} -dsigning.password=${{ secrets.PGP_PASSWORD }} -dsigning.secretKeyRingFile="/tmp/pgp_private_key.kbx"
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_SECRET }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.gradle
/build
gradle.properties
35 changes: 30 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
plugins {
id 'java'
id 'maven-publish'
id 'signing'
id 'jacoco'
}

group 'com.github.mjc-school'
version '1.0.4-SNAPSHOT'
group 'school.mjc'
archivesBaseName = "code-verifier"
version '1.0.0'

compileJava {
sourceCompatibility = '17'
Expand Down Expand Up @@ -40,10 +42,33 @@ tasks.jacocoTestReport {
dependsOn(tasks.test)
}

tasks.javadocJar {
classifier = 'javadoc'
from javadoc
}

tasks.sourcesJar {
classifier = 'sources'
from sourceSets.main.allSource
}

artifacts {
archives javadocJar, sourcesJar
}

signing {
sign configurations.archives
}

publishing {
publications {
maven(MavenPublication) {
from components.java
repositories {
maven {
name = "OSSRH"
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
}
}

0 comments on commit 05cbb00

Please sign in to comment.