2022-03-11 05:42:52 +00:00
|
|
|
name: CI
|
2021-05-23 05:30:08 +00:00
|
|
|
|
|
|
|
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/**'
|
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:
|
2022-06-06 18:00:16 +00:00
|
|
|
- name: Checkout the repository
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
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}'"
|
2022-10-25 01:17:59 +00:00
|
|
|
echo "do_release=true" >> $GITHUB_OUTPUT
|
|
|
|
echo "pom_version=${REF#v}" >> $GITHUB_OUTPUT # pom_version is the tag without the 'v' prefix
|
2021-11-13 02:55:54 +00:00
|
|
|
|
2023-01-17 18:00:39 +00:00
|
|
|
elif [[ "${GITHUB_EVENT_NAME}" =~ push|workflow_dispatch && "${REF}" == "refs/heads/master" && "${ACTOR}" == "arnaudroques" ]]; then
|
2021-11-13 02:55:54 +00:00
|
|
|
echo "::notice title=::This run will release a snapshot"
|
2022-10-25 01:17:59 +00:00
|
|
|
echo "do_snapshot_release=true" >> $GITHUB_OUTPUT
|
2022-06-06 18:00:16 +00:00
|
|
|
V=$(perl -ne 'if (/return (\d{6,7});/) {$v=$1} if (/final int beta = (\d+);/) {$b=$1} END{print(substr($v, 0, 1),".", substr($v, 1, 4),"."); if ($b) {print(int(substr($v+1, 5)), "beta", $b);} else {print(int(substr($v, 5)))}}' src/net/sourceforge/plantuml/version/Version.java)
|
2022-10-25 01:17:59 +00:00
|
|
|
echo "pom_version=$V-SNAPSHOT" >> $GITHUB_OUTPUT # pom_version is taken from Version.java
|
2021-11-13 02:55:54 +00:00
|
|
|
|
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.
|
2022-03-11 05:42:52 +00:00
|
|
|
test:
|
2021-10-31 04:28:23 +00:00
|
|
|
needs: workflow_config
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2022-02-11 06:20:56 +00:00
|
|
|
java_version: [ 8, 11, 17 ]
|
2022-09-29 00:01:56 +00:00
|
|
|
os: [ ubuntu-20.04, ubuntu-22.04, windows-2019, windows-2022 ]
|
2021-10-31 04:28:23 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
2021-03-21 13:03:23 +00:00
|
|
|
- name: Checkout the repository
|
2022-04-17 20:06:34 +00:00
|
|
|
uses: actions/checkout@v3
|
2021-03-21 13:03:23 +00:00
|
|
|
|
2021-09-03 05:57:59 +00:00
|
|
|
- name: Set up java
|
2023-02-18 07:27:59 +00:00
|
|
|
uses: actions/setup-java@v3.10.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
|
2022-03-11 05:42:52 +00:00
|
|
|
cache: gradle
|
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-03-11 05:42:52 +00:00
|
|
|
run: gradle -q compileJava --no-daemon
|
2021-09-03 05:57:59 +00:00
|
|
|
|
|
|
|
- name: Test
|
2022-08-29 16:33:02 +00:00
|
|
|
run: gradle test --no-daemon -i
|
2022-05-05 08:25:40 +00:00
|
|
|
|
|
|
|
- name: Upload test reports
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
if: ${{ always() }}
|
|
|
|
with:
|
|
|
|
# Using github.run_number here to reduce confusion when downloading & comparing from several builds
|
|
|
|
name: ${{ github.run_number }}-${{ matrix.os }}-java-${{ matrix.java_version }}-test-reports
|
|
|
|
path: build/reports/tests/
|
2022-03-11 05:42:52 +00:00
|
|
|
|
|
|
|
upload:
|
|
|
|
needs: [ workflow_config, test ]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout the repository
|
|
|
|
uses: actions/checkout@v2
|
2021-09-03 05:57:59 +00:00
|
|
|
|
2022-03-11 05:42:52 +00:00
|
|
|
- name: Set up java
|
2022-09-17 17:00:07 +00:00
|
|
|
uses: actions/setup-java@v3.5.0
|
2022-03-11 05:42:52 +00:00
|
|
|
with:
|
|
|
|
java-version: 17
|
|
|
|
distribution: temurin
|
|
|
|
cache: gradle
|
2021-12-08 01:42:42 +00:00
|
|
|
|
2022-03-11 05:42:52 +00:00
|
|
|
- name: Set version from tag
|
|
|
|
if: env.POM_VERSION
|
2021-12-08 01:42:42 +00:00
|
|
|
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
|
2021-09-03 05:57:59 +00:00
|
|
|
|
2022-03-11 05:42:52 +00:00
|
|
|
- name: Build artifacts
|
|
|
|
run: |
|
|
|
|
gradle -q clean build \
|
|
|
|
pdfJar \
|
|
|
|
generateMetadataFileForMavenPublication generatePomFileForMavenPublication \
|
|
|
|
-x test
|
2021-12-08 01:42:42 +00:00
|
|
|
|
2022-03-11 05:42:52 +00:00
|
|
|
- name: Sign artifacts
|
|
|
|
if: env.ORG_GRADLE_PROJECT_signingKey
|
2021-12-08 01:42:42 +00:00
|
|
|
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 }}
|
2021-12-08 01:42:42 +00:00
|
|
|
run: |
|
2022-09-27 23:25:52 +00:00
|
|
|
gradle -i signMavenPublication signPdfJar
|
2021-12-08 01:42:42 +00:00
|
|
|
|
|
|
|
- name: Upload artifacts
|
2022-04-17 20:06:34 +00:00
|
|
|
uses: actions/upload-artifact@v3
|
2021-09-03 05:57:59 +00:00
|
|
|
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: |
|
2022-03-11 05:42:52 +00:00
|
|
|
build/libs/*
|
|
|
|
build/publications/maven/*
|
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 }}
|
2022-09-26 23:51:52 +00:00
|
|
|
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
|
|
|
|
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
|
2023-03-08 21:40:21 +00:00
|
|
|
#do not remove signing key and password or signatures will not be published
|
|
|
|
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ARTIFACT_SIGNING_KEY }}
|
|
|
|
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ARTIFACT_SIGNING_PASSPHRASE }}
|
2022-09-26 23:51:52 +00:00
|
|
|
run: |
|
|
|
|
.github/scripts/release-snapshot.sh
|
|
|
|
gradle publish
|
2021-11-13 02:55:54 +00:00
|
|
|
|
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 }}
|
|
|
|
TAG: ${{ github.event.ref }}
|
2022-09-26 23:51:52 +00:00
|
|
|
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
|
|
|
|
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
|
2023-03-08 21:40:21 +00:00
|
|
|
#do not remove signing key and password or signatures will not be published
|
|
|
|
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ARTIFACT_SIGNING_KEY }}
|
|
|
|
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ARTIFACT_SIGNING_PASSPHRASE }}
|
2022-09-26 23:51:52 +00:00
|
|
|
run: |
|
|
|
|
.github/scripts/release.sh
|
|
|
|
gradle publish
|
2022-07-30 00:40:52 +00:00
|
|
|
|
|
|
|
push_to_registry:
|
|
|
|
needs: [ workflow_config, test, upload ]
|
|
|
|
if: needs.workflow_config.outputs.do_release == 'true'
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Check out the repo
|
|
|
|
uses: actions/checkout@v3
|
2023-01-13 01:47:30 +00:00
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v2
|
2022-07-30 00:40:52 +00:00
|
|
|
- name: Docker meta
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v4
|
|
|
|
with:
|
|
|
|
# list of Docker images to use as base name for tags
|
|
|
|
images: |
|
2022-08-17 01:12:59 +00:00
|
|
|
${{ github.repository }}
|
2023-01-13 05:22:15 +00:00
|
|
|
ghcr.io/${{ github.repository }}
|
2022-07-30 00:40:52 +00:00
|
|
|
# generate Docker tags based on the following events/attributes
|
|
|
|
tags: |
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
|
|
type=semver,pattern={{major}}
|
|
|
|
type=sha
|
2023-01-13 05:22:15 +00:00
|
|
|
- name: Log into Docker Hub
|
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
2022-07-30 00:40:52 +00:00
|
|
|
- name: Log in to GitHub Docker Registry
|
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build/push container image
|
2023-02-18 07:27:59 +00:00
|
|
|
uses: docker/build-push-action@v4
|
2022-07-30 00:40:52 +00:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: true
|
|
|
|
build-args: |
|
|
|
|
PLANTUML_VERSION=${{ github.event.ref }}
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
2023-01-13 01:47:30 +00:00
|
|
|
platforms: linux/amd64,linux/arm64
|