From 8e93eacf628d6a9e133bb075416c6d9c220c8aec Mon Sep 17 00:00:00 2001 From: Teal Bauer Date: Sat, 29 Mar 2025 23:10:37 +0100 Subject: [PATCH] Build in Github Action --- .github/workflows/build.yml | 72 +++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..83096cd --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,72 @@ +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: echo "VERSION=$(grep -m1 '' pom.xml | sed 's/[[:space:]]*\(.*\)<\/version>.*/\1/')" >> $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 + else + SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-8) + echo "BUILD_VERSION=${{ steps.get_version.outputs.VERSION }}-nightly-$SHORT_SHA" >> $GITHUB_OUTPUT + 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>/{s/.*<\/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 artifact + if: github.ref_type != 'tag' + uses: actions/upload-artifact@v4 + with: + name: GhydraMCP-${{ steps.set_version.outputs.BUILD_VERSION }} + path: target/GhydraMCP-*.zip + + - name: Create Release + if: github.ref_type == 'tag' + id: create_release + uses: softprops/action-gh-release@v1 + with: + name: Release ${{ github.ref_name }} + files: | + target/GhydraMCP-*.zip + draft: false + prerelease: false \ No newline at end of file