Skip to content

Commit

Permalink
githab action publish to repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ihermandev committed Jan 26, 2023
1 parent 9ca73d3 commit 73067d6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
40 changes: 40 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish

on:
release:
# Run this workflow when a new GitHub release is created
types: [released]

jobs:
publish:
name: Release build and publish
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3.1.0
with:
ref: release
- name: Set up JDK 11
uses: actions/setup-java@v3.6.0
with:
distribution: adopt
java-version: 11

# Builds the release artifacts
- name: Release build
run: ./gradlew :format-watcher:assembleRelease

# Generates artifacts androidSourcesJar and javadocJar
- name: Source jar and dokka
run: ./gradlew androidSourcesJar javadocJar

- name: Publish to MavenCentral
run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository

env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
5 changes: 4 additions & 1 deletion gradle/publish-root.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if (secretPropsFile.exists()) {
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
p.each { name, value -> ext[name] = value }
} else {
// Use system environment variables
// System environment variables
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
Expand All @@ -28,6 +28,9 @@ nexusPublishing {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
stagingProfileId = sonatypeStagingProfileId
username = ossrhUsername
password = ossrhPassword
}
}
}

0 comments on commit 73067d6

Please sign in to comment.