1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-06 02:10:53 +00:00
plantuml/.github/workflows/ci.yml

151 lines
5.0 KiB
YAML
Raw Normal View History

2022-03-11 05:42:52 +00:00
name: CI gradle
on:
2022-03-11 05:42:52 +00:00
create:
pull_request:
types: [ opened, synchronize, reopened ]
paths-ignore:
- '*.md'
- 'docs/**'
push:
branches:
- master
paths-ignore:
- '*.md'
- 'docs/**'
workflow_dispatch:
defaults:
run:
shell: bash
2021-03-21 13:03:23 +00:00
jobs:
workflow_config:
2021-03-21 13:03:23 +00:00
runs-on: ubuntu-latest
outputs:
do_release: ${{ steps.config.outputs.do_release }}
do_snapshot_release: ${{ steps.config.outputs.do_snapshot_release }}
pom_version: ${{ steps.config.outputs.pom_version }}
2021-03-21 13:03:23 +00:00
steps:
- name: Configure workflow
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* && \
( "${ACTOR}" == "arnaudroques" || "${ACTOR}" == "${GITHUB_REPOSITORY_OWNER}" ) \
]]; then
echo "::notice title=::This run will release '${REF}'"
echo "::set-output name=do_release::true"
echo "::set-output name=pom_version::${REF#v}" # pom_version is the tag without the 'v' prefix
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"
else
echo "This run will NOT make a release"
fi
# 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.
2022-03-11 05:42:52 +00:00
test:
needs: workflow_config
strategy:
fail-fast: false
matrix:
java_version: [ 8, 11, 17 ]
os: [ macos-10.15, macos-11, ubuntu-18.04, ubuntu-20.04, windows-2019, windows-2022 ]
runs-on: ${{ matrix.os }}
steps:
2021-03-21 13:03:23 +00:00
- name: Checkout the repository
uses: actions/checkout@v2
- name: Set up java
uses: actions/setup-java@v3.0.0
2021-03-21 13:03:23 +00:00
with:
java-version: ${{ matrix.java_version }}
distribution: temurin
2022-03-11 05:42:52 +00:00
cache: gradle
# Compile / Test / Package are separate steps so the reason for any failure is more obvious in GitHub UI
- name: Compile
2022-03-11 05:42:52 +00:00
run: gradle -q compileJava --no-daemon
- name: Test
2022-03-11 05:42:52 +00:00
run: gradle -q test --no-daemon
upload:
needs: [ workflow_config, test ]
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v2
2022-03-11 05:42:52 +00:00
- name: Set up java
uses: actions/setup-java@v3.0.0
with:
java-version: 17
distribution: temurin
cache: gradle
2022-03-11 05:42:52 +00:00
- name: Set version from tag
if: env.POM_VERSION
env:
2022-03-11 05:42:52 +00:00
POM_VERSION: ${{ needs.workflow_config.outputs.pom_version }}
run: sed -i "s/version = .*/version = $POM_VERSION/" gradle.properties
2022-03-11 05:42:52 +00:00
- name: Build artifacts
run: |
gradle -q clean build \
pdfJar \
generateMetadataFileForMavenPublication generatePomFileForMavenPublication \
-x test
2022-03-11 05:42:52 +00:00
- name: Sign artifacts
if: env.ORG_GRADLE_PROJECT_signingKey
env:
2022-03-11 05:42:52 +00:00
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ARTIFACT_SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ARTIFACT_SIGNING_PASSPHRASE }}
run: |
2022-03-11 05:42:52 +00:00
gradle -q signMavenPublication signPdfJar
- name: Upload artifacts
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 }}-artifacts
path: |
2022-03-11 05:42:52 +00:00
build/libs/*
build/publications/maven/*
- name: Create snapshot release
if: needs.workflow_config.outputs.do_snapshot_release == 'true'
env:
GITHUB_TOKEN: ${{ github.token }}
2022-03-11 05:42:52 +00:00
run: .github/scripts/release-gradle-snapshot.sh
- name: Create release in GitHub
if: needs.workflow_config.outputs.do_release == 'true'
env:
GITHUB_TOKEN: ${{ github.token }}
TAG: ${{ github.event.ref }}
2022-03-11 05:42:52 +00:00
run: .github/scripts/release-gradle.sh