Skip to content

Publish to Maven Central #1

Publish to Maven Central

Publish to Maven Central #1

Workflow file for this run

name: Publish to Maven Central
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
dry_run:
description: 'Dry run (skip actual publish)'
required: false
default: 'false'
type: boolean
jobs:
publish:
name: Publish to Maven Central
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate tag version
if: startsWith(github.ref, 'refs/tags/v')
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v}
GRADLE_VERSION=$(grep "ampereVersion=" gradle.properties | cut -d'=' -f2)
if [ "$TAG_VERSION" != "$GRADLE_VERSION" ]; then
echo "Error: Tag version ($TAG_VERSION) does not match gradle.properties ($GRADLE_VERSION)"
exit 1
fi
echo "Version validated: $TAG_VERSION"
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Create local.properties
run: |
cat > local.properties << 'EOF'
anthropic_api_key=placeholder
google_api_key=placeholder
openai_api_key=placeholder
EOF
- name: Run tests before publish
run: ./gradlew :ampere-core:jvmTest
- name: Publish to Maven Central
if: ${{ github.event.inputs.dry_run != 'true' }}
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
run: ./gradlew :ampere-core:publishAllPublicationsToOssrhRepository
- name: Dry run publish
if: ${{ github.event.inputs.dry_run == 'true' }}
run: |
echo "Dry run mode - skipping actual publish"
./gradlew :ampere-core:publishAllPublicationsToOssrhRepository --dry-run
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/v') && github.event.inputs.dry_run != 'true'
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
draft: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}