Skip to content

Commit

Permalink
add variable and update task
Browse files Browse the repository at this point in the history
  • Loading branch information
grablack committed Apr 3, 2024
1 parent d01ff10 commit 2647457
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
5 changes: 0 additions & 5 deletions .github/actions/publish_all_modules/action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: 'Publish All Modules'
description: 'Publishes all modules'
inputs:
release_snapshot:
description: 'Append Snapshot to version'
required: false
default: ''
sonatype_user:
description: 'Sonatype user'
required: true
Expand Down Expand Up @@ -32,7 +28,6 @@ runs:
./gradlew --stacktrace clean publishToSonatype closeAndReleaseSonatypeStagingRepository
shell: bash
env:
RELEASE_SNAPSHOT: ${{ inputs.release_snapshot }}
SONATYPE_NEXUS_USERNAME: ${{ inputs.sonatype_user }}
SONATYPE_NEXUS_PASSWORD: ${{ inputs.sonatype_password }}
SIGNING_KEY_ID: ${{ inputs.signing_key_id }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release-snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ jobs:
signing_key_file: ${{ secrets.SIGNING_KEY_FILE }}
signing_file_path: ${{ env.SIGNING_KEY_FILE_PATH }}

- name: Set snapshot environment variable
run: echo "USE_SNAPSHOT=true" >> $GITHUB_ENV

- name: Install Semantic Release Dependencies
run: npm install

Expand All @@ -60,7 +63,6 @@ jobs:
- name: Publish to Maven
uses: ./.github/actions/publish_all_modules
with:
release_snapshot: "true"
sonatype_user: ${{ secrets.SONATYPE_SDKS_NEXUS_USERNAME }}
sonatype_password: ${{ secrets.SONATYPE_SDKS_NEXUS_PASSWORD }}
signing_key_id: ${{ secrets.SIGNING_KEY_ID }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ jobs:
signing_key_file: ${{ secrets.SIGNING_KEY_FILE }}
signing_file_path: ${{ env.SIGNING_KEY_FILE_PATH }}

- name: Set snapshot environment variable
run: echo "USE_SNAPSHOT=true" >> $GITHUB_ENV

- name: Install Semantic Release Dependencies
run: npm install

Expand All @@ -60,7 +63,6 @@ jobs:
- name: Publish to Maven
uses: ./.github/actions/publish_all_modules
with:
release_snapshot: "true"
sonatype_user: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
sonatype_password: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
signing_key_id: ${{ secrets.SIGNING_KEY_ID }}
Expand Down
3 changes: 2 additions & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"branches": [
"release",
{"name": "develop", "prerelease": true},
{"name": "prerelease", "prerelease": true}
{"name": "prerelease", "prerelease": true},
{"name": "minSdkMatch", "prerelease": true}
],
"tagFormat": "${version}",
"plugins": [
Expand Down
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ tasks.register('changeReleaseVersion') {
doLast {
def topLevelGradleFile = file('./build.gradle')
def topLevelGradleFileText = topLevelGradleFile.getText('UTF-8')
def useSnapshot = System.getenv('USE_SNAPSHOT')
def snapshotParam = useSnapshot == 'true' ? "-SNAPSHOT" : ""

def updatedScript =
topLevelGradleFileText.replaceFirst(/("sdkVersionName"\s*: )".*",/, '$1"' + versionParam + '",')
topLevelGradleFileText.replaceFirst(/("sdkVersionName"\s*: )".*",/, '$1"' + versionParam + snapshotParam + '",')
topLevelGradleFile.write(updatedScript, 'UTF-8')
}
}
11 changes: 4 additions & 7 deletions gradle/gradle-publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') ?: ''
ext["signing.password"] = System.getenv('SIGNING_KEY_PASSWORD') ?: ''
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_KEY_FILE') ?: ''

if (System.getenv('RELEASE_SNAPSHOT') == "true") {
project.ext.version = project.ext.version + "-SNAPSHOT"
}

afterEvaluate {
publishing {
Expand Down Expand Up @@ -47,10 +44,10 @@ afterEvaluate {
}
repositories {
maven {
// def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
// url = project.ext.version.contains('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
url = uri(snapshotsRepoUrl)
// def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
// def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
// url = project.ext.version.contains('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
}
}
}
Expand Down

0 comments on commit 2647457

Please sign in to comment.