cicd#187
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a GitHub Actions workflow to build the Maven project and publish artifacts to GitHub Packages when a GitHub Release event occurs.
Changes:
- Introduces
.github/workflows/maven-publish.ymlto run Maven package + deploy on release events. - Configures
actions/setup-javafor Maven publishing via generatedsettings.xml.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - uses: actions/checkout@v4 | ||
| - name: Set up JDK 11 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: '11' | ||
| distribution: 'temurin' | ||
| server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | ||
| settings-path: ${{ github.workspace }} # location for the settings.xml file | ||
|
|
||
| - name: Build with Maven | ||
| run: mvn -B package --file pom.xml | ||
|
|
||
| - name: Publish to GitHub Packages Apache Maven | ||
| run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml | ||
| env: | ||
| GITHUB_TOKEN: ${{ github.token }} |
There was a problem hiding this comment.
steps: list items are not indented under the steps key. As written, the YAML is invalid and the workflow will fail to load; indent each - name / - uses entry under steps: (e.g., two spaces deeper than steps:).
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 11 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '11' | |
| distribution: 'temurin' | |
| server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | |
| settings-path: ${{ github.workspace }} # location for the settings.xml file | |
| - name: Build with Maven | |
| run: mvn -B package --file pom.xml | |
| - name: Publish to GitHub Packages Apache Maven | |
| run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 11 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '11' | |
| distribution: 'temurin' | |
| server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | |
| settings-path: ${{ github.workspace }} # location for the settings.xml file | |
| - name: Build with Maven | |
| run: mvn -B package --file pom.xml | |
| - name: Publish to GitHub Packages Apache Maven | |
| run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} |
|
|
||
| on: | ||
| release: | ||
| types: [created] |
There was a problem hiding this comment.
This workflow triggers on release: types: [created], which also runs for draft releases and before a release is actually published. If the intent is to publish packages only for finalized releases, use types: [published] (or explicitly handle drafts/prereleases).
| types: [created] | |
| types: [published] |
| - name: Set up JDK 11 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: '11' |
There was a problem hiding this comment.
The workflow sets up JDK 11, but the root pom.xml declares <java.version>1.8</java.version>. Consider aligning the workflow JDK version to the project’s declared target (or updating the POM) to avoid inconsistent build behavior across local/CI environments.
| - name: Set up JDK 11 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '11' | |
| - name: Set up JDK 8 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '8' |
| run: mvn -B package --file pom.xml | ||
|
|
||
| - name: Publish to GitHub Packages Apache Maven | ||
| run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml |
There was a problem hiding this comment.
actions/setup-java is configured with server-id: github, but the repository POMs do not define any <distributionManagement> repository with id github. As a result, mvn deploy will fail (no deployment repository configured). Add an appropriate <distributionManagement> section (matching github) or pass an explicit deployment repository via Maven CLI options.
| run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml | |
| run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml -DaltDeploymentRepository=github::default::https://maven.pkg.github.com/${{ github.repository }} |
cicd