From 92f58ccd0596d52c0ebf863600bd5f3986a8fde1 Mon Sep 17 00:00:00 2001 From: MajdT51 <50261972+MajdT51@users.noreply.github.com> Date: Fri, 19 Jul 2024 06:52:09 +0200 Subject: [PATCH] workflow, generate jar on tag (#110) --- .github/workflows/plugin_build.yml | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/plugin_build.yml diff --git a/.github/workflows/plugin_build.yml b/.github/workflows/plugin_build.yml new file mode 100644 index 0000000..790f1b1 --- /dev/null +++ b/.github/workflows/plugin_build.yml @@ -0,0 +1,44 @@ +name: Build Plugin + +on: + push: + tags: + - 'v*' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up JDK 21 + uses: actions/setup-java@v2 + with: + java-version: "21" + distribution: "temurin" + + - name: Extract version from pom.xml + run: echo "PLUGIN_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV + + - name: Prepare Version from Tag + run: | + # Removing the 'v' prefix from the tag + TAG_VERSION="${GITHUB_REF#refs/tags/v}" + echo "TAG_VERSION=$TAG_VERSION" >> $GITHUB_ENV + if [ "$PLUGIN_VERSION" != "$TAG_VERSION" ]; then + echo "Error: Tag version '$TAG_VERSION' does not match the version in pom.xml '$PLUGIN_VERSION'" + exit 1 + fi + + - name: Build with Maven + run: mvn clean package + + - name: Add version to JAR file + run: mv target/PopulationDensity.jar target/PopulationDensity-${{ env.PLUGIN_VERSION }}.jar + + - name: Upload plugin jar with version + uses: actions/upload-artifact@v2 + with: + name: PopulationDensity-${{ env.PLUGIN_VERSION }} + path: target/PopulationDensity-${{ env.PLUGIN_VERSION }}.jar