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 d88b22d commit 1e9448c
Showing 1 changed file with 18 additions and 46 deletions.
64 changes: 18 additions & 46 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,61 +8,29 @@ permissions:
contents: write

jobs:
checkout-code:
build:
runs-on: ubuntu-latest
outputs:
# Utwórz output, który będzie zawierał ścieżkę do kodu źródłowego
source-dir: ${{ github.workspace }}
version: ${{ steps.extract_info.outputs.version }}
artifact_name: ${{ steps.extract_info.outputs.artifact_name }}
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
- name: Upload source code for other jobs
uses: actions/upload-artifact@v3
with:
name: source-code
path: .

setup-java:
runs-on: ubuntu-latest
needs: checkout-code
steps:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven

build-with-maven:
runs-on: ubuntu-latest
needs: setup-java
steps:
- name: Download source code
uses: actions/download-artifact@v3
with:
name: source-code
- 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-with-maven
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
outputs:
version: ${{ steps.extract_info.outputs.version }}
artifact_name: ${{ steps.extract_info.outputs.artifact_name }}
steps:
- name: Extract version and artifact name
id: extract_info
run: |
Expand All @@ -72,30 +40,34 @@ jobs:
echo "::set-output name=version::v$VERSION"
echo "::set-output name=artifact_name::$ARTIFACT_NAME"
create-and-push-tag:
create-tag:
needs: build
runs-on: ubuntu-latest
needs: extract-info
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- 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 }}
git tag ${{ needs.build.outputs.version }}
git push https://x-access-token:${{ secrets.BE_ACCESS_TOKEN }}@github.com/${{ github.repository }} ${{ needs.build.outputs.version }}
create-release:
needs: create-tag
runs-on: ubuntu-latest
needs: [extract-info, create-and-push-tag]
steps:
- name: Download artifact
uses: actions/download-artifact@v3
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: minecraft-plugin
- 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: ${{ needs.build.outputs.artifact_name }}
tag_name: ${{ needs.build.outputs.version }}
files: target/*.jar
generate_release_notes: true
env:
Expand Down

0 comments on commit 1e9448c

Please sign in to comment.