-
Notifications
You must be signed in to change notification settings - Fork 0
Add Deploy Snapshot to Maven Central Portal workflow #559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
27b7689
Create action.yml
vibhutikumar07 7d3003e
Create deploy-central-snapshot.yml
vibhutikumar07 910dbf8
Remove artifact upload/download from snapshot workflow
vibhutikumar07 d20b437
Update pom.xml
vibhutikumar07 290656e
Add deploy-central-snapshot profile to sdm/pom.xml child module
vibhutikumar07 02063a9
Updated the workflow
vibhutikumar07 20c08b8
Removed run on push
vibhutikumar07 bf66512
Fix snapshot deploy: disable central-publishing-plugin extension in d…
vibhutikumar07 60fb9fe
Update action.yml
vibhutikumar07 20833cb
Update action.yml
vibhutikumar07 06b3b66
Update main-build-and-deploy-oss.yml
vibhutikumar07 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| name: Deploy Snapshot to Central Portal | ||
| description: "Deploys a Maven SNAPSHOT package to Sonatype Central Portal Snapshots repository." | ||
|
|
||
| inputs: | ||
| user: | ||
| description: "Sonatype Central Portal username (same as Maven Central)" | ||
| required: true | ||
| password: | ||
| description: "Sonatype Central Portal password (same as Maven Central)" | ||
| required: true | ||
| pgp-pub-key: | ||
| description: "The public pgp key ID (optional for snapshots but recommended)" | ||
| required: false | ||
| pgp-private-key: | ||
| description: "The private pgp key (optional for snapshots but recommended)" | ||
| required: false | ||
| pgp-passphrase: | ||
| description: "The passphrase for pgp (optional for snapshots but recommended)" | ||
| required: false | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: "Setup Java" | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: 'sapmachine' | ||
| java-version: '21' | ||
| cache: maven | ||
| server-id: central | ||
| server-username: CENTRAL_USER | ||
| server-password: CENTRAL_PASSWORD | ||
|
|
||
| - name: "Import GPG Key (if provided)" | ||
| if: ${{ inputs.pgp-private-key != '' }} | ||
| run: | | ||
| set +x | ||
| echo "::add-mask::$PGP_PRIVATE_KEY" | ||
| echo "::add-mask::$PASSPHRASE" | ||
| echo "$PGP_PRIVATE_KEY" | gpg --batch --passphrase "$PASSPHRASE" --import | ||
| shell: bash | ||
| env: | ||
| PGP_PRIVATE_KEY: ${{ inputs.pgp-private-key }} | ||
| PASSPHRASE: ${{ inputs.pgp-passphrase }} | ||
|
|
||
| - name: "Verify SNAPSHOT version" | ||
| run: | | ||
| VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | ||
| echo "Current version: $VERSION" | ||
| if [[ ! "$VERSION" == *-SNAPSHOT ]]; then | ||
| echo "Error: Version $VERSION is not a SNAPSHOT version!" | ||
| echo "Central Portal Snapshots repository only accepts SNAPSHOT versions." | ||
| exit 1 | ||
| fi | ||
| echo "✅ Version $VERSION is a valid SNAPSHOT" | ||
| shell: bash | ||
|
|
||
| - name: "Deploy Snapshot to Central Portal" | ||
| run: | | ||
| set +x | ||
| echo "::add-mask::$CENTRAL_USER" | ||
| echo "::add-mask::$CENTRAL_PASSWORD" | ||
| [ -n "$GPG_PASSPHRASE" ] && echo "::add-mask::$GPG_PASSPHRASE" | ||
| [ -n "$GPG_PUB_KEY" ] && echo "::add-mask::$GPG_PUB_KEY" | ||
| echo "🚀 Deploying SNAPSHOT to Sonatype Central Portal..." | ||
| if [ -n "$GPG_PASSPHRASE" ] && [ -n "$GPG_PUB_KEY" ]; then | ||
| mvn -B -ntp --show-version \ | ||
| -Dmaven.install.skip=true \ | ||
| -Dmaven.test.skip=true \ | ||
| -Dgpg.passphrase="$GPG_PASSPHRASE" \ | ||
| -Dgpg.keyname="$GPG_PUB_KEY" \ | ||
| clean deploy -P deploy-central-snapshot | ||
| else | ||
| mvn -B -ntp --show-version \ | ||
| -Dmaven.install.skip=true \ | ||
| -Dmaven.test.skip=true \ | ||
| -Dgpg.skip=true \ | ||
| clean deploy -P deploy-central-snapshot | ||
| fi | ||
| echo "✅ Snapshot deployed successfully!" | ||
| shell: bash | ||
| env: | ||
| CENTRAL_USER: ${{ inputs.user }} | ||
| CENTRAL_PASSWORD: ${{ inputs.password }} | ||
| GPG_PASSPHRASE: ${{ inputs.pgp-passphrase }} | ||
| GPG_PUB_KEY: ${{ inputs.pgp-pub-key }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| name: Deploy Snapshot to Central Portal | ||
|
|
||
| env: | ||
| JAVA_VERSION: '21' | ||
|
|
||
| on: | ||
| # Manual trigger - select any branch from GitHub UI | ||
| workflow_dispatch: | ||
| inputs: | ||
| sign_artifacts: | ||
| description: 'Sign artifacts with GPG' | ||
| required: false | ||
| default: 'true' | ||
| type: choice | ||
| options: | ||
| - 'true' | ||
| - 'false' | ||
|
|
||
|
|
||
| permissions: | ||
| contents: read | ||
| packages: read | ||
|
|
||
| jobs: | ||
| verify-snapshot: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| is_snapshot: ${{ steps.check.outputs.is_snapshot }} | ||
| version: ${{ steps.check.outputs.version }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Set up Java | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: 'temurin' | ||
| java-version: ${{ env.JAVA_VERSION }} | ||
| cache: maven | ||
|
|
||
| - name: Check version is SNAPSHOT | ||
| id: check | ||
| run: | | ||
| VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | ||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
| if [[ "$VERSION" == *-SNAPSHOT ]]; then | ||
| echo "is_snapshot=true" >> $GITHUB_OUTPUT | ||
| echo "✅ Version $VERSION is a SNAPSHOT" | ||
| else | ||
| echo "is_snapshot=false" >> $GITHUB_OUTPUT | ||
| echo "❌ Version $VERSION is NOT a SNAPSHOT - deployment will be skipped" | ||
| fi | ||
|
|
||
| build: | ||
| runs-on: ubuntu-latest | ||
| needs: verify-snapshot | ||
| if: needs.verify-snapshot.outputs.is_snapshot == 'true' | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Set up Java | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: 'temurin' | ||
| java-version: ${{ env.JAVA_VERSION }} | ||
| cache: maven | ||
|
|
||
| - name: Build | ||
| run: | | ||
| echo "🔨 Building SNAPSHOT version: ${{ needs.verify-snapshot.outputs.version }}" | ||
| mvn clean install -P unit-tests -DskipIntegrationTests | ||
| echo "✅ Build completed successfully!" | ||
|
|
||
| deploy: | ||
| name: Deploy Snapshot to Central Portal | ||
| runs-on: ubuntu-latest | ||
| needs: [verify-snapshot, build] | ||
| if: needs.verify-snapshot.outputs.is_snapshot == 'true' && needs.build.result == 'success' | ||
| environment: maven-central | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Deploy Snapshot (with GPG signing) | ||
| if: github.event.inputs.sign_artifacts != 'false' | ||
| uses: ./.github/actions/deploy-central-snapshot | ||
| with: | ||
| user: ${{ secrets.CENTRAL_REPOSITORY_USER }} | ||
| password: ${{ secrets.CENTRAL_REPOSITORY_PASS }} | ||
| pgp-pub-key: ${{ secrets.PGP_PUB_KEY }} | ||
| pgp-private-key: ${{ secrets.PGP_PRIVATE_KEY }} | ||
| pgp-passphrase: ${{ secrets.PGP_PASSPHRASE }} | ||
|
|
||
| - name: Deploy Snapshot (without GPG signing) | ||
| if: github.event.inputs.sign_artifacts == 'false' | ||
| uses: ./.github/actions/deploy-central-snapshot | ||
| with: | ||
| user: ${{ secrets.CENTRAL_REPOSITORY_USER }} | ||
| password: ${{ secrets.CENTRAL_REPOSITORY_PASS }} | ||
|
|
||
| - name: Summary | ||
| if: success() | ||
| run: | | ||
| echo "## 🚀 Snapshot Deployed to Central Portal" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "**Version:** ${{ needs.verify-snapshot.outputs.version }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "**Repository:** https://central.sonatype.com/repository/maven-snapshots/" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "### Usage" >> $GITHUB_STEP_SUMMARY | ||
| echo '```xml' >> $GITHUB_STEP_SUMMARY | ||
| echo '<repositories>' >> $GITHUB_STEP_SUMMARY | ||
| echo ' <repository>' >> $GITHUB_STEP_SUMMARY | ||
| echo ' <id>central-snapshots</id>' >> $GITHUB_STEP_SUMMARY | ||
| echo ' <url>https://central.sonatype.com/repository/maven-snapshots/</url>' >> $GITHUB_STEP_SUMMARY | ||
| echo ' <snapshots><enabled>true</enabled></snapshots>' >> $GITHUB_STEP_SUMMARY | ||
| echo ' </repository>' >> $GITHUB_STEP_SUMMARY | ||
| echo '</repositories>' >> $GITHUB_STEP_SUMMARY | ||
| echo '```' >> $GITHUB_STEP_SUMMARY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.