From defeb87909a4456daeb09f6629d61f3fc37432ed Mon Sep 17 00:00:00 2001 From: soloturn Date: Fri, 11 Feb 2022 15:59:00 +0100 Subject: [PATCH 1/4] gradle, clean, maven publication, same version for build/sign --- .github/workflows/ci-gradle.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-gradle.yml b/.github/workflows/ci-gradle.yml index 7e3abc939..5ed7e5b72 100644 --- a/.github/workflows/ci-gradle.yml +++ b/.github/workflows/ci-gradle.yml @@ -101,7 +101,9 @@ jobs: - name: Create artifacts if: matrix.release_from_this_build - run: gradle -q build -x test + env: + POM_VERSION: ${{ needs.workflow_config.outputs.pom_version }} + run: gradle -q clean build generateMetadataFileForMavenPublication generatePomFileForMavenPublication -Pversion=${POM_VERSION} -x test - name: Setup gpg if: matrix.release_from_this_build && env.ARTIFACT_SIGNING_KEY @@ -121,6 +123,7 @@ jobs: env: GPG_KEYNAME: ${{ steps.gpg.outputs.key_id }} GPG_PASSPHRASE: ${{ secrets.ARTIFACT_SIGNING_PASSPHRASE }} + POM_VERSION: ${{ needs.workflow_config.outputs.pom_version }} run: | gradle sign "-Pversion=${POM_VERSION}"\ "-Psigning.gnupg.keyName=${GPG_KEYNAME}" \ From a08af697e4b4dfc0c54bcd8c5b5d4dc677f3f5ba Mon Sep 17 00:00:00 2001 From: soloturn Date: Fri, 11 Feb 2022 16:47:05 +0100 Subject: [PATCH 2/4] gradle release, gh publish signatures. --- .github/scripts/release-gradle.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/scripts/release-gradle.sh b/.github/scripts/release-gradle.sh index 03c69d6b5..7bd9bc88b 100755 --- a/.github/scripts/release-gradle.sh +++ b/.github/scripts/release-gradle.sh @@ -1,14 +1,20 @@ #!/usr/bin/env bash set -ex -RELEASE_DIR="build/libs/github_release" +RELEASE_DIR="build/github_release" mkdir "${RELEASE_DIR}" ln -s "../libs/plantuml.jar" "${RELEASE_DIR}/plantuml-${POM_VERSION}.jar" ln -s "../libs/plantuml-javadoc.jar" "${RELEASE_DIR}/plantuml-${POM_VERSION}-javadoc.jar" ln -s "../libs/plantuml-sources.jar" "${RELEASE_DIR}/plantuml-${POM_VERSION}-sources.jar" -# we do not release the .pom or .asc signature files here, they will be added in a later PR + +if [[ -e "build/publications/maven/module.json.asc" ]]; then + # signatures are optional so that forked repos can release snapshots without needing a gpg signing key + ln -s "../libs/plantuml.jar.asc" "${RELEASE_DIR}/plantuml-${POM_VERSION}.jar.asc" + ln -s "../libs/plantuml-javadoc.jar.asc" "${RELEASE_DIR}/plantuml-${POM_VERSION}-javadoc.jar.asc" + ln -s "../libs/plantuml-sources.jar.asc" "${RELEASE_DIR}/plantuml-${POM_VERSION}-sources.jar.asc" +fi gh release create \ --target "${GITHUB_SHA}" \ From ba4c7da3e49531841672156b263e356c76104d74 Mon Sep 17 00:00:00 2001 From: soloturn Date: Sat, 12 Feb 2022 08:36:01 +0100 Subject: [PATCH 3/4] gradle, separate test, and build/upload --- .github/workflows/ci-gradle.yml | 54 +++++++++++++++------------------ 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci-gradle.yml b/.github/workflows/ci-gradle.yml index 5ed7e5b72..c58947790 100644 --- a/.github/workflows/ci-gradle.yml +++ b/.github/workflows/ci-gradle.yml @@ -66,17 +66,13 @@ jobs: # 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. - build: + 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 ] - include: - - release_from_this_build: true - os: ubuntu-20.04 - java_version: 8 runs-on: ${{ matrix.os }} steps: - name: Checkout the repository @@ -96,17 +92,32 @@ jobs: - name: Test run: gradle -q test --no-daemon - # 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 + upload: + needs: [ workflow_config, test ] + 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 + uses: actions/checkout@v2 - - name: Create artifacts - if: matrix.release_from_this_build + - name: Set up java + uses: actions/setup-java@v2.5.0 + with: + java-version: 17 + distribution: temurin + cache: gradle + + - name: Set version from tag + if: env.POM_VERSION env: POM_VERSION: ${{ needs.workflow_config.outputs.pom_version }} - run: gradle -q clean build generateMetadataFileForMavenPublication generatePomFileForMavenPublication -Pversion=${POM_VERSION} -x test + run: sed -i "s/version = .*/version = $POM_VERSION/" gradle.properties + + - name: Build artifacts + run: gradle -q clean build generateMetadataFileForMavenPublication generatePomFileForMavenPublication -x test - name: Setup gpg - if: matrix.release_from_this_build && env.ARTIFACT_SIGNING_KEY + if: env.ARTIFACT_SIGNING_KEY id: gpg env: ARTIFACT_SIGNING_KEY: ${{ secrets.ARTIFACT_SIGNING_KEY }} @@ -119,18 +130,16 @@ jobs: echo "::set-output name=key_id::${key_id}" - name: Sign artifacts - if: matrix.release_from_this_build && env.GPG_KEYNAME + if: env.GPG_KEYNAME env: GPG_KEYNAME: ${{ steps.gpg.outputs.key_id }} GPG_PASSPHRASE: ${{ secrets.ARTIFACT_SIGNING_PASSPHRASE }} - POM_VERSION: ${{ needs.workflow_config.outputs.pom_version }} run: | - gradle sign "-Pversion=${POM_VERSION}"\ + gradle sign \ "-Psigning.gnupg.keyName=${GPG_KEYNAME}" \ "-Psigning.gnupg.passphrase=${GPG_PASSPHRASE}" - name: Upload artifacts - 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 @@ -139,20 +148,6 @@ jobs: build/libs/* build/publications/maven/* - release: - needs: [ workflow_config, build ] - 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 - uses: actions/checkout@v2 - - - name: Download artifacts - uses: actions/download-artifact@v2 - with: - name: ${{ github.run_number }}-artifacts - path: build - - name: Create snapshot release if: needs.workflow_config.outputs.do_snapshot_release == 'true' env: @@ -163,6 +158,5 @@ jobs: 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: .github/scripts/release-gradle.sh From d201e7de64d4f7c1c7d61de088dc9685bd1ac1e3 Mon Sep 17 00:00:00 2001 From: soloturn Date: Sat, 12 Feb 2022 08:56:20 +0100 Subject: [PATCH 4/4] gradle, store POM_VERSION in properties so it is taken everywhere. --- .github/scripts/release-gradle-snapshot.sh | 21 +++++++++++---------- .github/scripts/release-gradle.sh | 13 +++++++------ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/scripts/release-gradle-snapshot.sh b/.github/scripts/release-gradle-snapshot.sh index 31462f09d..6e02588b4 100755 --- a/.github/scripts/release-gradle-snapshot.sh +++ b/.github/scripts/release-gradle-snapshot.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -ex +POM_VERSION=$(gradle properties -q | grep "version:" | awk '{print $2}') TAG="snapshot" DATE_TIME_UTC=$(date -u +"%F at %T (UTC)") RELEASE_DIR="build/github_release" @@ -13,19 +14,19 @@ git push --force origin "${TAG}" mkdir "${RELEASE_DIR}" -ln -s "../publications/maven/module.json" "${RELEASE_DIR}/plantuml-SNAPSHOT-module.json" -ln -s "../publications/maven/pom-default.xml" "${RELEASE_DIR}/plantuml-SNAPSHOT.pom" -ln -s "../libs/plantuml.jar" "${RELEASE_DIR}/plantuml-SNAPSHOT.jar" -ln -s "../libs/plantuml-javadoc.jar" "${RELEASE_DIR}/plantuml-SNAPSHOT-javadoc.jar" -ln -s "../libs/plantuml-sources.jar" "${RELEASE_DIR}/plantuml-SNAPSHOT-sources.jar" +ln -s "../publications/maven/module.json" "${RELEASE_DIR}/plantuml-SNAPSHOT-module.json" +ln -s "../publications/maven/pom-default.xml" "${RELEASE_DIR}/plantuml-SNAPSHOT.pom" +ln -s "../libs/plantuml-${POM_VERSION}.jar" "${RELEASE_DIR}/plantuml-SNAPSHOT.jar" +ln -s "../libs/plantuml-${POM_VERSION}-javadoc.jar" "${RELEASE_DIR}/plantuml-SNAPSHOT-javadoc.jar" +ln -s "../libs/plantuml-${POM_VERSION}-sources.jar" "${RELEASE_DIR}/plantuml-SNAPSHOT-sources.jar" if [[ -e "build/publications/maven/module.json.asc" ]]; then # signatures are optional so that forked repos can release snapshots without needing a gpg signing key - ln -s "../publications/maven/module.json.asc" "${RELEASE_DIR}/plantuml-SNAPSHOT-module.json.asc" - ln -s "../publications/maven/pom-default.xml.asc" "${RELEASE_DIR}/plantuml-SNAPSHOT.pom.asc" - ln -s "../libs/plantuml.jar.asc" "${RELEASE_DIR}/plantuml-SNAPSHOT.jar.asc" - ln -s "../libs/plantuml-javadoc.jar.asc" "${RELEASE_DIR}/plantuml-SNAPSHOT-javadoc.jar.asc" - ln -s "../libs/plantuml-sources.jar.asc" "${RELEASE_DIR}/plantuml-SNAPSHOT-sources.jar.asc" + ln -s "../publications/maven/module.json.asc" "${RELEASE_DIR}/plantuml-SNAPSHOT-module.json.asc" + ln -s "../publications/maven/pom-default.xml.asc" "${RELEASE_DIR}/plantuml-SNAPSHOT.pom.asc" + ln -s "../libs/plantuml-${POM_VERSION}.jar.asc" "${RELEASE_DIR}/plantuml-SNAPSHOT.jar.asc" + ln -s "../libs/plantuml-${POM_VERSION}-javadoc.jar.asc" "${RELEASE_DIR}/plantuml-SNAPSHOT-javadoc.jar.asc" + ln -s "../libs/plantuml-${POM_VERSION}-sources.jar.asc" "${RELEASE_DIR}/plantuml-SNAPSHOT-sources.jar.asc" fi echo -n "${DATE_TIME_UTC}" > "${RELEASE_DIR}/plantuml-SNAPSHOT.timestamp" diff --git a/.github/scripts/release-gradle.sh b/.github/scripts/release-gradle.sh index 7bd9bc88b..bd9311c92 100755 --- a/.github/scripts/release-gradle.sh +++ b/.github/scripts/release-gradle.sh @@ -1,19 +1,20 @@ #!/usr/bin/env bash set -ex +POM_VERSION=$(gradle properties -q | grep "version:" | awk '{print $2}') RELEASE_DIR="build/github_release" mkdir "${RELEASE_DIR}" -ln -s "../libs/plantuml.jar" "${RELEASE_DIR}/plantuml-${POM_VERSION}.jar" -ln -s "../libs/plantuml-javadoc.jar" "${RELEASE_DIR}/plantuml-${POM_VERSION}-javadoc.jar" -ln -s "../libs/plantuml-sources.jar" "${RELEASE_DIR}/plantuml-${POM_VERSION}-sources.jar" +ln -s "../libs/plantuml-${POM_VERSION}.jar" "${RELEASE_DIR}/plantuml-${POM_VERSION}.jar" +ln -s "../libs/plantuml-${POM_VERSION}-javadoc.jar" "${RELEASE_DIR}/plantuml-${POM_VERSION}-javadoc.jar" +ln -s "../libs/plantuml-${POM_VERSION}-sources.jar" "${RELEASE_DIR}/plantuml-${POM_VERSION}-sources.jar" if [[ -e "build/publications/maven/module.json.asc" ]]; then # signatures are optional so that forked repos can release snapshots without needing a gpg signing key - ln -s "../libs/plantuml.jar.asc" "${RELEASE_DIR}/plantuml-${POM_VERSION}.jar.asc" - ln -s "../libs/plantuml-javadoc.jar.asc" "${RELEASE_DIR}/plantuml-${POM_VERSION}-javadoc.jar.asc" - ln -s "../libs/plantuml-sources.jar.asc" "${RELEASE_DIR}/plantuml-${POM_VERSION}-sources.jar.asc" + ln -s "../libs/plantuml-${POM_VERSION}.jar.asc" "${RELEASE_DIR}/plantuml-${POM_VERSION}.jar.asc" + ln -s "../libs/plantuml-${POM_VERSION}-javadoc.jar.asc" "${RELEASE_DIR}/plantuml-${POM_VERSION}-javadoc.jar.asc" + ln -s "../libs/plantuml-${POM_VERSION}-sources.jar.asc" "${RELEASE_DIR}/plantuml-${POM_VERSION}-sources.jar.asc" fi gh release create \