Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ jobs:
uses: gradle/actions/setup-gradle@v3

- name: Build
env:
# These values are compiled into Constants.class. Keep tagged builds independent of
# which workflow ref launched a retry and of GitHub's ever-increasing run number.
GIT_BRANCH: ${{ inputs.release_tag || github.event.release.tag_name || github.ref_name }}
BUILD_NUMBER: ${{ github.event_name == 'push' && github.run_number || 0 }}
run: ./gradlew build

- name: Get version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,24 @@ void gradleArchivesAreConfiguredForReproducibleBytes() throws Exception {
assertTrue(build.contains("isReproducibleFileOrder = true"),
"archive entry order is not deterministic");
}

/** Tagged builds must not compile workflow-run identity into otherwise reproducible JARs. */
@Test
@SuppressWarnings("unchecked")
void taggedBuildIdentityIsStableAcrossReleaseRetries() throws Exception {
List<Map<String, Object>> steps = readBuildJobSteps();
int buildAt = stepIndex(steps, "Build");
assertTrue(buildAt >= 0, "build job is missing the Build step");

Map<String, Object> env = (Map<String, Object>) steps.get(buildAt).get("env");
assertTrue(env != null, "Build step has no stable release environment");
assertEquals(
"${{ inputs.release_tag || github.event.release.tag_name || github.ref_name }}",
String.valueOf(env.get("GIT_BRANCH")),
"tagged builds depend on the workflow ref that happened to launch them");
assertEquals(
"${{ github.event_name == 'push' && github.run_number || 0 }}",
String.valueOf(env.get("BUILD_NUMBER")),
"tagged builds compile GitHub's changing run number into Constants.class");
}
}
Loading