diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 9a0ba11..c2879c7 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,32 +1,42 @@ -name: Java Build and File Update + + +name: Java Maven Build & Publish Artifact on: push: - branches: - - main + branches: [ "main" ] + pull_request: + branches: [ "main" ] jobs: - build: + build_test: + runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up JDK - uses: actions/setup-java@v2 + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: java-version: '17' - distribution: 'adopt' - server-id: 'github' - server-username: ${{ github.actor }} - server-password: ${{ secrets.GITHUB_TOKEN }} + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.xml - - name: Build Java project with Maven - run: mvn clean package - - - name: Create builds directory - run: mkdir -p builds - - - name: Copy JAR file to builds directory - run: cp -r target/*.jar builds/ + + publish-job: + runs-on: ubuntu-latest + needs: build_test + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - run: mvn --batch-mode --update-snapshots verify + - run: mkdir staging && cp target/*.jar staging + - uses: actions/upload-artifact@v3 + with: + name: Package + path: staging