Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .github/workflows/.release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Release & Publish to Maven Central

on:
workflow_dispatch:
inputs:
release-type:
description: 'Specify release type: regular, alpha, beta, or rc'
required: true
default: 'regular'

jobs:
release:
runs-on: ubuntu-latest
env:
RELEASE_TYPE: ${{ github.event.inputs.release-type }}

steps:
# Validate that the workflow is running on the main branch
- name: Validate branch
run: |
if [[ "${{ github.ref }}" != "refs/heads/main" ]]; then
echo "Error: This workflow can only be run on the main branch."
exit 1
fi

# Validate the release type provided as input
- name: Validate release type
run: |
if [[ "$RELEASE_TYPE" != "regular" && "$RELEASE_TYPE" != "alpha" && "$RELEASE_TYPE" != "beta" && "$RELEASE_TYPE" != "rc" ]]; then
echo "Error: Invalid release type '$RELEASE_TYPE'. It must be one of: regular, alpha, beta, or rc."
exit 1
fi

# Checkout the source code from the repository
- name: Checkout source code
uses: actions/checkout@v3

# Setup Java environment
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

# Install necessary Node.js dependencies
- name: Install Node.js dependencies
run: npm ci

# Configure Git user with provided email and name
- name: Set Git user
run: |
git config --global user.email "${{ secrets.GIT_USER_EMAIL }}"
git config --global user.name "${{ secrets.GIT_USER_NAME }}"

# Generate Maven settings.xml file with necessary configurations
- name: Generate Maven configuration
working-directory: script
run: |
chmod +x generate_config_file.sh
./generate_config_file.sh ${{ secrets.PUBLISHING_SERVER_ID }} ${{ secrets.SONATYPE_USERNAME }} ${{ secrets.SONATYPE_PASSWORD }} ${{ secrets.GPG_PASSPHRASE }}

# Import the GPG key for signing artifacts
- name: Set up GPG key
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} # The private GPG key used for signing
PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} # The passphrase for the GPG key
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} # The ID of the GPG key
run: |
mkdir -p ~/.gnupg # Create the .gnupg directory if it doesn't exist
chmod 700 ~/.gnupg # Set the correct permissions for the .gnupg directory
echo "$GPG_PRIVATE_KEY" | gpg --import --batch --yes # Import the GPG private key
echo -e "5\n" | gpg --batch --yes --pinentry-mode loopback --passphrase "$PASSPHRASE" --command-fd 0 --edit-key "$GPG_KEY_ID" trust quit # Set the trust level for the GPG key to ultimate
echo -e "trust\n5\ny\nsave\n" | gpg --batch --command-fd 0 --edit-key ${{ secrets.GPG_KEY_ID }} # Ensure the key's trust level is set and saved correctly

# Run release-it to handle version bumping, changelog generation, and deployment
- name: Run release-it
run: |
if [ "$RELEASE_TYPE" == "regular" ]; then
npx release-it
else
npx release-it --preRelease="$RELEASE_TYPE"
fi
env:
TOKEN_GITHUB: ${{ secrets.TOKEN_GITHUB }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}

# Print a success message if the release was successful
- name: Print success message
if: success()
run: echo "Release and publishing completed successfully!"

# Print a failure message if the release failed
- name: Handle failure
if: failure()
run: echo "Release process failed."
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
node_modules/
36 changes: 36 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"$schema": "https://unpkg.com/release-it/schema/release-it.json",
"github": {
"release": true,
"releaseName": "Release ${version}",
"preRelease": false,
"autoGenerate": true,
"tokenRef": "TOKEN_GITHUB",
"contributors": true
},
"hooks": {
"after:bump": [
"chmod +x ./script/update_version.sh",
"./script/update_version.sh pom.xml ${version}"
],
"after:release": [
"mvn clean install",
"mvn deploy"
]
},
"git": {
"commitMessage": "chore(release): ${version}",
"tagName": "V${version}",
"requireCleanWorkingDir": true,
"push": true
},
"npm": {
"publish": false
},
"plugins": {
"@release-it/conventional-changelog": {
"preset": "angular",
"infile": "CHANGELOG.md"
}
}
}
Loading