Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e0a54a0
Create GH actions workflow for agent release
JonasKunz Feb 6, 2023
57e0a18
Added missing job dependency
JonasKunz Feb 20, 2023
9eb78ab
Added another missing dependency
JonasKunz Feb 20, 2023
2414c74
Add setup-git action and adapt permissions
reakaleek May 8, 2023
1a00ccb
Add docker login
reakaleek May 8, 2023
4c1baec
Replace hardcoded occurrences of main with inputs.branch
reakaleek May 15, 2023
95d27d9
Use gh cli instead of custom action
reakaleek May 15, 2023
9e74b86
Update .github/workflows/release.yml
reakaleek May 31, 2023
dbef751
Remove bump_opbeans job
reakaleek May 31, 2023
b4d7652
Remove maven config env
reakaleek May 31, 2023
79e768a
Use input instead of hard coded ref
reakaleek May 31, 2023
ffb0d16
Add buildkite trigger action and complete lambda publish steps
reakaleek May 31, 2023
57d965c
Cleanup
reakaleek Jun 5, 2023
d36f323
Checkout tag after it's created by prepare_release
reakaleek Jun 5, 2023
4791c32
Rename scripts/jenkins folder to scripts/docker-release
reakaleek Jun 5, 2023
9c6fc83
Checkout newly created tag instead of main
reakaleek Jun 5, 2023
1bdef7e
Add timeout-minutes to until loops
reakaleek Jun 5, 2023
b32f4b0
Remove dry_run input
reakaleek Jun 5, 2023
9798e9c
Add notification
reakaleek Jun 5, 2023
c8b1979
Only allow single workflow at a time
reakaleek Jun 5, 2023
6c4c3a2
complete needs list
reakaleek Jun 5, 2023
73d7272
Error if no artifacts our found from buildkite
reakaleek Jun 6, 2023
e6cafa0
Use correct repo
reakaleek Jun 6, 2023
9e66e33
Set permissions on individual jobs
reakaleek Jun 7, 2023
90e40ef
Update .github/workflows/release.yml
reakaleek Jun 7, 2023
b5fe13f
Remove comment from copy-paste
reakaleek Jun 7, 2023
4fbf504
Fix label
reakaleek Jun 12, 2023
a967347
Add default aws region env
reakaleek Jun 12, 2023
38fe1c4
Move benchmarks script to a more appropriate folder
reakaleek Jun 12, 2023
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
14 changes: 14 additions & 0 deletions .buildkite/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
agents:
provider: "gcp"

steps:
- label: "Run the release"
key: "release"
commands: .ci/release.sh
artifact_paths:
- "release.txt"
- "**/target/*"

notify:
- slack: "#apm-agent-java"
if: 'build.state != "passed"'
126 changes: 126 additions & 0 deletions .ci/ReleaseChangelog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Instant;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.OptionalInt;
import java.util.function.Predicate;

