Skip to content

Commit fd8c584

Browse files
jbachorikclaude
andcommitted
utils: add script to update Sonatype credentials in SSM via aws-vault
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c68cfc1 commit fd8c584

2 files changed

Lines changed: 129 additions & 112 deletions

File tree

utils/README.md

Lines changed: 77 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
This directory contains utility scripts for managing the java-profiler project.
44

5-
## Release Script
5+
---
6+
7+
## Release
68

79
### `release.sh`
810

@@ -28,88 +30,22 @@ Triggers the Validated Release workflow using GitHub CLI to create a new release
2830
- `--commit <sha>`: Specify commit SHA to release (default: interactive selection)
2931
- `--help`: Show help message
3032

31-
**Examples:**
32-
33-
1. **Interactive commit selection** (recommended first step):
34-
```bash
35-
./utils/release.sh minor
36-
```
37-
This will show a nice arrow-key navigable menu of the last 10 commits.
38-
39-
2. **Perform an actual minor release** from main branch:
40-
```bash
41-
./utils/release.sh minor --no-dry-run
42-
```
43-
44-
3. **Release a specific commit**:
45-
```bash
46-
./utils/release.sh patch --commit abc123def456 --no-dry-run
47-
```
48-
49-
4. **Perform a patch release** from a release branch:
50-
```bash
51-
# Ensure you're on a release/X.Y._ branch
52-
git checkout release/1.35._
53-
./utils/release.sh patch --no-dry-run
54-
```
55-
56-
5. **Emergency patch** without tests (use with caution):
57-
```bash
58-
./utils/release.sh patch --no-dry-run --skip-tests
59-
```
60-
61-
**Branch Rules:**
62-
- **Major/Minor releases**: Must be run from the `main` branch
63-
- **Patch releases**: Must be run from a `release/X.Y._` branch
64-
65-
**Interactive Features:**
66-
- **Commit Selection**: If no `--commit` is specified, the script shows an interactive menu of the last 10 commits
67-
- Use ↑/↓ arrow keys to navigate
68-
- Press Enter to select a commit
69-
- Press 'q' to quit
70-
- **Comprehensive Summary**: After execution, displays a detailed summary of all actions performed, including any errors or warnings
71-
72-
**Release Flow:**
73-
1. Script validates inputs and branch rules
74-
2. Interactive commit selection (or use specified commit)
75-
3. Triggers GitHub Actions "Validated Release" workflow on selected commit
76-
4. Workflow runs pre-release tests (testDebug + testAsan)
77-
5. Workflow creates annotated git tag
78-
6. Tag push triggers GitLab build pipeline
79-
7. GitLab builds multi-platform artifacts
80-
8. GitLab publishes to Maven Central
81-
9. GitHub workflows create release with assets
82-
10. Script displays comprehensive execution summary
83-
84-
**Monitoring:**
85-
86-
After triggering the release, monitor progress:
87-
88-
```bash
89-
# Watch the workflow run in real-time
90-
gh run watch
91-
92-
# List recent workflow runs
93-
gh run list --workflow=release-validated.yml --limit 5
94-
95-
# View in browser
96-
gh workflow view release-validated.yml --web
97-
```
98-
99-
**Troubleshooting:**
33+
**Branch rules:**
34+
- **Major/Minor releases**: must be run from `main`
35+
- **Patch releases**: must be run from a `release/X.Y._` branch
10036

101-
If the release fails:
37+
**Release flow:**
38+
1. Validates inputs and branch rules
39+
2. Interactive commit selection (or use `--commit`)
40+
3. Triggers GitHub Actions "Validated Release" workflow
41+
4. Workflow runs pre-release tests, creates annotated git tag
42+
5. Tag push triggers GitLab build pipeline
43+
6. GitLab builds multi-platform artifacts and publishes to Maven Central
44+
7. GitHub workflows create release with assets
10245

103-
1. **Tests fail**: Fix the issues and re-run
104-
2. **Tag already exists**: Delete the tag and retry:
105-
```bash
106-
git tag -d v_X.Y.Z
107-
git push origin :v_X.Y.Z
108-
```
109-
3. **GitLab build fails**: Check GitLab pipeline and retry
110-
4. **Authentication issues**: Run `gh auth login`
46+
---
11147

