68 lines
2.0 KiB
YAML
68 lines
2.0 KiB
YAML
name: Java CI/CD
|
|
|
|
on:
|
|
push:
|
|
tags: [ "v*" ]
|
|
|
|
jobs:
|
|
create_release:
|
|
name: Create Release
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Set up JDK 8
|
|
uses: actions/setup-java@v2
|
|
with:
|
|
java-version: '8'
|
|
distribution: 'adopt'
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@master
|
|
with:
|
|
platforms: all
|
|
|
|
- name: Set up Docker Build
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 18
|
|
|
|
- name: Build with Maven
|
|
run: mvn clean compile assembly:single
|
|
|
|
- name: Get version
|
|
id: get_version
|
|
run: echo "::set-output name=version::$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' exec:exec)"
|
|
|
|
- name: Get artifact id
|
|
id: get_artifact_id
|
|
run: echo "::set-output name=name::$(mvn -q -Dexec.executable=echo -Dexec.args='${project.artifactId}' exec:exec)"
|
|
|
|
- name: Rename artifact
|
|
run: mv ./target/${{ steps.get_artifact_id.outputs.name }}.jar ./target/${{ steps.get_artifact_id.outputs.name }}-${{ steps.get_version.outputs.version }}.jar
|
|
|
|
- name: Automatic Releases
|
|
uses: marvinpinto/action-automatic-releases@latest
|
|
with:
|
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
prerelease: false
|
|
title: Release ${{ steps.get_version.outputs.version }}
|
|
files: |
|
|
./target/${{ steps.get_artifact_id.outputs.name }}-${{ steps.get_version.outputs.version }}.jar
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v2
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
push: true
|
|
platforms: linux/amd64,linux/arm64
|
|
tags: |
|
|
germannewsmaker/mcdash:latest
|
|
germannewsmaker/mcdash:${{ steps.get_version.outputs.version }} |