mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-30 14:03:23 +01:00
5e1f1b802c
A lot is happening in this release! tl;dr: GitHub Actions runs tests, compiles the project, signs the jar files, deploys them to the Maven repo; Pushing a git tag issues a release instead of snapshot deployment; -SNAPSHOT is always added to the version otherwise; Core Version is now injected by maven instead of manually updating it in one of the classes We now use GitHub Actions to run automated tests, compile the project, sign the resulting jar files, and always deploy a version to the Maven repo. By default, a snapshot release is published but by creating a git tag, a release deploy can be triggered. Additionally the Core version is not manually updated in one of the classes but injected after compiling it. I think I found the most stable and easiest way to do this in maven, although I'd have wished for it to be easier and maybe not after the class file has already been created.
94 lines
3.2 KiB
YAML
94 lines
3.2 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
branches: [ master, development ]
|
|
tags:
|
|
- 'v*'
|
|
pull_request:
|
|
types: [ opened, synchronize, reopened ]
|
|
|
|
permissions: read-all
|
|
|
|
env:
|
|
DEPLOYMENT_POM_PATH: ./Core/dependency-reduced-pom.xml
|
|
DEPLOYMENT_ARTIFACT_DIR: ./Core/target
|
|
DEPLOYMENT_ARTIFACT_SELECTOR: SongodaCore-*.jar
|
|
|
|
jobs:
|
|
Tests:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Prepare Workspace
|
|
uses: ./.github/actions/setup_project_workspace
|
|
|
|
- name: Run tests
|
|
run: mvn -B clean test
|
|
|
|
Build:
|
|
name: Build + Deploy
|
|
runs-on: ubuntu-latest
|
|
needs: [ Tests ]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Prepare Workspace
|
|
uses: ./.github/actions/setup_project_workspace
|
|
with:
|
|
maven_username: ${{ secrets.MAVEN_REPO_USERNAME }}
|
|
maven_password: ${{ secrets.MAVEN_REPO_PASSWORD }}
|
|
|
|
- name: Set project version
|
|
uses: songoda/GH-Commons/.github/actions/maven_set_project_version@master
|
|
with:
|
|
append_snapshot: ${{ github.ref_type == 'tag' && 'false' || 'true' }}
|
|
version: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
|
|
|
|
- name: Build with Maven
|
|
run: mvn -B -Duser.name="GitHub Actions on $GITHUB_REPOSITORY (id=$GITHUB_RUN_ID)" -DskipTests clean package
|
|
|
|
- name: Sign jar archives
|
|
uses: songoda/GH-Commons/.github/actions/sign_jars@master
|
|
with:
|
|
jar_file_selector: ${{ env.DEPLOYMENT_ARTIFACT_DIR }}/${{ env.DEPLOYMENT_ARTIFACT_SELECTOR }}
|
|
keystore_gpg_encrypted: ${{ secrets.JARSIGNER_KEYSTORE_ENCRYPTED }}
|
|
keystore_gpg_password: ${{ secrets.JARSIGNER_KEYSTORE_ENCRYPTED_PASSWORD }}
|
|
keystore_password: ${{ secrets.JARSIGNER_KEYSTORE_PASSWORD }}
|
|
|
|
- name: 'Upload Build Artifacts'
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ github.event.repository.name }}
|
|
path: ${{ env.DEPLOYMENT_ARTIFACT_DIR }}/${{ env.DEPLOYMENT_ARTIFACT_SELECTOR }}
|
|
|
|
- name: Deploy to Maven repo
|
|
uses: songoda/GH-Commons/.github/actions/maven_deploy@master
|
|
with:
|
|
repository_url: ${{ secrets.MAVEN_REPO_URL_RELEASES }}
|
|
repository_url_snapshots: ${{ secrets.MAVEN_REPO_URL_SNAPSHOTS }}
|
|
maven_pom_path: ${{ env.DEPLOYMENT_POM_PATH }}
|
|
maven_out_dir: ${{ env.DEPLOYMENT_ARTIFACT_DIR }}
|
|
- name: Deploy parent pom.xml to Maven repo
|
|
uses: songoda/GH-Commons/.github/actions/maven_deploy@master
|
|
with:
|
|
repository_url: ${{ secrets.MAVEN_REPO_URL_RELEASES }}
|
|
repository_url_snapshots: ${{ secrets.MAVEN_REPO_URL_SNAPSHOTS }}
|
|
only_deploy_pom: true
|
|
maven_out_dir: ${{ env.DEPLOYMENT_ARTIFACT_DIR }}
|
|
|
|
discord_webhook:
|
|
name: Send Discord Webhook
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: [ Tests, Build ]
|
|
if: ${{ always() && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/development' || github.ref_type == 'tag') }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Notify Webhook
|
|
uses: songoda/GH-Commons/.github/actions/discord_send_job_results@master
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
|