95 lines
3.3 KiB
YAML
95 lines
3.3 KiB
YAML
# This workflow will build a Java project with Maven
|
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
|
#
|
|
|
|
name: Java CI with Maven
|
|
|
|
on:
|
|
push:
|
|
branches: [ master,develop ]
|
|
tags:
|
|
- 'v*'
|
|
pull_request:
|
|
branches: [ master,develop ]
|
|
paths-ignore:
|
|
- README.md
|
|
- .gitignore
|
|
|
|
jobs:
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Cache Maven Repos
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/.m2/repository
|
|
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-maven-
|
|
- uses: actions/checkout@v2
|
|
- name: Set up JDK 1.8
|
|
uses: actions/setup-java@v1
|
|
with:
|
|
java-version: 1.8
|
|
- name: Build Modules
|
|
run: mvn -B clean package install --file pom.xml
|
|
- name: Build Bootstrap
|
|
run: mvn -B clean package install --file fizz-bootstrap/pom.xml
|
|
- uses: bhowell2/github-substring-action@v1.0.0
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
id: releaseVersion
|
|
with:
|
|
fail_if_not_found: false
|
|
default_return_value: ${{ github.ref }}
|
|
value: ${{ github.ref }}
|
|
index_of_str: "refs/tags/v"
|
|
- name: Packing
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
run: |
|
|
mkdir fizz-gateway-community
|
|
cp ./fizz-bootstrap/target/fizz-bootstrap-*.jar ./fizz-gateway-community/fizz-gateway-community.jar
|
|
cp ./fizz-bootstrap/target/classes/application.yml ./fizz-gateway-community/application.yml
|
|
cp ./fizz-bootstrap/target/classes/log4j2-spring.xml ./fizz-gateway-community/log4j2-spring.xml
|
|
cp ./fizz-bootstrap/sh/boot.sh ./fizz-gateway-community/boot.sh
|
|
zip -r ./fizz-gateway-community-${{ steps.releaseVersion.outputs.substring }}.zip ./fizz-gateway-community/*
|
|
- name: Release
|
|
uses: softprops/action-gh-release@v1
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
with:
|
|
draft: true
|
|
files: ./fizz-gateway-community-${{ steps.releaseVersion.outputs.substring }}.zip
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Set up QEMU
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
uses: docker/setup-qemu-action@v1
|
|
- name: Set up Docker Buildx
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
uses: docker/setup-buildx-action@v1
|
|
- name: Login to DockerHub
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
- name: Build and push to DockerHub
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
file: ./Dockerfile
|
|
context: .
|
|
push: true
|
|
tags: fizzgate/fizz-gateway-community:${{ steps.releaseVersion.outputs.substring }}
|
|
- name: Publish to Apache Maven Central
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
uses: samuelmeuli/action-maven-publish@v1
|
|
with:
|
|
maven_profiles: release
|
|
server_id: sonatype-release
|
|
gpg_private_key: ${{ secrets.GPG_SECRET }}
|
|
gpg_passphrase: ${{ secrets.GPG_PASSPHASE }}
|
|
nexus_username: ${{ secrets.OSSRH_USER }}
|
|
nexus_password: ${{ secrets.OSSRH_PASSWORD }}
|