-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added .github/workflow/maven-build.yml
- Loading branch information
Showing
1 changed file
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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: Maven Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
workflow_dispatch: # Enables manual execution | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '23' | ||
distribution: 'temurin' | ||
|
||
- name: Configure Maven | ||
run: | | ||
mkdir -p ~/.m2 | ||
echo "<settings xmlns=\"http://maven.apache.org/SETTINGS/1.0.0\" | ||
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" | ||
xsi:schemaLocation=\"http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd\"> | ||
<activeProfiles> | ||
<activeProfile>github</activeProfile> | ||
</activeProfiles> | ||
<profiles> | ||
<profile> | ||
<id>github</id> | ||
<repositories> | ||
<repository> | ||
<id>central</id> | ||
<url>https://repo1.maven.org/maven2</url> | ||
</repository> | ||
<repository> | ||
<id>github</id> | ||
<url>https://maven.pkg.github.com/clanie/m2-repo</url> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
</snapshots> | ||
</repository> | ||
</repositories> | ||
</profile> | ||
</profiles> | ||
<servers> | ||
<server> | ||
<id>github</id> | ||
<username>${{ secrets.MAVEN_USERNAME }}</username> | ||
<password>${{ secrets.MAVEN_PASSWORD }}</password> | ||
</server> | ||
<server> | ||
<id>github-releases</id> | ||
<username>${{ secrets.MAVEN_USERNAME }}</username> | ||
<password>${{ secrets.MAVEN_PASSWORD }}</password> | ||
</server> | ||
<server> | ||
<id>github-snapshots</id> | ||
<username>${{ secrets.MAVEN_USERNAME }}</username> | ||
<password>${{ secrets.MAVEN_PASSWORD }}</password> | ||
</server> | ||
</servers> | ||
</settings>" > ~/.m2/settings.xml | ||
- name: Cache Maven dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- name: Build and deploy to GitHub Packages | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} | ||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} | ||
working-directory: ${{ github.workspace }} # Set working directory to project root | ||
run: | | ||
mvn clean deploy -Dsettings.security=/path/to/maven-security-settings.xml |