121 lines
4.0 KiB
YAML
121 lines
4.0 KiB
YAML
name: Build Ghidra Plugin
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
tags:
|
|
- 'v*'
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Set up JDK 21
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
java-version: '21'
|
|
distribution: 'temurin'
|
|
cache: maven
|
|
|
|
- name: Get version from pom.xml
|
|
id: get_version
|
|
run: |
|
|
VERSION=$(grep -m1 '<version>' pom.xml | sed 's/[[:space:]]*<version>\(.*\)<\/version>.*/\1/')
|
|
# Strip any suffix after version numbers (like -SNAPSHOT)
|
|
BASE_VERSION=$(echo "$VERSION" | sed 's/^\([0-9]\+\.[0-9]\+\)[^0-9].*/\1/')
|
|
echo "VERSION=$BASE_VERSION" >> $GITHUB_OUTPUT
|
|
|
|
- name: Set build version
|
|
id: set_version
|
|
run: |
|
|
if [[ "${{ github.ref_type }}" == "tag" ]]; then
|
|
VERSION="${{ github.ref_name }}"
|
|
VERSION="${VERSION#v}"
|
|
echo "BUILD_VERSION=${VERSION}" >> $GITHUB_OUTPUT
|
|
echo "::debug::Set BUILD_VERSION to ${VERSION}"
|
|
else
|
|
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-8)
|
|
TIMESTAMP=$(date +"%Y%m%d-%H%M%S")
|
|
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
|
|
if [ -z "$LATEST_TAG" ]; then
|
|
BASE_VERSION="${{ steps.get_version.outputs.VERSION }}"
|
|
else
|
|
BASE_VERSION="${LATEST_TAG#v}"
|
|
fi
|
|
FULL_VERSION="${BASE_VERSION}-${SHORT_SHA}-${TIMESTAMP}"
|
|
echo "BUILD_VERSION=${FULL_VERSION}" >> $GITHUB_OUTPUT
|
|
echo "::debug::Set BUILD_VERSION to ${FULL_VERSION}"
|
|
fi
|
|
|
|
- name: Update version in files
|
|
run: |
|
|
VERSION="${{ steps.set_version.outputs.BUILD_VERSION }}"
|
|
# Update pom.xml - only update the first version tag which is the project version
|
|
sed -i '0,/<version>.*<\/version>/{s/<version>.*<\/version>/<version>'"$VERSION"'<\/version>/}' pom.xml
|
|
# Update MANIFEST.MF
|
|
sed -i "s/Bundle-Version: .*/Bundle-Version: $VERSION/" src/main/resources/META-INF/MANIFEST.MF
|
|
# Update extension.properties if it has version
|
|
if grep -q "^version=" src/main/resources/extension.properties; then
|
|
sed -i "s/^version=.*/version=$VERSION/" src/main/resources/extension.properties
|
|
fi
|
|
|
|
- name: Build with Maven
|
|
run: mvn -B package
|
|
|
|
- name: Upload nightly artifacts
|
|
if: github.ref_type != 'tag'
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: GhydraMCP-${{ steps.set_version.outputs.BUILD_VERSION }}
|
|
path: |
|
|
target/GhydraMCP-*.zip
|
|
bridge_mcp_hydra.py
|
|
|
|
- name: Generate Release Notes
|
|
if: github.ref_type == 'tag'
|
|
id: generate_notes
|
|
run: |
|
|
# Extract version without v prefix
|
|
VERSION="${{ github.ref_name }}"
|
|
VERSION="${VERSION#v}"
|
|
|
|
# Get commit messages since last tag
|
|
LAST_TAG=$(git describe --tags --abbrev=0 "v${VERSION}^" 2>/dev/null || echo "")
|
|
if [ -z "$LAST_TAG" ]; then
|
|
# If no previous tag exists, get all commits
|
|
COMMITS=$(git log --pretty=format:"- %s" --no-merges)
|
|
else
|
|
# Get commits between last tag and current tag
|
|
COMMITS=$(git log --pretty=format:"- %s" --no-merges ${LAST_TAG}..HEAD)
|
|
fi
|
|
|
|
# Create release notes file
|
|
cat > release_notes.md << EOF
|
|
# Release v${VERSION}
|
|
|
|
## What's Changed
|
|
${COMMITS}
|
|
|
|
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${LAST_TAG}...v${VERSION}
|
|
EOF
|
|
|
|
echo "RELEASE_NOTES_FILE=release_notes.md" >> $GITHUB_OUTPUT
|
|
|
|
- name: Create Release
|
|
if: github.ref_type == 'tag'
|
|
id: create_release
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
name: Release ${{ github.ref_name }}
|
|
body_path: ${{ steps.generate_notes.outputs.RELEASE_NOTES_FILE }}
|
|
files: |
|
|
target/GhydraMCP-*.zip
|
|
bridge_mcp_hydra.py
|
|
draft: false
|
|
prerelease: false
|