From 33cbfdd951a34c6d3012e0aa41dd4f0438ef4124 Mon Sep 17 00:00:00 2001 From: matthew16550 Date: Sat, 13 Nov 2021 02:46:46 +1100 Subject: [PATCH 1/2] Minor syntax simplifications in ci.yml --- .github/workflows/ci.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37111d965..6b7a43385 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,9 +42,7 @@ jobs: # 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) - 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}" ) \ ]]; then echo "📣 This run will release '${REF}'" @@ -88,8 +86,7 @@ jobs: if: needs.workflow_config.outputs.do_release == 'true' env: POM_VERSION: ${{ needs.workflow_config.outputs.pom_version }} - run: | - mvn --batch-mode versions:set "-DnewVersion=${POM_VERSION}" + run: mvn --batch-mode versions:set "-DnewVersion=${POM_VERSION}" # Compile / Test / Package are separate steps so the reason for any failure is more obvious in GitHub UI - name: Compile @@ -99,11 +96,11 @@ jobs: run: mvn --batch-mode test - name: Package - if: ${{ matrix.release_from_this_build }} + if: matrix.release_from_this_build run: mvn --batch-mode -Dmaven.test.skip=true package - name: Upload jar artifacts - if: ${{ matrix.release_from_this_build }} + if: matrix.release_from_this_build uses: actions/upload-artifact@v2 with: # Using github.run_number here to reduce confusion when downloading & comparing artifacts from several builds From 54d0bf27b58525095c309b5b893685c74348e65b Mon Sep 17 00:00:00 2001 From: matthew16550 Date: Sat, 13 Nov 2021 13:55:54 +1100 Subject: [PATCH 2/2] Update CI to create snapshot releases in GitHub --- .github/scripts/release.sh | 13 +++++++++++++ .github/scripts/release_snapshot.sh | 26 ++++++++++++++++++++++++++ .github/workflows/ci.yml | 25 +++++++++++++++++-------- pom.xml | 2 ++ 4 files changed, 58 insertions(+), 8 deletions(-) create mode 100755 .github/scripts/release.sh create mode 100755 .github/scripts/release_snapshot.sh diff --git a/.github/scripts/release.sh b/.github/scripts/release.sh new file mode 100755 index 000000000..e78a64815 --- /dev/null +++ b/.github/scripts/release.sh @@ -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} 🎉" diff --git a/.github/scripts/release_snapshot.sh b/.github/scripts/release_snapshot.sh new file mode 100755 index 000000000..fabe1c6e4 --- /dev/null +++ b/.github/scripts/release_snapshot.sh @@ -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}" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b7a43385..a4794f11f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,7 @@ jobs: 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 }} steps: - name: Configure workflow @@ -45,9 +46,14 @@ jobs: if [[ "${GITHUB_EVENT_NAME}" == "create" && "${REF_TYPE}" == "tag" && "${REF}" == v* && \ ( "${ACTOR}" == "arnaudroques" || "${ACTOR}" == "${GITHUB_REPOSITORY_OWNER}" ) \ ]]; 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=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 @@ -97,7 +103,7 @@ jobs: - name: Package 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 if: matrix.release_from_this_build @@ -119,7 +125,7 @@ jobs: release: 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 steps: - name: Checkout the repository @@ -130,13 +136,16 @@ jobs: with: 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 + if: needs.workflow_config.outputs.do_release == 'true' env: GITHUB_TOKEN: ${{ github.token }} POM_VERSION: ${{ needs.workflow_config.outputs.pom_version }} TAG: ${{ github.event.ref }} - run: | - gh release create "${TAG}" \ - "plantuml-${POM_VERSION}.jar" \ - "plantuml-${POM_VERSION}-javadoc.jar" \ - "plantuml-${POM_VERSION}-sources.jar" + run: .github/scripts/release.sh diff --git a/pom.xml b/pom.xml index 491cfbfb9..966d33c18 100644 --- a/pom.xml +++ b/pom.xml @@ -58,6 +58,7 @@ + ${project.artifactId}-${project.version} 1.7 1.7 1.8 @@ -131,6 +132,7 @@ + ${finalName} ${project.basedir}/src ${project.basedir}/test