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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ jobs:
branch="${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}"
timestamp="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
build_id="${GITHUB_RUN_NUMBER}.${GITHUB_RUN_ATTEMPT}"
artifact_name="HeadDB-ci-${build_id}-${short_sha}"
jar_name="HeadDB-${version}-ci-build-${build_id}-${short_sha}.jar"
artifact_name="HeadDB-${version}+ci.${build_id}.${short_sha}"
jar_name="${artifact_name}.jar"

echo "version=${version}" >> "$GITHUB_OUTPUT"
echo "short_sha=${short_sha}" >> "$GITHUB_OUTPUT"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ concurrency:
cancel-in-progress: false

jobs:
release_please:
name: Prepare or create release
prepare_release_pr:
name: Prepare release PR
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
timeout-minutes: 15
Expand All @@ -47,7 +47,7 @@ jobs:
pull-requests: write

steps:
- name: Run Release Please
- name: Prepare release PR
uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0
with:
token: ${{ secrets.RELEASE_PLEASE_TOKEN || github.token }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public record BuildInfo(@NotNull String version, @NotNull String channel, @Nulla
Objects.requireNonNull(buildProperties, "buildProperties");
Objects.requireNonNull(gitProperties, "gitProperties");

String channel = channel(buildProperties.getProperty("headdb.build.channel"));
String channel = channelLabel(buildProperties.getProperty("headdb.build.channel"));
String buildNumber = optionalValue(buildProperties.getProperty("headdb.build.number"));
String buildAttempt = buildNumber == null ? null : optionalValue(buildProperties.getProperty("headdb.build.attempt"));
String runId = buildNumber == null ? null : optionalValue(buildProperties.getProperty("headdb.build.run-id"));
Expand All @@ -41,17 +41,15 @@ public record BuildInfo(@NotNull String version, @NotNull String channel, @Nulla
}

public @NotNull String displayBuild() {
String label = channelLabel();

if (buildNumber == null) {
return label;
return channel;
}

if (buildAttempt == null || buildAttempt.equals("1")) {
return label + " #" + buildNumber;
return buildNumber;
}

return label + " #" + buildNumber + "." + buildAttempt;
return buildNumber + "." + buildAttempt;
}

public boolean hasGitInfo() {
Expand All @@ -62,18 +60,6 @@ public boolean hasCiBuildInfo() {
return channel.equalsIgnoreCase("ci") && buildNumber != null;
}

private @NotNull String channelLabel() {
if (channel.equalsIgnoreCase("ci")) {
return "CI";
}

if (channel.length() == 1) {
return channel.toUpperCase(Locale.ROOT);
}

return Character.toUpperCase(channel.charAt(0)) + channel.substring(1).toLowerCase(Locale.ROOT);
}

private static @NotNull Properties readProperties(@NotNull JavaPlugin plugin, @NotNull String resource) {
Properties properties = new Properties();

Expand All @@ -90,13 +76,22 @@ public boolean hasCiBuildInfo() {
return properties;
}

private static @NotNull String channel(@Nullable String value) {
private static @NotNull String channelLabel(@Nullable String value) {
String normalized = optionalValue(value);
if (normalized == null) {
return "local";
return "Local";
}

if (normalized.equalsIgnoreCase("ci")) {
return "CI";
}

if (normalized.length() == 1) {
return normalized.toUpperCase(Locale.ROOT);
}

return normalized.toLowerCase(Locale.ROOT);
return Character.toUpperCase(normalized.charAt(0))
+ normalized.substring(1).toLowerCase(Locale.ROOT);
}

private static @Nullable String firstPresent(@Nullable String first, @Nullable String second) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ void readsCiMetadataWithoutChangingPluginVersion() {
BuildInfo buildInfo = BuildInfo.from("7.0.0-rc.7", buildProperties, gitProperties);

assertEquals("7.0.0-rc.7", buildInfo.version());
assertEquals("ci", buildInfo.channel());
assertEquals("CI", buildInfo.channel());
assertEquals("412", buildInfo.buildNumber());
assertEquals("2", buildInfo.buildAttempt());
assertEquals("22018457391", buildInfo.runId());
assertEquals("CI #412.2", buildInfo.displayBuild());
assertEquals("412.2", buildInfo.displayBuild());
assertEquals("45733cd", buildInfo.commit());
assertEquals("45733cd4e64b227ade4f42c30f6b4bdd27e5d88d", buildInfo.fullCommit());
assertEquals("master", buildInfo.branch());
Expand All @@ -56,7 +56,7 @@ void usesSafeLocalDefaults() {
BuildInfo buildInfo = BuildInfo.from("7.0.0-rc.7", buildProperties, new Properties());

assertEquals("7.0.0-rc.7", buildInfo.version());
assertEquals("local", buildInfo.channel());
assertEquals("Local", buildInfo.channel());
assertEquals("Local", buildInfo.displayBuild());
assertNull(buildInfo.buildNumber());
assertNull(buildInfo.buildAttempt());
Expand Down
Loading