Skip to content

fix maven

fix maven #18

Workflow file for this run

name: PIPELINE
on:
push:
branches:
- 'master'
workflow_dispatch:
jobs:
bump:
name: Get And Bump SemVer πŸ‘Š
runs-on: [self-hosted, Linux, X64]
outputs:
pom_version: ${{ steps.set_version.outputs.pom_version }}
major_version: ${{ steps.set_version.outputs.major_version }}
minor_version: ${{ steps.set_version.outputs.minor_version }}
build_version: ${{ steps.set_version.outputs.build_version }}
steps:
- name: Checkout repo πŸ“¦
uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Bump version and push tag πŸ‘Š
uses: anothrNick/github-tag-action@master
id: bump_version
env:
GITHUB_TOKEN: ${{ github.TOKEN }}
RELEASE_BRANCHES: master
DEFAULT_BUMP: patch
WITH_V: false
- name: Extract version from tag πŸ”
id: set_version
env:
POM_VERSION: ${{ steps.bump_version.outputs.new_tag }}
run: |
MAJOR_VERSION=$(echo $POM_VERSION | cut -d. -f1)
MINOR_VERSION=$(echo $POM_VERSION | cut -d. -f2)
BUILD_VERSION=$(echo $POM_VERSION | cut -d. -f3)
echo POM:$POM_VERSION, MAJOR:$MAJOR_VERSION, MINOR:$MINOR_VERSION, BUILD:$BUILD_VERSION
echo --- set output for step ---
echo "pom_version=${POM_VERSION}" >> $GITHUB_ENV
echo "major_version=${MAJOR_VERSION}" >> $GITHUB_ENV
echo "minor_version=${MINOR_VERSION}" >> $GITHUB_ENV
echo "build_version=${BUILD_VERSION}" >> $GITHUB_ENV
echo --- set output for job ---
echo "pom_version=${POM_VERSION}" >> $GITHUB_OUTPUT
echo "major_version=${MAJOR_VERSION}" >> $GITHUB_OUTPUT
echo "minor_version=${MINOR_VERSION}" >> $GITHUB_OUTPUT
echo "build_version=${BUILD_VERSION}" >> $GITHUB_OUTPUT
build:
name: Build and publish to Maven Central πŸ”¨
runs-on: [self-hosted, Linux, X64]
env:
MAVEN_ARGS: -Dmaven.test.skip=true
outputs:
pom_version: ${{ needs.bump.outputs.pom_version }}
major_version: ${{ needs.bump.outputs.major_version }}
minor_version: ${{ needs.bump.outputs.minor_version }}
build_version: ${{ needs.bump.outputs.build_version }}
needs: [bump]
steps:
- name: Checkout repo πŸ“¦
uses: actions/checkout@v4
- name: Cache Maven packages πŸ’Ύ
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
- name: Set up JDK 21 βš™οΈ
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
server-id: maven
server-username: ${{ secrets.SONATYPE_USERNAME }}
server-password: ${{ secrets.SONATYPE_PASSWORD }}
- name: Set up GPG for CI βš™οΈ
run: |
which gpg2 || sudo apt update && sudo apt install -y gnupg2
mkdir -p ~/.gnupg
chmod 700 ~/.gnupg
echo "use-agent" >> ~/.gnupg/gpg.conf
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
echo "default-cache-ttl 600" >> ~/.gnupg/gpg-agent.conf
echo "max-cache-ttl 7200" >> ~/.gnupg/gpg-agent.conf
gpgconf --kill gpg-agent
gpgconf --launch gpg-agent
- name: Import GPG key using gpg2 πŸ”
run: |
echo "${{ secrets.GPG_SECRET_KEY }}" | base64 --decode | gpg2 --batch --yes --import
echo "${{ secrets.GPG_OWNERTRUST }}" | base64 --decode | gpg2 --import-ownertrust
export GPG_TTY=$(tty)
export GPG_EXECUTABLE=gpg2
- name: Write .m2/settings.xml πŸ’Ύ
run: |
mkdir -p ~/.m2
cat <<EOF > ~/.m2/settings.xml
<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">
<servers>
<server>
<id>maven</id>
<username>${{ secrets.SONATYPE_USERNAME }}</username>
<password>${{ secrets.SONATYPE_PASSWORD }}</password>
</server>
</servers>
</settings>
EOF
- name: Conditionally setup Maven βš™οΈ
run: |
wihch mvn || sudo apt update && sudo apt install -y maven
- name: Update pom.xml version πŸ’Ύ
run: |
mvn versions:set -DnewVersion=${{ needs.bump.outputs.major_version }}.${{ needs.bump.outputs.minor_version }}.${{ needs.bump.outputs.build_version }} -DgenerateBackupPoms=false
- name: Build and publish with Maven πŸ”¨
env:
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: mvn clean deploy --batch-mode --update-snapshots -DreleaseSonatype=true $MAVEN_ARGS
- name: List signed files 🐞
run: |
echo "πŸ“¦ Contents of target/:"
ls -lh target/
echo ""
echo "πŸ” GPG signatures:"
find target/ -type f -name "*.asc" -exec echo "βœ” Found:" {} \;
echo ""
echo "❓ Missing POM signature?" && test ! -f target/*pom.asc && echo "❌ No POM signature found!" || echo "βœ… POM is signed."
- name: Upload build artifacts ⬆️
uses: actions/upload-artifact@v4
with:
name: maven-artifacts
path: target/*.jar