Skip to content

Release

Release #6

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
release_version:
description: 'Release version (e.g., 1.0.1)'
required: true
type: string
next_version:
description: 'Next development version (e.g., 1.0.2-SNAPSHOT)'
required: true
type: string
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write # For pushing changes and tags
id-token: write # For OIDC (if needed)
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Configure Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git config --global url."https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf "git@github.com:"
git remote set-url origin https://github.com/${{ github.repository }}.git
- name: Import GPG key
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
- name: Configure Maven settings
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
mkdir -p ~/.m2
cat > ~/.m2/settings.xml <<EOF
<settings>
<servers>
<server>
<id>central</id>
<username>${MAVEN_CENTRAL_USERNAME}</username>
<password>${MAVEN_CENTRAL_TOKEN}</password>
</server>
</servers>
<profiles>
<profile>
<id>gpg</id>
<properties>
<gpg.executable>gpg</gpg.executable>
<gpg.passphrase>${GPG_PASSPHRASE}</gpg.passphrase>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>gpg</activeProfile>
</activeProfiles>
</settings>
EOF
- name: Run tests
run: mvn clean test
- name: Verify git remote
run: |
git remote -v
git config --get remote.origin.url
- name: Prepare release
env:
RELEASE_VERSION: ${{ github.event.inputs.release_version }}
NEXT_VERSION: ${{ github.event.inputs.next_version }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mvn release:prepare \
-DreleaseVersion=$RELEASE_VERSION \
-DdevelopmentVersion=$NEXT_VERSION \
-Dtag=v$RELEASE_VERSION \
-Dscm.url=scm:git:https://x-access-token:$GITHUB_TOKEN@github.com/${{ github.repository }}.git \
-Darguments="-DskipTests" \
-B
- name: Perform release
env:
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mvn release:perform \
-Dscm.url=scm:git:https://x-access-token:$GITHUB_TOKEN@github.com/${{ github.repository }}.git \
-B
- name: Push changes and tags
run: |
git push origin master
git push origin --tags