Skip to content
Merged
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
115 changes: 115 additions & 0 deletions .github/workflows/release-debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# This workflow automates the release process when a draft release is created
# on GitHub. It uses Maven release plugin to manage versions and deploys to
# Maven Central
#
# Usage:
# 1. Create a new draft release in GitHub UI with tag format: vX.Y.Z
# (e.g., v1.2.0)
# - Select the target branch (typically main)
# 2. This workflow will automatically:
# - Use Maven release:prepare to update versions and create release commit
# - Use Maven release:perform to build and deploy artifacts to Maven Central
# - Create the tag to point to release commit
# - Push commits back to the originating branch
# - Publish the GitHub release (mark draft as non-draft)
name: Automated Release Debug

on:
release:
types: [created] # Only fire when a release is created

permissions:
contents: write # Required to push commits, update tags and edit releases

jobs:
release:
# Only run for draft releases; ignore non-draft created events
if: github.event.release.draft

runs-on: ubuntu-latest

steps:
- name: Validate release tag format
id: validate_tag
run: |
TAG_NAME="${{ github.event.release.tag_name }}"
echo "Release tag: $TAG_NAME"

# Validate tag format (should be vX.Y.Z)
if [[ ! "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid tag format. Expected format: vX.Y.Z (e.g., v1.2.0)"
exit 1
fi

# Remove 'v' prefix to get the version number
VERSION="${TAG_NAME#v}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "Extracted version: $VERSION"

- name: Determine target branch
id: target_branch
run: |
# Use target_commitish to determine the originating branch
TARGET="${{ github.event.release.target_commitish }}"

# If target_commitish is empty or a SHA, default to main
if [[ -z "$TARGET" ]] || [[ "$TARGET" =~ ^[0-9a-f]{40}$ ]]; then
TARGET="main"
fi

echo "target_branch=${TARGET}" >> "$GITHUB_OUTPUT"
echo "Target branch: $TARGET"

- name: Generate GitHub App Token
id: generate_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}

- name: Checkout repository
uses: actions/checkout@v6
with:
ref: ${{ steps.target_branch.outputs.target_branch }}
fetch-depth: 0
token: ${{ steps.generate_token.outputs.token }}

- name: Pre-build condition checks
run: |
TAG_NAME="${{ github.event.release.tag_name }}"

echo "Performing pre-build condition checks..."

# Fetch latest state from remote
git fetch origin --tags

# Check if a tag exists
if git ls-remote --tags origin | grep -q "refs/tags/$TAG_NAME$"; then
echo "::error::Tag $TAG_NAME already exists on remote."
exit 1
fi

echo "Pre-build checks passed. No issues detected."

- name: Set up JDK 25
uses: actions/setup-java@v5
with:
java-version: "25"
distribution: "temurin"
cache: maven
cache-dependency-path: |
pom.xml
xapi-model/pom.xml
xapi-client/pom.xml
xapi-model-spring-boot-starter/pom.xml
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"