Skip to content

Commit

Permalink
Update maven.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Grzybol authored Mar 17, 2024
1 parent 9bef656 commit 0972e6e
Showing 1 changed file with 6 additions and 45 deletions.
51 changes: 6 additions & 45 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,31 @@
name: Java CI with Maven, Auto-Versioning, and Release

#
on:
push:
branches: [ "master" ]

permissions:
contents: write

jobs:
setup:
build-and-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # To ensure tags are fetched as well
token: ${{ secrets.GITHUB_TOKEN }} # Użyj GITHUB_TOKEN do checkout

set-up-jdk:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven

move-pom:
runs-on: ubuntu-latest
needs: [setup, set-up-jdk]
steps:
- name: Move pom.xml to workspace
run: mv /home/runner/work/BetterElo/BetterElo/pom.xml $GITHUB_WORKSPACE/

build:
runs-on: ubuntu-latest
needs: [setup, set-up-jdk, move-pom]
steps:
- name: Build with Maven and Auto-Versioning
run: mvn -B build-helper:parse-version versions:set versions:commit package --file pom.xml

upload-artifact:
runs-on: ubuntu-latest
needs: build
steps:
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: minecraft-plugin
path: target/*.jar

extract-info:
runs-on: ubuntu-latest
needs: upload-artifact
steps:
- name: Extract version and artifact name
id: extract_info
run: |
Expand All @@ -63,27 +34,17 @@ jobs:
VERSION=$(echo $ARTIFACT_NAME | grep -oP '(?<=-)\d+\.\d+\.\d+(?=-SNAPSHOT)')
echo "::set-output name=version::v$VERSION"
echo "::set-output name=artifact_name::$ARTIFACT_NAME"
create-tag:
runs-on: ubuntu-latest
needs: extract-info
steps:
- name: Create and Push Tag
run: |
git config user.name "GitHub Actions"
git config user.email "github-actions@users.noreply.github.com"
git tag ${{ needs.extract-info.outputs.version }}
git push https://x-access-token:${{ secrets.BE_ACCESS_TOKEN }}@github.com/${{ github.repository }} ${{ needs.extract-info.outputs.version }}
create-release:
runs-on: ubuntu-latest
needs: create-tag
steps:
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: ${{ needs.extract-info.outputs.artifact_name }}
tag_name: ${{ needs.extract-info.outputs.version }}
name: ${{ steps.extract_info.outputs.artifact_name }}
tag_name: ${{ steps.extract_info.outputs.version }}
files: target/*.jar
generate_release_notes: true
env:
Expand Down

0 comments on commit 0972e6e

Please sign in to comment.