From eda184e6af63d6eee1b3a59c61d1695eef44fcb4 Mon Sep 17 00:00:00 2001 From: Mihai Nita Date: Thu, 29 Aug 2024 17:56:35 +0000 Subject: [PATCH] ICU-22606 Make the ICU4J release easier & more predictable --- .github/workflows/maven-publish.yml | 115 +++++++++++++++++++++ .gitignore | 1 + icu4j/demos/pom.xml | 7 -- icu4j/main/charset/pom.xml | 12 +++ icu4j/main/collate/pom.xml | 12 --- icu4j/main/common_tests/pom.xml | 7 -- icu4j/main/core/pom.xml | 7 -- icu4j/main/currdata/pom.xml | 12 --- icu4j/main/framework/pom.xml | 7 -- icu4j/main/icu4j/pom.xml | 12 +++ icu4j/main/langdata/pom.xml | 12 --- icu4j/main/localespi/pom.xml | 14 +++ icu4j/main/regiondata/pom.xml | 12 --- icu4j/main/translit/pom.xml | 12 --- icu4j/perf-tests/pom.xml | 9 +- icu4j/pom.xml | 150 +++++++++++++++++++++++----- icu4j/samples/pom.xml | 7 -- icu4j/tools/build/pom.xml | 12 --- icu4j/tools/misc/pom.xml | 9 +- 19 files changed, 282 insertions(+), 147 deletions(-) create mode 100644 .github/workflows/maven-publish.yml diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml new file mode 100644 index 000000000000..fe14fec48264 --- /dev/null +++ b/.github/workflows/maven-publish.yml @@ -0,0 +1,115 @@ +# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created +# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path + +name: Publish to Nexus Sonatype OSS + +# For this to run you should define the follwing GitHub Secrets in the proper Environment. +# In Settings -- Environments -- release_env -- Environment secrets: +# * MAVEN_CENTRAL_USERNAME & MAVEN_CENTRAL_TOKEN: +# * Go to https://oss.sonatype.org and login with the `icu-robot` user +# * Top-right select "Profile" +# * Open the drop-down list showing "Summary" and select "User Token" +# * Click the "Access User Token" button +# * The `username` (first, shorter part of the token) goes in the `MAVEN_CENTRAL_USERNAME` secret +# * The `password` (second, longer part of the token) goes in the `MAVEN_CENTRAL_TOKEN` secret +# * MAVEN_GPG_PRIVATE_KEY: an ASCII dump of the GPG private signing key: +# `gpg --output icu_release_signing.asc --armor --export-secret-key ` +# * MAVEN_GPG_PASSPHRASE: the GPG password used to protect that key + +on: + # To trigger the Env Test workflow manually, follow the instructions in + # https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow + workflow_dispatch: + inputs: + gitTag: + # TODO: make this mandatory and validate that it is in a release* branch and looks like + # 'release-\d+.\d+ or something like that. + # For now we don't do it so that we can test. + description: 'Git tag at which to sync for deploy and release' + type: string + +env: + SHARED_MVN_ARGS: '--no-transfer-progress --show-version --batch-mode' + RELEASE_FOLDER: 'target/release_files' + +jobs: + publish: + runs-on: ubuntu-latest + environment: release-env + permissions: + contents: read + packages: write + + steps: + + - name: Checkout repo files + uses: actions/checkout@v4.1.7 + with: + lfs: true + + - name: Set up JDK + uses: actions/setup-java@v4.2.2 + with: + java-version: '8' # The custom Taglets for javadoc (tools/build) are still Java 8. They need updating to use a different JDK version. + distribution: 'temurin' + server-id: icu4j-maven-repo # Value of the distributionManagement/repository/id field of the pom.xml + server-username: MAVEN_USERNAME # env variable for username in deploy + server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy + gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import + gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase + settings-path: ${{ github.workspace }} # location for the settings.xml file + + # TODO: enable tests? We don't want to release until we are 100% sure everything works. + - name: Build all of ICU + run: | + # Really important to do this first because we need `tools/build` for the javadoc applets + mvn install --file icu4j/tools/build \ + ${SHARED_MVN_ARGS} \ + -DskipTests -DskipITs + + - name: Build and deploy to Maven Central + run: | + mvn deploy --file icu4j \ + ${SHARED_MVN_ARGS} \ + --settings $GITHUB_WORKSPACE/settings.xml \ + --errors --fail-at-end -DdeployAtEnd=true \ + -DskipTests -DskipITs \ + -P with_sources,with_javadoc,with_signature + env: + MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} + + # These are files that will end in the "Release" section of the GitHub repo. + # So the jar files published in GitHub are binary identical to the ones in Maven Central. + - name: Prepare release folder + run: | + pushd icu4j + ICU_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + # Copy the artifacts (with sources and javdoc .jar files) to the release folder + mvn dependency:copy \ + ${SHARED_MVN_ARGS} \ + -DskipTests -DskipITs \ + -Drelease.directory=${RELEASE_FOLDER} \ + -P release_files + # Build the full javadoc to be posted on the public site + mvn site \ + ${SHARED_MVN_ARGS} \ + -DskipITs -DskipTests \ + -P with_full_javadoc + jar -Mcf ${RELEASE_FOLDER}/icu4j-${ICU_VERSION}-fulljavadoc.jar \ + -C target/site/apidocs/ . + # Create the file with MD5 checksums + pushd ${RELEASE_FOLDER} + md5sum *.jar > icu4j-${ICU_VERSION}.md5 + popd # out of $RELEASE_FOLDER + popd # out of icu4j + + # TODO: add them to the GitHub "Release" page automatically + - name: Upload build results + uses: actions/upload-artifact@v4.3.6 + with: + path: ./icu4j/${{ env.RELEASE_FOLDER }}/* + retention-days: 3 # TBD if we want to keep them longer + overwrite: true + diff --git a/.gitignore b/.gitignore index 2663b13e8746..503e3e8135fb 100644 --- a/.gitignore +++ b/.gitignore @@ -80,6 +80,7 @@ pkgdata.inc pkgdataMakefile rules.mk .DS_Store +.flattened-pom.xml !icu4c/source/samples/csdet/Makefile diff --git a/icu4j/demos/pom.xml b/icu4j/demos/pom.xml index b9cd3f50b1f0..2baf924b834a 100644 --- a/icu4j/demos/pom.xml +++ b/icu4j/demos/pom.xml @@ -37,13 +37,6 @@ - - maven-deploy-plugin - - - true - - org.codehaus.mojo exec-maven-plugin diff --git a/icu4j/main/charset/pom.xml b/icu4j/main/charset/pom.xml index 111568fcfc53..c15de1241a73 100644 --- a/icu4j/main/charset/pom.xml +++ b/icu4j/main/charset/pom.xml @@ -14,6 +14,7 @@ icu4j-charset icu4j-charset is a supplemental library for icu4j, implementing Java Charset SPI. + ${proj.url} ${project.basedir}/../.. @@ -70,6 +71,17 @@ + + org.codehaus.mojo + flatten-maven-plugin + + + maven-deploy-plugin + + + false + + diff --git a/icu4j/main/collate/pom.xml b/icu4j/main/collate/pom.xml index 2fb65f866eed..9b0bcdd2b926 100644 --- a/icu4j/main/collate/pom.xml +++ b/icu4j/main/collate/pom.xml @@ -67,16 +67,4 @@ - - - - maven-deploy-plugin - - - true - - - - - diff --git a/icu4j/main/common_tests/pom.xml b/icu4j/main/common_tests/pom.xml index d27fe3676ad3..381b36f331db 100644 --- a/icu4j/main/common_tests/pom.xml +++ b/icu4j/main/common_tests/pom.xml @@ -103,13 +103,6 @@ - - maven-deploy-plugin - - - true - - diff --git a/icu4j/main/core/pom.xml b/icu4j/main/core/pom.xml index f988f09ef53f..09a223de01ea 100644 --- a/icu4j/main/core/pom.xml +++ b/icu4j/main/core/pom.xml @@ -90,13 +90,6 @@ - - maven-deploy-plugin - - - true - - diff --git a/icu4j/main/currdata/pom.xml b/icu4j/main/currdata/pom.xml index fea06b21f91b..7eadaeeb2feb 100644 --- a/icu4j/main/currdata/pom.xml +++ b/icu4j/main/currdata/pom.xml @@ -27,16 +27,4 @@ - - - - maven-deploy-plugin - - - true - - - - - diff --git a/icu4j/main/framework/pom.xml b/icu4j/main/framework/pom.xml index ed3861dc0ccf..8873acd95b97 100644 --- a/icu4j/main/framework/pom.xml +++ b/icu4j/main/framework/pom.xml @@ -47,13 +47,6 @@ - - maven-deploy-plugin - - - true - - diff --git a/icu4j/main/icu4j/pom.xml b/icu4j/main/icu4j/pom.xml index b845c63e1c39..0ef34246cc29 100644 --- a/icu4j/main/icu4j/pom.xml +++ b/icu4j/main/icu4j/pom.xml @@ -16,6 +16,7 @@ icu4j International Components for Unicode for Java (ICU4J) is a mature, widely used Java library providing Unicode and Globalization support + ${proj.url} ${project.basedir}/../.. @@ -114,6 +115,17 @@ + + org.codehaus.mojo + flatten-maven-plugin + + + maven-deploy-plugin + + + false + + diff --git a/icu4j/main/langdata/pom.xml b/icu4j/main/langdata/pom.xml index 3a321614dba7..f90a598c44d8 100644 --- a/icu4j/main/langdata/pom.xml +++ b/icu4j/main/langdata/pom.xml @@ -27,16 +27,4 @@ - - - - maven-deploy-plugin - - - true - - - - - diff --git a/icu4j/main/localespi/pom.xml b/icu4j/main/localespi/pom.xml index ee0026593f6a..4b28593e1636 100644 --- a/icu4j/main/localespi/pom.xml +++ b/icu4j/main/localespi/pom.xml @@ -14,6 +14,7 @@ icu4j-localespi icu4j-localespi is a supplemental library for icu4j, implementing Java Locale SPI. + ${proj.url} JDK locale service provider @@ -185,6 +186,19 @@ + + org.codehaus.mojo + flatten-maven-plugin + + + + maven-deploy-plugin + + + false + + + diff --git a/icu4j/main/regiondata/pom.xml b/icu4j/main/regiondata/pom.xml index 5673465eb4ac..b1d689827e95 100644 --- a/icu4j/main/regiondata/pom.xml +++ b/icu4j/main/regiondata/pom.xml @@ -27,16 +27,4 @@ - - - - maven-deploy-plugin - - - true - - - - - diff --git a/icu4j/main/translit/pom.xml b/icu4j/main/translit/pom.xml index 53fc490c6b4d..b8f90ee778a8 100644 --- a/icu4j/main/translit/pom.xml +++ b/icu4j/main/translit/pom.xml @@ -62,16 +62,4 @@ - - - - maven-deploy-plugin - - - true - - - - - diff --git a/icu4j/perf-tests/pom.xml b/icu4j/perf-tests/pom.xml index aceb57d559cd..cdb7fd4c50af 100644 --- a/icu4j/perf-tests/pom.xml +++ b/icu4j/perf-tests/pom.xml @@ -41,7 +41,7 @@ commons-cli commons-cli - 1.7.0 + ${commons-cli.version} @@ -63,13 +63,6 @@ - - maven-deploy-plugin - - - true - - diff --git a/icu4j/pom.xml b/icu4j/pom.xml index 9849bfbd6dcf..c17100bc65f7 100644 --- a/icu4j/pom.xml +++ b/icu4j/pom.xml @@ -15,7 +15,7 @@ International Components for Unicode for Java (ICU4J) is a mature, widely used Java library providing Unicode and Globalization support. This is the base artifact with common settings, not intended to use directly. - https://icu.unicode.org/ + ${proj.url} 1995 @@ -56,12 +56,17 @@ ${maven-central-repo-url}/service/local/staging/deploy/maven2 ${maven-central-repo-url}/content/repositories/snapshots + + ${project.build.directory}/release_directory + 4.13.2 1.1.1 - 2.10.1 + 2.11.0 + 1.9.0 International Components for Unicode for Java ${project.artifactId} + https://icu.unicode.org/ 76 @@ -166,12 +171,12 @@ - icu4j-releases + icu4j-maven-repo ICU4J Central Repository ${maven-central-releases-repo-url} - icu4j-snapshots + icu4j-maven-repo ICU4J Central Development Repository ${maven-central-snapshots-repo-url} @@ -182,7 +187,7 @@ maven-clean-plugin - 3.3.1 + 3.4.0 maven-resources-plugin @@ -190,7 +195,7 @@ maven-compiler-plugin - 3.11.0 + 3.13.0 @@ -201,7 +206,7 @@ maven-surefire-plugin - 3.1.2 + 3.4.0 -J-Djcitesourcepath=${icu4j.api.doc.root.dir}/samples/src/main/java${path.separator}${icu4j.api.doc.root.dir}/demos/src/main/java${path.separator}${icu4j.api.doc.root.dir}/main/core/src/main/java @@ -400,7 +431,7 @@ maven-jar-plugin - 3.3.0 + 3.4.2 @@ -432,7 +463,7 @@ org.codehaus.mojo exec-maven-plugin - 3.1.0 + 3.4.1 @@ -685,6 +716,77 @@ + + release_files + + + + maven-dependency-plugin + + ${release.directory} + true + true + + + + com.ibm.icu + icu4j + ${project.version} + + + com.ibm.icu + icu4j + ${project.version} + sources + + + com.ibm.icu + icu4j + ${project.version} + javadoc + + + + com.ibm.icu + icu4j-charset + ${project.version} + + + com.ibm.icu + icu4j-charset + ${project.version} + sources + + + com.ibm.icu + icu4j-charset + ${project.version} + javadoc + + + + com.ibm.icu + icu4j-localespi + ${project.version} + + + com.ibm.icu + icu4j-localespi + ${project.version} + sources + + + com.ibm.icu + icu4j-localespi + ${project.version} + javadoc + + + + + + + diff --git a/icu4j/samples/pom.xml b/icu4j/samples/pom.xml index 98fb504829fe..6de776d04d04 100644 --- a/icu4j/samples/pom.xml +++ b/icu4j/samples/pom.xml @@ -32,13 +32,6 @@ - - maven-deploy-plugin - - - true - - org.codehaus.mojo exec-maven-plugin diff --git a/icu4j/tools/build/pom.xml b/icu4j/tools/build/pom.xml index 9f8498ef207b..c1975788ec82 100644 --- a/icu4j/tools/build/pom.xml +++ b/icu4j/tools/build/pom.xml @@ -28,16 +28,4 @@ - - - - maven-deploy-plugin - - - true - - - - - diff --git a/icu4j/tools/misc/pom.xml b/icu4j/tools/misc/pom.xml index 998ee0a17567..0e4ffae4ae88 100644 --- a/icu4j/tools/misc/pom.xml +++ b/icu4j/tools/misc/pom.xml @@ -32,7 +32,7 @@ commons-cli commons-cli - 1.7.0 + ${commons-cli.version} @@ -48,13 +48,6 @@ - - maven-deploy-plugin - - - true - -