tdlight-java/.github/workflows/maven-publish.yml

80 lines
2.7 KiB
YAML

# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path
name: Maven Package
on:
push:
jobs:
build:
strategy:
matrix:
include:
- { os: ubuntu-20.04, arch: "linux/amd64" }
runs-on: ${{ matrix.os }}
steps:
- name: Branch name
id: branch_name
run: |
set -xeo pipefail
echo "SOURCE_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo "SOURCE_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "SOURCE_TAG_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
cat $GITHUB_ENV > github.env
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Setup variables
shell: bash
run: |
set -xeo pipefail
# ====== Variables
export REVISION=${{ steps.branch_name.outputs.SOURCE_TAG_VERSION }}
echo "REVISION=$REVISION" >> $GITHUB_ENV
cat $GITHUB_ENV >> github.env
- name: Set up JDK 17 (Snapshot)
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: 'maven'
server-id: mchv-snapshot-distribution
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Build and deploy to Maven (Snapshot)
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
shell: bash
run: |
set -xeo pipefail
mvn -B -f bom/pom.xml -P "java8,java17" clean deploy
echo "Done."
env:
MAVEN_USERNAME: ${{ secrets.MCHV_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MCHV_TOKEN }}
- name: Set up JDK 17 (Release)
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: 'maven'
server-id: mchv-release-distribution
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Build and deploy to Maven (Release)
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
shell: bash
run: |
set -xeo pipefail
echo "REVISION: $REVISION"
mvn -B -f bom/pom.xml -Drevision="${REVISION}" -P "java8,java17" clean deploy
echo "Done."
env:
MAVEN_USERNAME: ${{ secrets.MCHV_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MCHV_TOKEN }}