1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-29 08:13:53 +00:00

Update CI to create snapshot releases in GitHub

This commit is contained in:
matthew16550 2021-11-13 13:55:54 +11:00
parent 33cbfdd951
commit 54d0bf27b5
4 changed files with 58 additions and 8 deletions

13
.github/scripts/release.sh vendored Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -ex
mv plantuml.jar "plantuml-${POM_VERSION}.jar"
mv plantuml-javadoc.jar "plantuml-${POM_VERSION}-javadoc.jar"
mv plantuml-sources.jar "plantuml-${POM_VERSION}-sources.jar"
gh release create --target "${GITHUB_SHA}" "${TAG}" \
"plantuml-${POM_VERSION}.jar" \
"plantuml-${POM_VERSION}-javadoc.jar" \
"plantuml-${POM_VERSION}-sources.jar"
echo "::notice title=::Released at ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/releases/tag/${TAG} 🎉"

26
.github/scripts/release_snapshot.sh vendored Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -ex
TAG="snapshot"
gh release delete "${TAG}" -y || true
git tag --force "${TAG}"
git push --force origin "${TAG}"
mv plantuml.jar plantuml-SNAPSHOT.jar
mv plantuml-javadoc.jar plantuml-SNAPSHOT-javadoc.jar
mv plantuml-sources.jar plantuml-SNAPSHOT-sources.jar
cat <<-EOF >notes.txt
This is a pre-release of the latest development work.
⚠️ **It is not ready for general use** ⚠️
EOF
gh release create --prerelease --target "${GITHUB_SHA}" --notes-file notes.txt "${TAG}" \
plantuml-SNAPSHOT.jar \
plantuml-SNAPSHOT-javadoc.jar \
plantuml-SNAPSHOT-sources.jar
echo "::notice title=::Snapshot released at ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/releases/tag/${TAG}"

View File

@ -18,6 +18,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
do_release: ${{ steps.config.outputs.do_release }} do_release: ${{ steps.config.outputs.do_release }}
do_snapshot_release: ${{ steps.config.outputs.do_snapshot_release }}
pom_version: ${{ steps.config.outputs.pom_version }} pom_version: ${{ steps.config.outputs.pom_version }}
steps: steps:
- name: Configure workflow - name: Configure workflow
@ -45,9 +46,14 @@ jobs:
if [[ "${GITHUB_EVENT_NAME}" == "create" && "${REF_TYPE}" == "tag" && "${REF}" == v* && \ if [[ "${GITHUB_EVENT_NAME}" == "create" && "${REF_TYPE}" == "tag" && "${REF}" == v* && \
( "${ACTOR}" == "arnaudroques" || "${ACTOR}" == "${GITHUB_REPOSITORY_OWNER}" ) \ ( "${ACTOR}" == "arnaudroques" || "${ACTOR}" == "${GITHUB_REPOSITORY_OWNER}" ) \
]]; then ]]; then
echo "📣 This run will release '${REF}'" echo "::notice title=::This run will release '${REF}'"
echo "::set-output name=do_release::true" echo "::set-output name=do_release::true"
echo "::set-output name=pom_version::${REF#v}" # pom_version is the tag without the 'v' prefix 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 else
echo "This run will NOT make a release" echo "This run will NOT make a release"
fi fi
@ -97,7 +103,7 @@ jobs:
- name: Package - name: Package
if: matrix.release_from_this_build if: matrix.release_from_this_build
run: mvn --batch-mode -Dmaven.test.skip=true package run: mvn --batch-mode -DfinalName=plantuml -Dmaven.test.skip=true package
- name: Upload jar artifacts - name: Upload jar artifacts
if: matrix.release_from_this_build if: matrix.release_from_this_build
@ -119,7 +125,7 @@ jobs:
release: release:
needs: [ workflow_config, build ] needs: [ workflow_config, build ]
if: needs.workflow_config.outputs.do_release == 'true' if: needs.workflow_config.outputs.do_release == 'true' || needs.workflow_config.outputs.do_snapshot_release == 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout the repository - name: Checkout the repository
@ -130,13 +136,16 @@ jobs:
with: with:
name: ${{ github.run_number }}-jars name: ${{ github.run_number }}-jars
- name: Create snapshot release
if: needs.workflow_config.outputs.do_snapshot_release == 'true'
env:
GITHUB_TOKEN: ${{ github.token }}
run: .github/scripts/release_snapshot.sh
- name: Create release in GitHub - name: Create release in GitHub
if: needs.workflow_config.outputs.do_release == 'true'
env: env:
GITHUB_TOKEN: ${{ github.token }} GITHUB_TOKEN: ${{ github.token }}
POM_VERSION: ${{ needs.workflow_config.outputs.pom_version }} POM_VERSION: ${{ needs.workflow_config.outputs.pom_version }}
TAG: ${{ github.event.ref }} TAG: ${{ github.event.ref }}
run: | run: .github/scripts/release.sh
gh release create "${TAG}" \
"plantuml-${POM_VERSION}.jar" \
"plantuml-${POM_VERSION}-javadoc.jar" \
"plantuml-${POM_VERSION}-sources.jar"

View File

@ -58,6 +58,7 @@
</parent> </parent>
<properties> <properties>
<finalName>${project.artifactId}-${project.version}</finalName>
<maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target> <maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.testSource>1.8</maven.compiler.testSource> <maven.compiler.testSource>1.8</maven.compiler.testSource>
@ -131,6 +132,7 @@
</developers> </developers>
<build> <build>
<finalName>${finalName}</finalName>
<sourceDirectory>${project.basedir}/src</sourceDirectory> <sourceDirectory>${project.basedir}/src</sourceDirectory>
<testSourceDirectory>${project.basedir}/test</testSourceDirectory> <testSourceDirectory>${project.basedir}/test</testSourceDirectory>
<resources> <resources>