Skip to content

Commit

Permalink
Improve automated release workflow (#812)
Browse files Browse the repository at this point in the history
  • Loading branch information
popematt authored Apr 24, 2024
1 parent e85079a commit 2a87e2b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/publish-release-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = """
Expand Down

0 comments on commit 2a87e2b

Please sign in to comment.