From a6bd5107b2fb0488f1fda8f778ca4c80af6efcc7 Mon Sep 17 00:00:00 2001 From: BetterBox <53705390+Grzybol@users.noreply.github.com> Date: Sun, 17 Mar 2024 14:42:35 +0100 Subject: [PATCH] Update maven.yml --- .github/workflows/maven.yml | 45 +++++++++---------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index eb78033..2fa8f4a 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,23 +1,18 @@ name: Java CI with Maven, Auto-Versioning, and Release - +# on: push: branches: [ "master" ] - permissions: contents: write - jobs: - build: + build-and-release: runs-on: ubuntu-latest - outputs: - version: ${{ steps.extract_info.outputs.version }} - artifact_name: ${{ steps.extract_info.outputs.artifact_name }} steps: - uses: actions/checkout@v3 with: - fetch-depth: 0 - token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 # To ensure tags are fetched as well + token: ${{ secrets.GITHUB_TOKEN }} # Użyj GITHUB_TOKEN do checkout - name: Set up JDK 17 uses: actions/setup-java@v3 with: @@ -37,38 +32,20 @@ jobs: JAR_NAME=$(ls target/*.jar) ARTIFACT_NAME=$(basename $JAR_NAME) VERSION=$(echo $ARTIFACT_NAME | grep -oP '(?<=-)\d+\.\d+\.\d+(?=-SNAPSHOT)') - echo "VERSION=v$VERSION" >> $GITHUB_ENV - echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_ENV - - create-tag: - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - token: ${{ secrets.GITHUB_TOKEN }} + echo "::set-output name=version::v$VERSION" + echo "::set-output name=artifact_name::$ARTIFACT_NAME" - name: Create and Push Tag run: | git config user.name "GitHub Actions" git config user.email "github-actions@users.noreply.github.com" - git tag ${{ env.VERSION }} - git push https://x-access-token:${{ secrets.BR_ACCESS_TOKEN }}@github.com/${{ github.repository }} ${{ env.VERSION }} - - create-release: - needs: create-tag - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 - with: - name: minecraft-plugin + git tag ${{ steps.extract_info.outputs.version }} + git push https://x-access-token:${{ secrets.BE_ACCESS_TOKEN }}@github.com/${{ github.repository }} ${{ steps.extract_info.outputs.version }} - name: Create Release uses: softprops/action-gh-release@v1 with: - name: ${{ env.ARTIFACT_NAME }} - tag_name: ${{ env.VERSION }} - files: '*.jar' + name: ${{ steps.extract_info.outputs.artifact_name }} + tag_name: ${{ steps.extract_info.outputs.version }} + files: target/*.jar generate_release_notes: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}