66on :
77 workflow_dispatch :
88 inputs :
9- dist-tag :
10- description : " Tag to publish under"
11- type : choice
12- required : true
13- default : " latest"
14- options :
15- - latest
16- - prerelease
179 version :
18- description : " Version override (optional, e.g., 1.0.0 ). If empty, auto-increments ."
10+ description : " Version to publish (optional). If empty, uses version from pom.xml ."
1911 type : string
2012 required : false
13+ prerelease :
14+ description : " Is this a prerelease?"
15+ type : boolean
16+ required : false
17+ default : false
2118
2219permissions :
2320 contents : write
@@ -28,80 +25,45 @@ concurrency:
2825 cancel-in-progress : false
2926
3027jobs :
31- # Calculate version using the nodejs version script (shared across all SDKs)
32- version :
33- name : Calculate Version
28+ publish-maven :
29+ name : Publish Java SDK to Maven Central
3430 runs-on : ubuntu-latest
3531 outputs :
36- version : ${{ steps.version.outputs.VERSION }}
37- current : ${{ steps.version.outputs.CURRENT }}
38- current-prerelease : ${{ steps.version.outputs.CURRENT_PRERELEASE }}
39- defaults :
40- run :
41- working-directory : ./nodejs
32+ version : ${{ steps.get-version.outputs.version }}
4233 steps :
4334 - uses : actions/checkout@v6
44- - uses : actions/setup-node@v6
4535 with :
46- node-version : " 22.x"
47- - run : npm ci --ignore-scripts
48- - name : Get version
49- id : version
50- run : |
51- CURRENT="$(node scripts/get-version.js current)"
52- echo "CURRENT=$CURRENT" >> $GITHUB_OUTPUT
53- echo "Current latest version: $CURRENT" >> $GITHUB_STEP_SUMMARY
54- CURRENT_PRERELEASE="$(node scripts/get-version.js current-prerelease)"
55- echo "CURRENT_PRERELEASE=$CURRENT_PRERELEASE" >> $GITHUB_OUTPUT
56- echo "Current prerelease version: $CURRENT_PRERELEASE" >> $GITHUB_STEP_SUMMARY
57- if [ -n "${{ github.event.inputs.version }}" ]; then
58- VERSION="${{ github.event.inputs.version }}"
59- # Validate version format matches dist-tag
60- if [ "${{ github.event.inputs.dist-tag }}" = "latest" ]; then
61- if [[ "$VERSION" == *-* ]]; then
62- echo "❌ Error: Version '$VERSION' has a prerelease suffix but dist-tag is 'latest'" >> $GITHUB_STEP_SUMMARY
63- echo "Use a version without suffix (e.g., '1.0.0') for latest releases"
64- exit 1
65- fi
66- else
67- if [[ "$VERSION" != *-* ]]; then
68- echo "❌ Error: Version '$VERSION' has no prerelease suffix but dist-tag is 'prerelease'" >> $GITHUB_STEP_SUMMARY
69- echo "Use a version with suffix (e.g., '1.0.0-preview.0') for prerelease"
70- exit 1
71- fi
72- fi
73- echo "Using manual version override: $VERSION" >> $GITHUB_STEP_SUMMARY
74- else
75- VERSION="$(node scripts/get-version.js ${{ github.event.inputs.dist-tag }})"
76- echo "Auto-incremented version: $VERSION" >> $GITHUB_STEP_SUMMARY
77- fi
78- echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
36+ fetch-depth : 0
37+ token : ${{ secrets.GITHUB_TOKEN }}
7938
80- publish-maven :
81- name : Publish Java SDK to Maven Central
82- needs : version
83- runs-on : ubuntu-latest
84- defaults :
85- run :
86- working-directory : ./java
87- steps :
88- - uses : actions/checkout@v6
39+ - name : Configure Git for Maven Release
40+ run : |
41+ git config user.name "github-actions[bot]"
42+ git config user.email "github-actions[bot]@users.noreply.github.com"
8943
90- - uses : ./.github/actions/ setup-copilot
44+ - uses : ./.github/setup-copilot
9145
9246 - name : Set up JDK 21
9347 uses : actions/setup-java@v5
9448 with :
9549 java-version : " 21"
9650 distribution : " temurin"
9751 server-id : central
98- server-username : ${{ secrets.MAVEN_CENTRAL_USERNAME }}
99- server-password : ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
52+ server-username : MAVEN_USERNAME
53+ server-password : MAVEN_PASSWORD
10054 gpg-private-key : ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
101- gpg-passphrase : ${{ secrets. MAVEN_GPG_PASSPHRASE }}
55+ gpg-passphrase : MAVEN_GPG_PASSPHRASE
10256
10357 - name : Set version in pom.xml
104- run : mvn versions:set -DnewVersion=${{ needs.version.outputs.version }} -DgenerateBackupPoms=false
58+ if : ${{ github.event.inputs.version != '' }}
59+ run : mvn versions:set -DnewVersion=${{ github.event.inputs.version }} -DgenerateBackupPoms=false
60+
61+ - name : Get version
62+ id : get-version
63+ run : |
64+ VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
65+ echo "version=$VERSION" >> $GITHUB_OUTPUT
66+ echo "Publishing version: $VERSION" >> $GITHUB_STEP_SUMMARY
10567
10668 - name : Build and verify
10769 run : mvn verify
@@ -115,35 +77,17 @@ jobs:
11577
11678 github-release :
11779 name : Create GitHub Release
118- needs : [version, publish-maven]
80+ needs : publish-maven
11981 if : github.ref == 'refs/heads/main'
12082 runs-on : ubuntu-latest
12183 steps :
12284 - uses : actions/checkout@v6
12385 - name : Create GitHub Release
124- if : github.event.inputs.dist-tag == 'latest'
125- run : |
126- NOTES_FLAG=""
127- if git rev-parse "v${{ needs.version.outputs.current }}" >/dev/null 2>&1; then
128- NOTES_FLAG="--notes-start-tag v${{ needs.version.outputs.current }}"
129- fi
130- gh release create "java/v${{ needs.version.outputs.version }}" \
131- --title "Java SDK v${{ needs.version.outputs.version }}" \
132- --generate-notes $NOTES_FLAG \
133- --target ${{ github.sha }}
134- env :
135- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
136- - name : Create GitHub Pre-Release
137- if : github.event.inputs.dist-tag == 'prerelease'
13886 run : |
139- NOTES_FLAG=""
140- if git rev-parse "v${{ needs.version.outputs.current-prerelease }}" >/dev/null 2>&1; then
141- NOTES_FLAG="--notes-start-tag v${{ needs.version.outputs.current-prerelease }}"
142- fi
143- gh release create "java/v${{ needs.version.outputs.version }}" \
144- --prerelease \
145- --title "Copilot SDK Java v${{ needs.version.outputs.version }}" \
146- --generate-notes $NOTES_FLAG \
87+ gh release create "java/v${{ needs.publish-maven.outputs.version }}" \
88+ ${{ github.event.inputs.prerelease == 'true' && '--prerelease' || '' }} \
89+ --title "Java SDK v${{ needs.publish-maven.outputs.version }}" \
90+ --generate-notes \
14791 --target ${{ github.sha }}
14892 env :
14993 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments