Add mvn test push workflow

This commit is contained in:
kristoffer 2023-04-30 23:18:19 +02:00
parent 2fcc102ed4
commit cfaa584a7d
No known key found for this signature in database
GPG Key ID: A14590146063A150
2 changed files with 72 additions and 54 deletions

View File

@ -1,54 +1,54 @@
name: Create Release #name: Create Release
#
on: #on:
push: # push:
tags: # tags:
- '[0-9]+.[0-9]+.[0-9]+*' # - '[0-9]+.[0-9]+.[0-9]+*'
#
jobs: #jobs:
build-and-release: # build-and-release:
runs-on: ubuntu-latest # runs-on: ubuntu-latest
#
steps: # steps:
- name: Checkout code # - name: Checkout code
uses: actions/checkout@v2 # uses: actions/checkout@v2
#
- name: Set up JDK # - name: Set up JDK
uses: actions/setup-java@v2 # uses: actions/setup-java@v2
with: # with:
distribution: 'adopt' # distribution: 'adopt'
java-version: '11' # java-version: '11'
#
- name: Extract artifact ID and version from pom.xml # - name: Extract artifact ID and version from pom.xml
run: | # run: |
ARTIFACT_ID=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.artifactId}' --non-recursive exec:exec) # ARTIFACT_ID=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.artifactId}' --non-recursive exec:exec)
VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) # VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
echo "ARTIFACT_ID=$ARTIFACT_ID" >> $GITHUB_ENV # echo "ARTIFACT_ID=$ARTIFACT_ID" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV # echo "VERSION=$VERSION" >> $GITHUB_ENV
#
- name: Build with Maven # - name: Build with Maven
run: mvn clean install --settings settings.xml --batch-mode -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true # run: mvn clean install --settings settings.xml --batch-mode -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true
#
- name: Create GitHub Release # - name: Create GitHub Release
id: create_release # id: create_release
uses: actions/create-release@v1 # uses: actions/create-release@v1
env: # env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: # with:
tag_name: ${{ github.ref }} # tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }} # release_name: Release ${{ github.ref }}
body: | # body: |
Changes in this Release # Changes in this Release
- Add a summary of changes or refer to the changelog. # - Add a summary of changes or refer to the changelog.
draft: false # draft: false
prerelease: false # prerelease: false
#
- name: Upload JAR Artifact to Release # - name: Upload JAR Artifact to Release
uses: actions/upload-release-asset@v1 # uses: actions/upload-release-asset@v1
env: # env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: # with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./target/${{ env.ARTIFACT_ID }}-${{ env.VERSION }}.jar # asset_path: ./target/${{ env.ARTIFACT_ID }}-${{ env.VERSION }}.jar
asset_name: ${{ env.ARTIFACT_ID }}-${{ env.VERSION }}.jar # asset_name: ${{ env.ARTIFACT_ID }}-${{ env.VERSION }}.jar
asset_content_type: application/java-archive # asset_content_type: application/java-archive

18
.github/workflows/run-tests.yaml vendored Normal file
View File

@ -0,0 +1,18 @@
name: Maven Tests
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build and test with Maven
run: mvn test