Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
153 changes: 153 additions & 0 deletions .github/workflows/publish-maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
name: Publish Java SDK to Maven Central

env:
HUSKY: 0

on:
workflow_dispatch:
inputs:
dist-tag:
description: "Tag to publish under"
type: choice
required: true
default: "latest"
options:
- latest
- prerelease
version:
description: "Version override (optional, e.g., 1.0.0). If empty, auto-increments."
type: string
required: false

permissions:
contents: write
id-token: write

concurrency:
group: publish-maven
cancel-in-progress: false

jobs:
# Calculate version using the nodejs version script (shared across all SDKs)
version:
name: Calculate Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.VERSION }}
current: ${{ steps.version.outputs.CURRENT }}
current-prerelease: ${{ steps.version.outputs.CURRENT_PRERELEASE }}
defaults:
run:
working-directory: ./nodejs
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: "22.x"
- run: npm ci --ignore-scripts
- name: Get version
id: version
run: |
CURRENT="$(node scripts/get-version.js current)"
echo "CURRENT=$CURRENT" >> $GITHUB_OUTPUT
echo "Current latest version: $CURRENT" >> $GITHUB_STEP_SUMMARY
CURRENT_PRERELEASE="$(node scripts/get-version.js current-prerelease)"
echo "CURRENT_PRERELEASE=$CURRENT_PRERELEASE" >> $GITHUB_OUTPUT
echo "Current prerelease version: $CURRENT_PRERELEASE" >> $GITHUB_STEP_SUMMARY
if [ -n "${{ github.event.inputs.version }}" ]; then
VERSION="${{ github.event.inputs.version }}"
# Validate version format matches dist-tag
if [ "${{ github.event.inputs.dist-tag }}" = "latest" ]; then
if [[ "$VERSION" == *-* ]]; then
echo "❌ Error: Version '$VERSION' has a prerelease suffix but dist-tag is 'latest'" >> $GITHUB_STEP_SUMMARY
echo "Use a version without suffix (e.g., '1.0.0') for latest releases"
exit 1
fi
else
if [[ "$VERSION" != *-* ]]; then
echo "❌ Error: Version '$VERSION' has no prerelease suffix but dist-tag is 'prerelease'" >> $GITHUB_STEP_SUMMARY
echo "Use a version with suffix (e.g., '1.0.0-preview.0') for prerelease"
exit 1
fi
fi
echo "Using manual version override: $VERSION" >> $GITHUB_STEP_SUMMARY
else
VERSION="$(node scripts/get-version.js ${{ github.event.inputs.dist-tag }})"
echo "Auto-incremented version: $VERSION" >> $GITHUB_STEP_SUMMARY
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT

publish-maven:
name: Publish Java SDK to Maven Central
needs: version
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./java
steps:
- uses: actions/checkout@v6

- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: "21"
distribution: "temurin"
server-id: central
server-username: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
server-password: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

- name: Set version in pom.xml
run: mvn versions:set -DnewVersion=${{ needs.version.outputs.version }} -DgenerateBackupPoms=false

- name: Build and verify
run: mvn clean verify -DskipTests

- name: Deploy to Maven Central
run: mvn deploy -DskipTests -Prelease
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: java-package
path: java/target/*.jar

github-release:
name: Create GitHub Release
needs: [version, publish-maven]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Create GitHub Release
if: github.event.inputs.dist-tag == 'latest'
run: |
NOTES_FLAG=""
if git rev-parse "v${{ needs.version.outputs.current }}" >/dev/null 2>&1; then
NOTES_FLAG="--notes-start-tag v${{ needs.version.outputs.current }}"
fi
gh release create "java/v${{ needs.version.outputs.version }}" \
--title "Java SDK v${{ needs.version.outputs.version }}" \
--generate-notes $NOTES_FLAG \
--target ${{ github.sha }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Pre-Release
if: github.event.inputs.dist-tag == 'prerelease'
run: |
NOTES_FLAG=""
if git rev-parse "v${{ needs.version.outputs.current-prerelease }}" >/dev/null 2>&1; then
NOTES_FLAG="--notes-start-tag v${{ needs.version.outputs.current-prerelease }}"
fi
gh release create "java/v${{ needs.version.outputs.version }}" \
--prerelease \
--title "Java SDK v${{ needs.version.outputs.version }}" \
--generate-notes $NOTES_FLAG \
--target ${{ github.sha }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37 changes: 37 additions & 0 deletions .github/workflows/sdk-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,40 @@ jobs:
env:
COPILOT_HMAC_KEY: ${{ secrets.COPILOT_DEVELOPER_CLI_INTEGRATION_HMAC_KEY }}
run: dotnet test --no-build -v n

java-sdk:
name: "Java SDK Tests"

runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ./java
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-copilot
- uses: actions/setup-java@v5
with:
java-version: "21"
distribution: "temurin"

- name: Run spotless check
run: |
mvn spotless:check
if [ $? -ne 0 ]; then
echo "❌ spotless:check failed. Please run 'mvn spotless:apply' in java"
exit 1
fi
echo "✅ spotless:check passed"

- name: Build SDK
run: mvn compile

- name: Install test harness dependencies
working-directory: ./test/harness
run: npm ci --ignore-scripts

- name: Run Java SDK tests
env:
COPILOT_HMAC_KEY: ${{ secrets.COPILOT_DEVELOPER_CLI_INTEGRATION_HMAC_KEY }}
run: mvn verify
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ All SDKs are in technical preview and may change in breaking ways as we move tow
| **Python** | [`./python/`](./python/README.md) | `pip install github-copilot-sdk` |
| **Go** | [`./go/`](./go/README.md) | `go get github.com/github/copilot-sdk/go` |
| **.NET** | [`./dotnet/`](./dotnet/README.md) | `dotnet add package GitHub.Copilot.SDK` |
| **Java** | [`./java/`](./java/README.md) | Add dependency (see [README](./java/README.md)) |

See the individual SDK READMEs for installation, usage examples, and API reference.

Expand Down
36 changes: 36 additions & 0 deletions java/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar

# IDE
.idea/
*.iml
*.ipr
*.iws
.vscode/
.settings/
.project
.classpath
*.swp
*.swo
*~

# Build
build/
out/
bin/

# OS
.DS_Store
Thumbs.db

# Logs
*.log
3 changes: 3 additions & 0 deletions java/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
wrapperVersion=3.3.4
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.12/apache-maven-3.9.12-bin.zip
Loading