Skip to content

Commit

Permalink
workflows: separate build and deploy workflows; publish releases
Browse files Browse the repository at this point in the history
  • Loading branch information
lokka30 committed Nov 11, 2024
1 parent e417527 commit c1f5ab4
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 8 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/maven.yml → .github/workflows/mvn-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@ name: Java CI with Maven
on:
push:
pull_request:
release:
types: [ published ]

jobs:
build-publish:
build:

runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4
Expand All @@ -33,7 +30,5 @@ jobs:
distribution: 'temurin'
cache: maven

- name: Build and deploy with Maven
run: mvn --batch-mode deploy --settings settings.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build with Maven
run: mvn --batch-mode clean
49 changes: 49 additions & 0 deletions .github/workflows/mvn-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Java CI with Maven

on:
release:
types: [ published ]

jobs:
build-publish:

runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven

- name: Build and deploy with Maven
run: mvn --batch-mode deploy --settings settings.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set JAR filename
id: jar
run: JAR_FILE=$(find target -name '*.jar' -o -name '*.jar' | grep -v 'original'); echo "JAR_FILE=$JAR_FILE" >> $GITHUB_ENV

- name: Upload JAR to Release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.JAR_FILE }}
asset_name: ${{ github.event.release.tag_name }}.jar
asset_content_type: application/java-archive

0 comments on commit c1f5ab4

Please sign in to comment.