Skip to content

Maven Package

Maven Package #6

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:
release:
types: [created]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
server-id: github
settings-path: ${{ github.workspace }}
- name: Create settings.xml
working-directory: ./packages/java
run: |
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
http://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/gabriel-logan/Gerador-CPF-e-CNPJ-valido</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>github</id>
<username>gabriel-logan</username>
<password>${{secrets.MVN_TOKEN_GITHUB_PACKAGES}}</password>
</server>
</servers>
</settings>' > settings.xml
- name: Build with Maven
working-directory: ./packages/java
run: mvn -B package --file pom.xml
- name: List directory contents
working-directory: ./packages/java
run: ls -la
- name: Publish to GitHub Packages Apache Maven
working-directory: ./packages/java
run: mvn deploy -s settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}