Skip to content

Liberar nova versão Maven #1

Liberar nova versão Maven

Liberar nova versão Maven #1

Workflow file for this run

name: Liberar nova versão Maven
on:
workflow_dispatch:
inputs:
version:
description: 'Release version'
required: true
type: string
jobs:
release:
name: Build, Test and Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Java 8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
cache: maven
- name: Set release version
run: |
VERSION="${{ github.event.inputs.version }}"
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
mvn versions:set -DnewVersion=$VERSION
mvn versions:commit
- name: Build and test with Java 8
run: |
mvn clean compile test -B
- name: Setup Maven settings.xml
run: |
mkdir -p ~/.m2
cat > ~/.m2/settings.xml << 'EOF'
<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">
<servers>
<server>
<id>central</id>
<username>${{ secrets.MAVEN_CENTRAL_USERNAME }}</username>
<password>${{ secrets.MAVEN_CENTRAL_PASSWORD }}</password>
</server>
</servers>
</settings>
EOF
- name: Setup GPG
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
# Import GPG key
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
# Configure GPG for non-interactive mode
echo "use-agent" >> ~/.gnupg/gpg.conf
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
# Restart GPG agent
gpgconf --kill gpg-agent || true
gpgconf --launch gpg-agent
# Get the key ID and verify it's the correct one
GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep "1F93637480018AD7" | head -1 | awk '{print $2}' | cut -d'/' -f2)
echo "GPG_KEY_ID=$GPG_KEY_ID" >> $GITHUB_ENV
echo "Using GPG Key ID: $GPG_KEY_ID"
# Test signing
echo "test signing" | gpg --clearsign --armor --pinentry-mode loopback --batch --passphrase "$GPG_PASSPHRASE" --default-key "1F93637480018AD7"
- name: Deploy to Maven Central Portal
env:
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
export GPG_TTY=$(tty)
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
mvn deploy -B --no-transfer-progress
- name: Create GitHub Release
if: success()
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.RELEASE_VERSION }}
name: Release v${{ env.RELEASE_VERSION }}
body_path: CHANGELOG.md
draft: false
prerelease: false
files: |
target/paf-nfce-${{ env.RELEASE_VERSION }}.jar
target/paf-nfce-${{ env.RELEASE_VERSION }}-sources.jar
target/paf-nfce-${{ env.RELEASE_VERSION }}-javadoc.jar