diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..dd890f7 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 12eb6a9..b99da90 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /.gradle /build +gradle.properties \ No newline at end of file diff --git a/build.gradle b/build.gradle index f6ff3a0..6ee28d6 100644 --- a/build.gradle +++ b/build.gradle @@ -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' @@ -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") + } } } }