Skip to content

Maven Package

Maven Package #1

Workflow file for this run

name: Maven Package
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
server-id: github
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Create settings.xml
run: |
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $GITHUB_WORKSPACE/settings.xml
echo "<settings xmlns=\"http://maven.apache.org/SETTINGS/1.0.0\"" >> $GITHUB_WORKSPACE/settings.xml
echo " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" >> $GITHUB_WORKSPACE/settings.xml
echo " xsi:schemaLocation=\"http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd\">" >> $GITHUB_WORKSPACE/settings.xml
echo " <servers>" >> $GITHUB_WORKSPACE/settings.xml
echo " <server>" >> $GITHUB_WORKSPACE/settings.xml
echo " <id>github</id>" >> $GITHUB_WORKSPACE/settings.xml
echo " <username>${{ secrets.GH_USERNAME }}</username>" >> $GITHUB_WORKSPACE/settings.xml
echo " <password>${{ secrets.GITHUB_TOKEN }}</password>" >> $GITHUB_WORKSPACE/settings.xml
echo " </server>" >> $GITHUB_WORKSPACE/settings.xml
echo " </servers>" >> $GITHUB_WORKSPACE/settings.xml
echo " <profiles>" >> $GITHUB_WORKSPACE/settings.xml
echo " <profile>" >> $GITHUB_WORKSPACE/settings.xml
echo " <id>github-packages</id>" >> $GITHUB_WORKSPACE/settings.xml
echo " <repositories>" >> $GITHUB_WORKSPACE/settings.xml
echo " <repository>" >> $GITHUB_WORKSPACE/settings.xml
echo " <id>github</id>" >> $GITHUB_WORKSPACE/settings.xml
echo " <url>https://maven.pkg.github.com/GH_USERNAME/spring-rest-api-exception-lib</url>" >> $GITHUB_WORKSPACE/settings.xml
echo " <releases>" >> $GITHUB_WORKSPACE/settings.xml
echo " <enabled>true</enabled>" >> $GITHUB_WORKSPACE/settings.xml
echo " </releases>" >> $GITHUB_WORKSPACE/settings.xml
echo " <snapshots>" >> $GITHUB_WORKSPACE/settings.xml
echo " <enabled>true</enabled>" >> $GITHUB_WORKSPACE/settings.xml
echo " </snapshots>" >> $GITHUB_WORKSPACE/settings.xml
echo " </repository>" >> $GITHUB_WORKSPACE/settings.xml
echo " </repositories>" >> $GITHUB_WORKSPACE/settings.xml
echo " </profile>" >> $GITHUB_WORKSPACE/settings.xml
echo " </profiles>" >> $GITHUB_WORKSPACE/settings.xml
echo " <activeProfiles>" >> $GITHUB_WORKSPACE/settings.xml
echo " <activeProfile>github-packages</activeProfile>" >> $GITHUB_WORKSPACE/settings.xml
echo " </activeProfiles>" >> $GITHUB_WORKSPACE/settings.xml
echo "</settings>" >> $GITHUB_WORKSPACE/settings.xml
- 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: ${{ secrets.GITHUB_TOKEN }}