diff --git a/.github/workflows/publish-release-artifacts.yml b/.github/workflows/publish-release-artifacts.yml index b8e7bd8230..4e54414b61 100644 --- a/.github/workflows/publish-release-artifacts.yml +++ b/.github/workflows/publish-release-artifacts.yml @@ -15,7 +15,7 @@ # TODO: Consider whether we should merge this with the "prepare-release" workflow rather # than having separate workflows. -name: Publish Artifacts for Release +name: "Publish Release Artifacts" on: release: @@ -42,10 +42,19 @@ jobs: echo "Project Version: $PROJECT_VERSION" echo "Release Tag: $RELEASE_TAG" [ "$PROJECT_VERSION" = "$RELEASE_TAG" ] || exit 1 - - uses: gradle/gradle-build-action@e2097ccd7e8ed48671dc068ac4efa86d25745b39 # v3.3.1 + - name: Build Release Artifacts + uses: gradle/gradle-build-action@e2097ccd7e8ed48671dc068ac4efa86d25745b39 # v3.3.1 with: - arguments: build cyclonedxBom publishToSonatype closeAndReleaseSonatypeStagingRepository - - name: Upload Jar to GitHub release + arguments: build cyclonedxBom + - name: Publish to Sonatype + uses: gradle/gradle-build-action@e2097ccd7e8ed48671dc068ac4efa86d25745b39 # v3.3.1 + with: + arguments: publishToSonatype + - name: Close and Release Sonatype Staging Repository + uses: gradle/gradle-build-action@e2097ccd7e8ed48671dc068ac4efa86d25745b39 # v3.3.1 + with: + arguments: closeAndReleaseSonatypeStagingRepository + - name: Upload Artifacts to GitHub Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # TODO - reusability diff --git a/build.gradle.kts b/build.gradle.kts index ea31b24f79..8b92773b51 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -75,6 +75,8 @@ description = "A Java implementation of the Amazon Ion data notation." val isCI: Boolean = System.getenv("CI") == "true" val githubRepositoryUrl = "https://github.com/amazon-ion/ion-java/" val isReleaseVersion: Boolean = !version.toString().endsWith("SNAPSHOT") +// The name we're checking for corresponds to the name that is set in the `publish-release-artifacts.yml` file. +val isReleaseWorkflow: Boolean = System.getenv("GITHUB_WORKFLOW") == "Publish Release Artifacts" val generatedResourcesDir = "$buildDir/generated/main/resources" lateinit var sourcesJar: AbstractArchiveTask lateinit var javadocJar: AbstractArchiveTask @@ -150,6 +152,13 @@ fun String.runCommand(workingDir: File = rootProject.projectDir): String { } spotless { + // If this is an automated release workflow, don't configure any style checks. + // This is important because we're ratcheting from `master` and when we create + // a release that is not directly from `master`, the spotless checks can cause + // the release workflow to fail if `master` has any commits that are not in the + // release branch. + if (isReleaseWorkflow) return@spotless + ratchetFrom("$sourceRepoRemoteName/master") val shortFormLicenseHeader = """