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:
|
2022-02-11 06:20:56 +00:00
|
|
|
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
|
2022-02-11 06:20:56 +00:00
|
|
|
java_version: 8
|
2021-10-31 04:28:23 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
2021-12-08 01:42:42 +00:00
|
|
|
env:
|
|
|
|
SIGN_ARTIFACTS: ${{ secrets.ARTIFACT_SIGNING_KEY != '' }}
|
2021-10-31 04:28:23 +00:00
|
|
|
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
|
2022-02-11 06:20:56 +00:00
|
|
|
uses: actions/setup-java@v2.5.0
|
2021-03-21 13:03:23 +00:00
|
|
|
with:
|
2022-02-11 06:20:56 +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
|
2022-02-11 06:20:56 +00:00
|
|
|
run: mvn --batch-mode compile
|
2021-09-03 05:57:59 +00:00
|
|
|
|
|
|
|
- name: Test
|
2022-02-11 06:20:56 +00:00
|
|
|
run: mvn --batch-mode test
|
2021-09-03 05:57:59 +00:00
|
|
|
|
2021-12-08 01:42:42 +00:00
|
|
|
# The repeated "matrix.release_from_this_build" checks are messy, but I have not found a simple way to avoid them
|
|
|
|
# See https://github.com/actions/runner/issues/662
|
|
|
|
|
|
|
|
- name: Setup gpg
|
|
|
|
if: matrix.release_from_this_build && env.ARTIFACT_SIGNING_KEY
|
|
|
|
id: gpg
|
|
|
|
env:
|
|
|
|
ARTIFACT_SIGNING_KEY: ${{ secrets.ARTIFACT_SIGNING_KEY }}
|
|
|
|
run: |
|
|
|
|
echo "Importing key ..."
|
|
|
|
echo "${ARTIFACT_SIGNING_KEY}" | gpg --batch --import --import-options import-show
|
2021-09-03 05:57:59 +00:00
|
|
|
|
2021-12-08 01:42:42 +00:00
|
|
|
echo "Getting key id ..."
|
|
|
|
key_id="$(echo "${ARTIFACT_SIGNING_KEY}" | gpg --batch --show-keys --with-colons | awk -F: '$1 == "sec" { print $5 }')"
|
|
|
|
echo "::set-output name=key_id::${key_id}"
|
|
|
|
|
|
|
|
- name: Create artifacts
|
|
|
|
if: matrix.release_from_this_build
|
|
|
|
env:
|
|
|
|
GPG_KEYNAME: ${{ steps.gpg.outputs.key_id }}
|
|
|
|
GPG_PASSPHRASE: ${{ secrets.ARTIFACT_SIGNING_PASSPHRASE }}
|
|
|
|
run: |
|
2021-12-09 10:03:26 +00:00
|
|
|
[[ "${SIGN_ARTIFACTS}" == "true" ]] || cp pom.xml target/plantuml.pom
|
|
|
|
|
2021-12-08 01:42:42 +00:00
|
|
|
mvn --batch-mode \
|
|
|
|
"-DfinalName=plantuml" \
|
|
|
|
"-Dgpg.keyname=${GPG_KEYNAME}" \
|
|
|
|
"-Dgpg.passphrase=${GPG_PASSPHRASE}" \
|
|
|
|
"-Dmaven.test.skip=true" \
|
|
|
|
verify
|
|
|
|
|
|
|
|
- name: Upload 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:
|
2022-02-04 00:12:06 +00:00
|
|
|
# Using github.run_number here to reduce confusion when downloading & comparing artifacts from several builds
|
2021-12-08 01:42:42 +00:00
|
|
|
name: ${{ github.run_number }}-artifacts
|
|
|
|
path: |
|
|
|
|
target/*.asc
|
|
|
|
target/*.jar
|
|
|
|
target/*.pom
|
2021-09-03 05:57:59 +00:00
|
|
|
|
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
|
|
|
|
|
2021-12-08 01:42:42 +00:00
|
|
|
- name: Download artifacts
|
2021-10-31 04:28:23 +00:00
|
|
|
uses: actions/download-artifact@v2
|
|
|
|
with:
|
2021-12-08 01:42:42 +00:00
|
|
|
name: ${{ github.run_number }}-artifacts
|
|
|
|
path: target
|
2021-10-31 04:28:23 +00:00
|
|
|
|
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
|