public class ReleaseChangelog {

public static void main(String[] args) throws IOException {
if (args.length != 2) {
System.out.println("Expected exactly two arguments: <ChangelogFile> <VersionToRelease>");
System.exit(-1);
}
Path fileName = Paths.get(args[0]);
String version = args[1].trim();
if (!version.matches("\\d+\\.\\d+\\.\\d+")) {
System.out.println("Version must be in the format x.x.x but was not: " + version);
System.exit(-1);
}
Lines f = new Lines(Files.readAllLines(fileName, StandardCharsets.UTF_8));
int unreleasedStart = f.findLine(str -> str.trim().equals("=== Unreleased"), 0).orElseThrow() + 1;
int unreleasedEnd = f.findLine(str -> str.startsWith("[[release-notes-"), unreleasedStart).orElseThrow();

Lines changes = f.cut(unreleasedStart, unreleasedEnd);
f.insert(new Lines(List.of("")), unreleasedStart); //add a blank line below unreleased heading
changes.trim();

// a few sanity checks
if (changes.lineCount() == 0) {
System.out.println("Unreleased changes are empty, there must be something wrong!");
System.exit(-1);
}
OptionalInt wrongIndentedHeading = changes.findLine(str -> str.matches("^==?=?=?[^=].*"), 0);
if (wrongIndentedHeading.isPresent()) {
System.out.println("Found heading which is too high level (must be at least =====) within changes: "
+ changes.getLine(wrongIndentedHeading.getAsInt()));
System.exit(-1);
}

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd")
.withZone(ZoneOffset.UTC);

changes.insert(new Lines(List.of(
"",
String.format("[[release-notes-%s]]", version),
String.format("==== %s - %s", version, formatter.format(Instant.now())),
""
)), 0);

int majorVersion = Integer.parseInt(version.split("\\.")[0]);
String majorHeading = String.format("=== Java Agent version %d.x", majorVersion);
OptionalInt sectionStart = f.findLine(str -> str.trim().equals(majorHeading), 0);
if (sectionStart.isEmpty()) {
System.out.println("Could not find heading for major version: " + majorHeading);
System.out.println("Is this a new major version? If yes, please add an empty section for it manually to the Changelog");
System.exit(-1);
}

f.insert(changes, sectionStart.getAsInt() + 1);

Files.writeString(fileName, f.toString(), StandardCharsets.UTF_8);
}

static class Lines {

private final List<String> lines;

public Lines(List<String> lines) {
this.lines = new ArrayList<>(lines);
}

int lineCount() {
return lines.size();
}

OptionalInt findLine(Predicate<String> condition, int startAt) {
for (int i = startAt; i < lines.size(); i++) {
if (condition.test(lines.get(i))) {
return OptionalInt.of(i);
}
}
return OptionalInt.empty();
}

Lines cut(int startInclusive, int endExclusive) {
List<String> cutLines = new ArrayList<>();
for (int i = startInclusive; i < endExclusive; i++) {
cutLines.add(lines.remove(startInclusive));
}
return new Lines(cutLines);
}

void insert(Lines other, int insertAt) {
this.lines.addAll(insertAt, other.lines);
}

/**
* Trims lines consisting of only blanks at the top and bottom
*/
void trim() {
while (!lines.isEmpty() && lines.get(0).matches("\\s*")) {
lines.remove(0);
}
while (!lines.isEmpty() && lines.get(lines.size() - 1).matches("\\s*")) {
lines.remove(lines.size() - 1);
}
}

@Override
public String toString() {
return String.join("\n", lines);
}

public String getLine(int number) {
return lines.get(number);
}
}

}
26 changes: 26 additions & 0 deletions .ci/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
##
## It relies on the .buildkite/hooks/pre-command so the Vault and other tooling
## are prepared automatically by buildkite.
##

set -eo pipefail

# Make sure we delete this folder before leaving even in case of failure
clean_up () {
ARG=$?
export VAULT_TOKEN=$PREVIOUS_VAULT_TOKEN
echo "--- Deleting tmp workspace"
rm -rf $TMP_WORKSPACE
exit $ARG
}
trap clean_up EXIT

echo "--- Debug JDK installation :coffee:"
echo $JAVA_HOME
echo $PATH
java -version

set +x
echo "--- Deploy the release :package:"
./mvnw -V -s .ci/settings.xml -Pgpg clean deploy -DskipTests --batch-mode | tee release.txt
6 changes: 3 additions & 3 deletions .ci/release/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pipeline {
// If this fails, an exception should be thrown and execution will halt
dir("${BASE_DIR}"){
script {
def r = sh(label: "Check Maven status", script: "./scripts/jenkins/check_maven.sh -u https://status.maven.org/api/v2/summary.json --component OSSRH", returnStatus: true)
def r = sh(label: "Check Maven status", script: "./scripts/docker-release/check_maven.sh -u https://status.maven.org/api/v2/summary.json --component OSSRH", returnStatus: true)
if (r == 1) {
error("Failing release build because Maven is the OSSRH component is not fully operational. See https://status.maven.org/ for more details.")
}
Expand Down Expand Up @@ -264,10 +264,10 @@ pipeline {
dir("${BASE_DIR}"){
// fetch agent artifact from remote repository
withEnv(["SONATYPE_FALLBACK=1"]) {
sh(label: "Build Docker image", script: "./scripts/jenkins/build_docker.sh")
sh(label: "Build Docker image", script: "./scripts/docker-release/build_docker.sh")
// Get Docker registry credentials
dockerLogin(secret: "${ELASTIC_DOCKER_SECRET}", registry: 'docker.elastic.co', role_id: 'apm-vault-role-id', secret_id: 'apm-vault-secret-id')
sh(label: "Push Docker image", script: "./scripts/jenkins/push_docker.sh")
sh(label: "Push Docker image", script: "./scripts/docker-release/push_docker.sh")
}
}
}
Expand Down
File renamed without changes.
Loading