Skip to content

Commit e1b11ee

Browse files
committed
feat: Document release process in RELEASE.md
- Add script to update versions - Add checks to make sure the JBang version is in sync with pom versions - Add workflow to create GH release
1 parent 1277f24 commit e1b11ee

File tree

6 files changed

+606
-0
lines changed

6 files changed

+606
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Fetch the property from the Maven project
2+
def scriptName = project.properties['jbang.script.name']
3+
4+
// Fail if the script property is missing
5+
if (scriptName == null) {
6+
System.err.println("[ERROR] JBang validator: No jbang.script.name set in properties")
7+
throw new IllegalStateException("[ERROR] JBang validator: No jbang.script.name set in properties")
8+
}
9+
10+
def jbangFile = new File(project.basedir, scriptName)
11+
if (!jbangFile.exists()) {
12+
// If a script name was explicitly provided but doesn't exist, fail.
13+
// If using the fallback, we might want to just skip (return true).
14+
System.err.println("[INFO] JBang validator: File not found: " + jbangFile.absolutePath)
15+
throw new IllegalStateException("[ERROR] JBang validator: File not found: " + jbangFile.absolutePath)
16+
}
17+
18+
def expectedVersion = project.version
19+
def groupPrefix = "//DEPS io.github.a2asdk:"
20+
def success = true
21+
22+
jbangFile.eachLine { line ->
23+
if (line.trim().startsWith(groupPrefix)) {
24+
def lastColon = line.lastIndexOf(":")
25+
if (lastColon != -1) {
26+
def actualVersion = line.substring(lastColon + 1).trim()
27+
if (actualVersion != expectedVersion) {
28+
System.err.println("[ERROR] JBang Version Mismatch in " + scriptName)
29+
System.err.println(" Expected: " + expectedVersion)
30+
System.err.println(" Found: " + actualVersion)
31+
success = false
32+
}
33+
}
34+
}
35+
}
36+
37+
if (!success) {
38+
throw new IllegalStateException("[ERROR] JBang version validation failed")
39+
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Create GitHub Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v?[0-9]+.[0-9]+.[0-9]+*' # Trigger on tags like v1.0.0, 1.2.3, v1.2.3.Alpha1 etc.
7+
8+
jobs:
9+
create-release:
10+
# Only run this job for the main repository, not for forks
11+
if: github.repository == 'a2aproject/a2a-java'
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write # Required to create releases
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0 # Fetch all history for changelog generation
21+
22+
- name: Extract version from tag
23+
id: version
24+
run: |
25+
# Remove 'v' prefix if present
26+
VERSION=${GITHUB_REF_NAME#v}
27+
echo "version=$VERSION" >> $GITHUB_OUTPUT
28+
echo "Version: $VERSION"
29+
30+
- name: Generate release notes
31+
id: release_notes
32+
uses: actions/github-script@v7
33+
with:
34+
script: |
35+
const version = '${{ steps.version.outputs.version }}';
36+
37+
// Get the previous tag
38+
let previousTag = '';
39+
try {
40+
const { data: tags } = await github.rest.repos.listTags({
41+
owner: context.repo.owner,
42+
repo: context.repo.repo,
43+
per_page: 100
44+
});
45+
46+
// Find current tag index
47+
const currentIndex = tags.findIndex(tag => tag.name === context.ref.replace('refs/tags/', ''));
48+
49+
// Get previous tag (next in list)
50+
if (currentIndex >= 0 && currentIndex < tags.length - 1) {
51+
previousTag = tags[currentIndex + 1].name;
52+
}
53+
} catch (error) {
54+
console.log('Could not fetch previous tag:', error.message);
55+
}
56+
57+
// Build release notes
58+
let releaseNotes = `## A2A Java SDK ${version}\n\n`;
59+
60+
// Add Maven Central installation instructions
61+
releaseNotes += `### Installation\n\n`;
62+
releaseNotes += `**Maven**:\n\`\`\`xml\n<dependency>\n`;
63+
releaseNotes += ` <groupId>io.github.a2asdk</groupId>\n`;
64+
releaseNotes += ` <artifactId>a2a-java-sdk-client</artifactId>\n`;
65+
releaseNotes += ` <version>${version}</version>\n`;
66+
releaseNotes += `</dependency>\n\`\`\`\n\n`;
67+
68+
releaseNotes += `**Gradle**:\n\`\`\`gradle\n`;
69+
releaseNotes += `implementation 'io.github.a2asdk:a2a-java-sdk-client:${version}'\n`;
70+
releaseNotes += `\`\`\`\n\n`;
71+
72+
// Add links
73+
releaseNotes += `### Links\n\n`;
74+
releaseNotes += `- [Maven Central](https://central.sonatype.com/artifact/io.github.a2asdk/a2a-java-sdk-parent/${version})\n`;
75+
releaseNotes += `- [JavaDoc](https://javadoc.io/doc/io.github.a2asdk/a2a-java-sdk-parent/${version})\n`;
76+
releaseNotes += `- [GitHub](https://github.com/a2aproject/a2a-java/tree/v${version})\n\n`;
77+
78+
// Add changelog header
79+
if (previousTag) {
80+
releaseNotes += `### Changes since ${previousTag}\n\n`;
81+
releaseNotes += `[Full Changelog](https://github.com/a2aproject/a2a-java/compare/${previousTag}...v${version})\n\n`;
82+
} else {
83+
releaseNotes += `### Changes\n\n`;
84+
}
85+
86+
return releaseNotes;
87+
88+
- name: Create GitHub Release
89+
uses: actions/github-script@v7
90+
with:
91+
script: |
92+
const version = '${{ steps.version.outputs.version }}';
93+
const tag = context.ref.replace('refs/tags/', '');
94+
const releaseNotes = ${{ steps.release_notes.outputs.result }};
95+
96+
// Determine if this is a pre-release
97+
const isPrerelease = version.includes('Alpha') ||
98+
version.includes('Beta') ||
99+
version.includes('RC') ||
100+
version.includes('SNAPSHOT');
101+
102+
try {
103+
const { data: release } = await github.rest.repos.createRelease({
104+
owner: context.repo.owner,
105+
repo: context.repo.repo,
106+
tag_name: tag,
107+
name: `v${version}`,
108+
body: releaseNotes,
109+
draft: false,
110+
prerelease: isPrerelease,
111+
generate_release_notes: true // GitHub will append auto-generated notes
112+
});
113+
114+
console.log(`✅ Created release: ${release.html_url}`);
115+
core.summary
116+
.addHeading(`Release v${version} Created`)
117+
.addLink('View Release', release.html_url)
118+
.addLink('Maven Central', `https://central.sonatype.com/artifact/io.github.a2asdk/a2a-java-sdk-parent/${version}`)
119+
.write();
120+
121+
} catch (error) {
122+
if (error.status === 422 && error.message.includes('already_exists')) {
123+
console.log('⚠️ Release already exists for this tag');
124+
} else {
125+
throw error;
126+
}
127+
}

0 commit comments

Comments
 (0)