112-
## Backport Script
48+
## Backport
11349

11450
### `backport-pr.sh`
11551

@@ -118,66 +54,95 @@ Cherry-picks a merged PR onto a release branch, pushes the backport branch, and
11854
**Prerequisites:**
11955
- [GitHub CLI](https://cli.github.com/) installed and authenticated
12056
- [jq](https://jqlang.github.io/jq/) installed
121-
- Clean working tree (no uncommitted changes)
57+
- Clean working tree
12258

12359
**Usage:**
12460
```bash
12561
./utils/backport-pr.sh [--dry-run] [<release-name>] <pr-number-or-url>
12662
```
12763

12864
**Arguments:**
129-
- `<release-name>`: Target release branch suffix, e.g. `1.9._` (maps to `release/1.9._`). If omitted, the script presents an interactive picker of the 10 most recent release branches.
130-
- `<pr-number-or-url>`: PR number (`420`) or full GitHub URL (`https://github.com/DataDog/java-profiler/pull/420`).
131-
- `--dry-run`: Show what would happen without making any changes.
65+
- `<release-name>`: Target release branch suffix, e.g. `1.9._` (maps to `release/1.9._`). If omitted, an interactive picker is shown.
66+
- `<pr-number-or-url>`: PR number (`420`) or full GitHub URL.
67+
- `--dry-run`: Preview without making changes.
13268

13369
**Examples:**
13470
```bash
135-
# Backport PR #420 to release/1.9._
13671
./utils/backport-pr.sh 1.9._ 420
72+
./utils/backport-pr.sh 420 # interactive branch selection
73+
./utils/backport-pr.sh --dry-run 1.9._ 420
74+
```
13775

138-
# Same, using a URL
139-
./utils/backport-pr.sh 1.9._ https://github.com/DataDog/java-profiler/pull/420
76+
---
14077

141-
# Interactive branch selection
142-
./utils/backport-pr.sh 420
78+
## Testing
14379

144-
# Preview without making changes
145-
./utils/backport-pr.sh --dry-run 1.9._ 420
146-
```
80+
### `run-docker-tests.sh`
14781

148-
**Features:**
149-
- Interactive release branch picker when no branch is specified
150-
- Accepts both PR numbers and full GitHub URLs
151-
- Single GitHub API call for all PR metadata
152-
- Warns if the PR is not merged and asks for confirmation
153-
- Handles squashed/garbage-collected commits by falling back to the merge commit
154-
- Detects and cleans up existing backport branches from previous attempts
155-
- Guided recovery on cherry-pick conflicts (does not leave you stranded)
156-
- Comments on the original PR with a link to the backport for traceability
157-
- Colored terminal output (degrades gracefully in non-TTY contexts)
158-
- Restores the original branch on completion or failure
82+
Runs tests in Docker across various OS/libc/JDK combinations, mirroring the CI matrix locally.
15983

160-
## Patch dd-java-agent Script
84+
**Usage:**
85+
```bash
86+
./utils/run-docker-tests.sh [options]
87+
--libc=glibc|musl (default: glibc)
88+
--jdk=8|11|17|21|25|8-j9|... (default: 21)
89+
--arch=x64|aarch64 (default: auto-detect)
90+
--config=debug|release|asan|tsan (default: debug)
91+
--tests="TestPattern" (optional)
92+
--gtest (enable C++ gtests)
93+
--shell (drop to shell instead of running tests)
94+
--mount (mount local repo instead of cloning)
95+
--rebuild (force rebuild of Docker images)
96+
```
16197

16298
### `patch-dd-java-agent.sh`
16399

164-
Patches a `dd-java-agent.jar` with locally-built ddprof library contents for quick local testing without a full dd-trace-java rebuild.
100+
Patches a `dd-java-agent.jar` with a locally-built ddprof library for quick local testing without a full dd-trace-java rebuild.
165101

166102
**Usage:**
167103
```bash
168-
DD_AGENT_JAR=path/to/dd-java-agent.jar DDPROF_JAR=path/to/ddprof.jar ./utils/patch-dd-java-agent.sh
104+
DD_AGENT_JAR=path/to/dd-java-agent.jar DDPROF_JAR=path/to/ddprof.jar \
105+
./utils/patch-dd-java-agent.sh
169106
```
170107

171-
## Cherry-Pick Scripts
108+
---
109+
110+
## Upstream Tracking
111+
112+
See [README_UPSTREAM_TRACKER.md](README_UPSTREAM_TRACKER.md) for full documentation.
113+
114+
### `check_upstream_changes.sh`
115+
116+
Wrapper to compare local files against a given upstream async-profiler commit and produce a change report.
117+
118+
### `track_upstream_changes.sh`
119+
120+
Core change detection and report generation logic.
121+
122+
### `generate_tracked_files.sh`
172123

173-
### `cherry.sh`
124+
Identifies which local files should be tracked against upstream (based on async-profiler copyright headers).
174125

175-
Helper script for cherry-picking commits from upstream async-profiler.
126+
### `check_contribution_candidates.sh`
176127

177-
### `init_cherypick_repo.sh`
128+
Identifies divergences from upstream async-profiler that could be contributed back.
178129

179-
Initializes the repository for cherry-picking from upstream.
130+
### `find_contribution_candidates.sh`
131+
132+
Core diff analysis and report generation for contribution candidate detection.
180133

181134
---
182135

183-
For more information about the release process, see `.github/workflows/release-validated.yml`.
136+
## CI / Ops
137+
138+
### `update-sonatype-credentials.sh`
139+
140+
Updates the Sonatype (Maven Central) OSSRH credentials stored in AWS SSM, used by the CI publish pipeline.
141+
142+
**Prerequisites:**
143+
- AWS CLI authenticated with `ssm:PutParameter` permission
144+
145+
**Usage:**
146+
```bash
147+
./utils/update-sonatype-credentials.sh <username> <token>
148+
```
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Update Sonatype (Maven Central) credentials in AWS SSM for java-profiler CI.
5+
#
6+
# Usage: update-sonatype-credentials.sh <username> <token>
7+
8+
AWS_REGION=us-east-1
9+
SSM_PREFIX=ci.java-profiler
10+
AWS_VAULT_PROFILE=sso-build-stable-developer
11+
12+
usage() {
13+
echo "Usage: $0 <username> <token>"
14+
echo ""
15+
echo "Updates Sonatype OSSRH credentials in AWS SSM:"
16+
echo " ${SSM_PREFIX}.sonatype_token_user"
17+
echo " ${SSM_PREFIX}.sonatype_token"
18+
exit 1
19+
}
20+
21+
if [ $# -ne 2 ]; then
22+
usage
23+
fi
24+
25+
USERNAME="$1"
26+
TOKEN="$2"
27+
28+
aws-vault login sso-build-stable-developer
29+
30+
# Verify AWS authentication
31+
if ! aws-vault exec "${AWS_VAULT_PROFILE}" -- aws sts get-caller-identity --query "Arn" --output text 2>/dev/null; then
32+
echo "ERROR: Not authenticated with AWS. Run 'aws-vault login ${AWS_VAULT_PROFILE}' and retry."
33+
exit 1
34+
fi
35+
36+
echo "Updating ${SSM_PREFIX}.sonatype_token_user ..."
37+
aws-vault exec "${AWS_VAULT_PROFILE}" -- aws ssm put-parameter \
38+
--region "${AWS_REGION}" \
39+
--name "${SSM_PREFIX}.sonatype_token_user" \
40+
--value "${USERNAME}" \
41+
--type SecureString \
42+
--overwrite
43+
44+
echo "Updating ${SSM_PREFIX}.sonatype_token ..."
45+
aws-vault exec "${AWS_VAULT_PROFILE}" -- aws ssm put-parameter \
46+
--region "${AWS_REGION}" \
47+
--name "${SSM_PREFIX}.sonatype_token" \
48+
--value "${TOKEN}" \
49+
--type SecureString \
50+
--overwrite
51+
52+
echo "Done."

0 commit comments

Comments
 (0)