Skip to content

Commit 6f5c8be

Browse files
authored
chore: automate releasing to Maven central when a tag happens. (#197)
# Description Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [x] Follow the [`CONTRIBUTING` Guide](../CONTRIBUTING.md). - [x] Make your Pull Request title in the <https://www.conventionalcommits.org/> specification. - Important Prefixes for [release-please](https://github.com/googleapis/release-please): - `fix:` which represents bug fixes, and correlates to a [SemVer](https://semver.org/) patch. - `feat:` represents a new feature, and correlates to a SemVer minor. - `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking change (indicated by the `!`) and will result in a SemVer major. - [x] Ensure the tests pass - [x] Appropriate READMEs were updated (if necessary) Fixes #<issue_number_goes_here> 🦕
1 parent bc3c8cb commit 6f5c8be

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish release to Maven Central
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+
publish:
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: read
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up JDK 17
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: '17'
24+
distribution: 'temurin'
25+
cache: maven
26+
27+
# Use secrets to import GPG key
28+
- name: Import GPG key
29+
uses: crazy-max/ghaction-import-gpg@v6
30+
with:
31+
gpg_private_key: ${{ secrets.GPG_SIGNING_KEY }}
32+
passphrase: ${{ secrets.GPG_SIGNING_PASSPHRASE }}
33+
34+
# Create settings.xml for Maven since it needs the 'central-a2asdk-temp' server.
35+
# Populate wqith username and password from secrets
36+
- name: Create settings.xml
37+
run: |
38+
mkdir -p ~/.m2
39+
echo "<settings><servers><server><id>central-a2asdk-temp</id><username>${{ secrets.CENTRAL_TOKEN_USERNAME }}</username><password>${{ secrets.CENTRAL_TOKEN_PASSWORD }}</password></server></servers></settings>" > ~/.m2/settings.xml
40+
41+
# Deploy to Maven Central
42+
# -s uses the settings file we created.
43+
- name: Publish to Maven Central
44+
run: >
45+
mvn -B deploy
46+
-s ~/.m2/settings.xml
47+
-P release
48+
-DskipTests
49+
-Drelease.auto.publish=true
50+
env:
51+
# GPG passphrase is set as an environment variable for the gpg plugin to use
52+
GPG_PASSPHRASE: ${{ secrets.GPG_SIGNING_PASSPHRASE }}

pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262

6363
<!-- Redirect test output to file -->
6464
<maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
65+
66+
<!-- release properties -->
67+
<release.auto.publish>false</release.auto.publish>
6568
</properties>
6669

6770
<dependencyManagement>
@@ -206,6 +209,7 @@
206209
<configuration>
207210
<!-- This should point to a server entry in your settings.xml -->
208211
<publishingServerId>central-a2asdk-temp</publishingServerId>
212+
<autoPublish>${release.auto.publish}</autoPublish>
209213
</configuration>
210214
</plugin>
211215
<plugin>

0 commit comments

Comments
 (0)