Skip to content

Update maven-publish.yml #14

Update maven-publish.yml

Update maven-publish.yml #14

Workflow file for this run

# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
name: Maven Package
on:
push:
branches: [ master, '**' ]
pull_request:
branches: [ master ]
release:
types: [created]
jobs:
build:
runs-on: aware
permissions:
contents: read
packages: write
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: Set up Maven settings
run: |
mkdir -p ~/.m2
cat <<EOF > ~/.m2/settings.xml
<settings>
<servers>
<server>
<id>github</id>
<username>$GITHUB_ACTOR</username>
<password>$GITHUB_TOKEN</password>
</server>
</servers>
</settings>
EOF
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Make Maven Wrapper executable
run: chmod +x ./mvnw
- name: Build with Maven
run: ./mvnw -B package -s ~/.m2/settings.xml --file pom.xml
- name: Publish to GitHub Packages Apache Maven
run: ./mvnw deploy -s ~/.m2/settings.xml
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Release to GitHub Packages Apache Maven
run: ./mvnw release:prepare release:perform -s ~/.m2/settings.xml
env:
GITHUB_TOKEN: ${{ secrets.PAT }}