2021-09-03 05:57:59 +00:00
|
|
|
name: CI
|
2021-05-23 05:30:08 +00:00
|
|
|
|
|
|
|
on:
|
2021-09-03 05:57:59 +00:00
|
|
|
create:
|
2021-05-23 05:30:08 +00:00
|
|
|
pull_request:
|
|
|
|
types: [ opened, synchronize, reopened ]
|
2021-12-01 21:54:25 +00:00
|
|
|
paths-ignore:
|
|
|
|
- '*.md'
|
|
|
|
- 'docs/**'
|
2021-05-23 05:30:08 +00:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
2021-12-01 21:54:25 +00:00
|
|
|
paths-ignore:
|
|
|
|
- '*.md'
|
|
|
|
- 'docs/**'
|
2021-09-03 05:57:59 +00:00
|
|
|
workflow_dispatch:
|
2021-05-23 05:30:08 +00:00
|
|
|
|
2021-10-31 04:28:23 +00:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
|
2021-03-21 13:03:23 +00:00
|
|
|
jobs:
|
2021-10-31 04:28:23 +00:00
|
|
|
workflow_config:
|
2021-03-21 13:03:23 +00:00
|
|
|
runs-on: ubuntu-latest
|
2021-10-31 04:28:23 +00:00
|
|
|
outputs:
|
|
|
|
do_release: ${{ steps.config.outputs.do_release }}
|
2021-11-13 02:55:54 +00:00
|
|
|
do_snapshot_release: ${{ steps.config.outputs.do_snapshot_release }}
|
2021-10-31 04:28:23 +00:00
|
|
|
pom_version: ${{ steps.config.outputs.pom_version }}
|
2021-03-21 13:03:23 +00:00
|
|
|
steps:
|
2021-10-31 04:28:23 +00:00
|
|
|
- name: Configure workflow
|
2021-09-03 05:57:59 +00:00
|
|
|
id: config
|
|
|
|
env:
|
|
|
|
ACTOR: ${{ github.actor }}
|
|
|
|
EVENT_ACTION: ${{ github.event.action }}
|
|
|
|
REF_TYPE: ${{ github.event.ref_type }}
|
|
|
|
REF: ${{ github.event.ref }}
|
|
|
|
run: |
|
|
|
|
cat <<-EOF
|
|
|
|
::group::Debug Info
|
|
|
|
GITHUB_EVENT_NAME : '${GITHUB_EVENT_NAME}'
|
|
|
|
EVENT_ACTION : '${EVENT_ACTION}'
|
|
|
|
REF_TYPE : '${REF_TYPE}'
|
|
|
|
REF : '${REF}'
|
|
|
|
ACTOR : '${ACTOR}'
|
|
|
|
GITHUB_REPOSITORY_OWNER : '${GITHUB_REPOSITORY_OWNER}'
|
|
|
|
::endgroup::
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Do a release when a git tag starting with 'v' has been created by a suitable user.
|
|
|
|
# (We match against github.repository_owner as a kludge so that forked repos can release themselves when testing the workflow)
|
|
|
|
|
2021-11-12 15:46:46 +00:00
|
|
|
if [[ "${GITHUB_EVENT_NAME}" == "create" && "${REF_TYPE}" == "tag" && "${REF}" == v* && \
|
2021-09-03 05:57:59 +00:00
|
|
|
( "${ACTOR}" == "arnaudroques" || "${ACTOR}" == "${GITHUB_REPOSITORY_OWNER}" ) \
|
|
|
|
]]; then
|
2021-11-13 02:55:54 +00:00
|
|
|
echo "::notice title=::This run will release '${REF}'"
|
2021-09-03 05:57:59 +00:00
|
|
|
echo "::set-output name=do_release::true"
|
|
|
|
echo "::set-output name=pom_version::${REF#v}" # pom_version is the tag without the 'v' prefix
|
2021-11-13 02:55:54 +00:00
|
|
|
|
|
|
|
elif [[ "${GITHUB_EVENT_NAME}" =~ push|workflow_dispatch && "${REF}" == "refs/heads/master" ]]; then
|
|
|
|
echo "::notice title=::This run will release a snapshot"
|
|
|
|
echo "::set-output name=do_snapshot_release::true"
|
|
|
|
|
2021-09-03 05:57:59 +00:00
|
|
|
else
|
|
|
|
echo "This run will NOT make a release"
|
|
|
|
fi
|
|
|
|
|
2021-11-02 06:59:16 +00:00
|
|
|
# We run the tests on many OS / Java combinations but also the Compile step because some users build
|
|
|
|
# their own jars from source, so it is good for CI to check that is working on all combinations.
|
2021-10-31 04:28:23 +00:00
|
|
|
build:
|
|
|
|
needs: workflow_config
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
java_version: [ 8, 11, 17 ]
|
2021-11-30 23:16:24 +00:00
|
|
|
os: [ macos-10.15, macos-11, ubuntu-18.04, ubuntu-20.04, windows-2019, windows-2022 ]
|
2021-10-31 04:28:23 +00:00
|
|
|
include:
|
|
|
|
- release_from_this_build: true
|
|
|
|
os: ubuntu-20.04
|
|
|
|
java_version: 8
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
2021-03-21 13:03:23 +00:00
|
|
|
- name: Checkout the repository
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
2021-09-03 05:57:59 +00:00
|
|
|
- name: Set up java
|
2021-09-30 01:13:05 +00:00
|
|
|
uses: actions/setup-java@v2.3.1
|
2021-03-21 13:03:23 +00:00
|
|
|
with:
|
2021-10-31 04:28:23 +00:00
|
|
|
java-version: ${{ matrix.java_version }}
|
2021-09-03 05:57:59 +00:00
|
|
|
distribution: temurin
|
|
|
|
cache: maven
|
2021-03-21 13:03:23 +00:00
|
|
|
|
2021-09-03 05:57:59 +00:00
|
|
|
# Downloading all the dependencies is very log spammy, so we do this in its own step.
|
|
|
|
- name: Prime maven cache
|
2021-05-23 05:30:08 +00:00
|
|
|
run: mvn --batch-mode dependency:go-offline
|
2021-07-31 21:47:07 +00:00
|
|
|
|
2021-09-03 05:57:59 +00:00
|
|
|
# POM version is usually a -SNAPSHOT at this point, if this is a release then we use the version derived from the tag
|
|
|
|
- name: Set POM version
|
2021-10-31 04:28:23 +00:00
|
|
|
if: needs.workflow_config.outputs.do_release == 'true'
|
2021-09-03 05:57:59 +00:00
|
|
|
env:
|
2021-10-31 04:28:23 +00:00
|
|
|
POM_VERSION: ${{ needs.workflow_config.outputs.pom_version }}
|
2021-11-12 15:46:46 +00:00
|
|
|
run: mvn --batch-mode versions:set "-DnewVersion=${POM_VERSION}"
|
2021-09-03 05:57:59 +00:00
|
|
|
|
|
|
|
# Compile / Test / Package are separate steps so the reason for any failure is more obvious in GitHub UI
|
|
|
|
- name: Compile
|
|
|
|
run: mvn --batch-mode compile
|
|
|
|
|
|
|
|
- name: Test
|
|
|
|
run: mvn --batch-mode test
|
|
|
|
|
|
|
|
- name: Package
|
2021-11-12 15:46:46 +00:00
|
|
|
if: matrix.release_from_this_build
|
2021-11-13 02:55:54 +00:00
|
|
|
run: mvn --batch-mode -DfinalName=plantuml -Dmaven.test.skip=true package
|
2021-09-03 05:57:59 +00:00
|
|
|
|
|
|
|
- name: Upload jar artifacts
|
2021-11-12 15:46:46 +00:00
|
|
|
if: matrix.release_from_this_build
|
2021-09-03 05:57:59 +00:00
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
# Using github.run_number here to reduce confusion when downloading & comparing artifacts from several builds
|
|
|
|
name: ${{ github.run_number }}-jars
|
|
|
|
path: target/*.jar
|
|
|
|
|
2021-10-31 04:28:23 +00:00
|
|
|
release:
|
|
|
|
needs: [ workflow_config, build ]
|
2021-11-13 02:55:54 +00:00
|
|
|
if: needs.workflow_config.outputs.do_release == 'true' || needs.workflow_config.outputs.do_snapshot_release == 'true'
|
2021-10-31 04:28:23 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout the repository
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Download jar artifacts
|
|
|
|
uses: actions/download-artifact@v2
|
|
|
|
with:
|
|
|
|
name: ${{ github.run_number }}-jars
|
|
|
|
|
2021-11-13 02:55:54 +00:00
|
|
|
- name: Create snapshot release
|
|
|
|
if: needs.workflow_config.outputs.do_snapshot_release == 'true'
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
|
|
run: .github/scripts/release_snapshot.sh
|
|
|
|
|
2021-09-03 05:57:59 +00:00
|
|
|
- name: Create release in GitHub
|
2021-11-13 02:55:54 +00:00
|
|
|
if: needs.workflow_config.outputs.do_release == 'true'
|
2021-09-03 05:57:59 +00:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ github.token }}
|
2021-10-31 04:28:23 +00:00
|
|
|
POM_VERSION: ${{ needs.workflow_config.outputs.pom_version }}
|
2021-09-03 05:57:59 +00:00
|
|
|
TAG: ${{ github.event.ref }}
|
2021-11-13 02:55:54 +00:00
|
|
|
run: .github/scripts/release.sh
|