From e9af3cd1b9491de3dcb206da21400644c74bac57 Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 4 Oct 2024 16:45:17 -0400 Subject: [PATCH 1/3] Update manualBuild.yml --- .github/workflows/manualBuild.yml | 89 +++++++++++++++---------------- 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/.github/workflows/manualBuild.yml b/.github/workflows/manualBuild.yml index 213abca1..2e1cec9d 100644 --- a/.github/workflows/manualBuild.yml +++ b/.github/workflows/manualBuild.yml @@ -1,72 +1,69 @@ -name: Build Jar Manually +name: Manual Build on: - workflow_dispatch: # Allows manual trigger from the GitHub UI + workflow_dispatch: + +env: + VERSION: 1.0.0 jobs: build: runs-on: ubuntu-latest steps: - # Step 1: Checkout the code + # Step 1: Checkout the repository - name: Checkout repository - uses: actions/checkout@v3 - - # Step 2: Set up Java 17 (or your target version) - - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/checkout@v2 + + # Step 2: Set up Java JDK (Make sure to specify the version needed) + - name: Set up JDK + uses: actions/setup-java@v2 with: - java-version: '17' - distribution: 'temurin' # or 'zulu', 'adopt', etc. - - # Step 3: Get the current version from the pom.xml - - name: Get current version from pom.xml - id: get_version + java-version: '17' # Use the Java version you need + + # Step 3: Install Maven + - name: Install Maven run: | - VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) - echo "Current version is: $VERSION" - echo "VERSION=$VERSION" >> $GITHUB_ENV - - # Step 4: Increment the version (patch version bump) - - name: Increment version - id: increment_version + sudo apt-get install maven + + # Step 4: Build the project (this will also run tests) + - name: Build with Maven + run: mvn clean package + + # Step 5: Increment the version + - name: Increment Version + id: version run: | - # Increment the patch version - VERSION=$(echo ${{ env.VERSION }} | awk -F. '{$NF+=1; OFS="."; print}') - echo "New version is: $VERSION" + # Increment the version + VERSION=$(echo "${{ env.VERSION }}" | awk -F. -v OFS=. '{$NF++;print}') echo "VERSION=$VERSION" >> $GITHUB_ENV - # Update the version in the pom.xml - mvn versions:set -DnewVersion=${{ env.VERSION }} -DgenerateBackupPoms=false - - # Step 5: Verify if the version change has been applied to pom.xml - - name: Check for version change in pom.xml + + # Step 6: Update pom.xml with the new version + - name: Update pom.xml run: | - git status - git diff - - # Step 6: Build the .jar file - - name: Build jar file - run: mvn clean package - - # Step 7: Upload the built .jar file as an artifact - - name: Upload .jar artifact - uses: actions/upload-artifact@v3 - with: - name: built-jar - path: target/*.jar - - # Step 8: Commit the updated pom.xml with the new version (only if there are changes) + mvn versions:set -DnewVersion=${{ env.VERSION }} + mvn versions:commit + + # Step 7: Commit the updated pom.xml with the new version (only if there are changes) - name: Commit new version run: | git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' git add pom.xml git commit -m "Bump version to ${{ env.VERSION }}" || echo "No changes to commit" - - # Step 9: Push the commit and the new version tag to the repository + + # Step 8: Create Git Tag and push - name: Create Git Tag and push run: | + # Create a properly formatted tag with periods TAG_NAME="v${{ env.VERSION }}" git tag -a "$TAG_NAME" -m "Release $TAG_NAME" git push origin master git push origin "$TAG_NAME" + + # Step 9: Upload the JAR as an artifact (Optional) + - name: Upload JAR + uses: actions/upload-artifact@v2 + with: + name: my-artifact + path: target/*.jar # Adjust the path according to your project structure From c427a9d66d4b771965d73f4f51ced5d879491940 Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 4 Oct 2024 16:47:58 -0400 Subject: [PATCH 2/3] Update and rename manualBuild.yml to build.yml nevermind :( --- .github/workflows/build.yml | 23 +++++++++++ .github/workflows/manualBuild.yml | 69 ------------------------------- 2 files changed, 23 insertions(+), 69 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/manualBuild.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..523ad1da --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,23 @@ +name: Build + +on: + pull_request: + branches: + - master + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4.1.7 + + - name: Set up JDK 16 + uses: actions/setup-java@v4.2.1 + with: + java-version: 16 + distribution: adopt + + - name: Build with Maven + run: mvn package diff --git a/.github/workflows/manualBuild.yml b/.github/workflows/manualBuild.yml deleted file mode 100644 index 2e1cec9d..00000000 --- a/.github/workflows/manualBuild.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: Manual Build - -on: - workflow_dispatch: - -env: - VERSION: 1.0.0 - -jobs: - build: - runs-on: ubuntu-latest - - steps: - # Step 1: Checkout the repository - - name: Checkout repository - uses: actions/checkout@v2 - - # Step 2: Set up Java JDK (Make sure to specify the version needed) - - name: Set up JDK - uses: actions/setup-java@v2 - with: - java-version: '17' # Use the Java version you need - - # Step 3: Install Maven - - name: Install Maven - run: | - sudo apt-get install maven - - # Step 4: Build the project (this will also run tests) - - name: Build with Maven - run: mvn clean package - - # Step 5: Increment the version - - name: Increment Version - id: version - run: | - # Increment the version - VERSION=$(echo "${{ env.VERSION }}" | awk -F. -v OFS=. '{$NF++;print}') - echo "VERSION=$VERSION" >> $GITHUB_ENV - - # Step 6: Update pom.xml with the new version - - name: Update pom.xml - run: | - mvn versions:set -DnewVersion=${{ env.VERSION }} - mvn versions:commit - - # Step 7: Commit the updated pom.xml with the new version (only if there are changes) - - name: Commit new version - run: | - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - git add pom.xml - git commit -m "Bump version to ${{ env.VERSION }}" || echo "No changes to commit" - - # Step 8: Create Git Tag and push - - name: Create Git Tag and push - run: | - # Create a properly formatted tag with periods - TAG_NAME="v${{ env.VERSION }}" - git tag -a "$TAG_NAME" -m "Release $TAG_NAME" - git push origin master - git push origin "$TAG_NAME" - - # Step 9: Upload the JAR as an artifact (Optional) - - name: Upload JAR - uses: actions/upload-artifact@v2 - with: - name: my-artifact - path: target/*.jar # Adjust the path according to your project structure From 4ec0818ac1efed4e128c58b83deb4df92ddae34b Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 4 Oct 2024 16:50:38 -0400 Subject: [PATCH 3/3] Update build.yml --- .github/workflows/build.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 523ad1da..771ec752 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,9 +1,7 @@ name: Build on: - pull_request: - branches: - - master + workflow_dispatch: jobs: build: