11# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
22# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
33
4- name : Publish to Nexus Sonatype OSS
4+ name : Release - ICU4J publish to Maven Central
55
66# For this to run you should define the follwing GitHub Secrets in the proper Environment.
77# In Settings -- Environments -- release_env -- Environment secrets:
2121 # https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
2222 workflow_dispatch :
2323 inputs :
24- gitTag :
25- # TODO: make this mandatory and validate that it is in a release* branch and looks like
26- # 'release-\d+.\d+ or something like that.
27- # For now we don't do it so that we can test.
28- description : ' Git tag at which to sync for deploy and release'
24+ runTests :
25+ description : ' Run the tests.'
26+ type : boolean
27+ default : true
28+ deployToMaven :
29+ description : ' Deploy to Maven Central (using Sonatype OSSRH)'
30+ type : boolean
31+ default : false
32+ gitReleaseTag :
33+ description : ' Release tag to upload to. Must start with "release-"'
2934 type : string
3035
3136env :
3237 SHARED_MVN_ARGS : ' --no-transfer-progress --show-version --batch-mode'
33- RELEASE_FOLDER : ' target/release_files '
38+ RELEASE_FOLDER : ' ${{ github.workspace }}/releaseDist '
3439
3540jobs :
3641 publish :
3742 runs-on : ubuntu-latest
3843 environment : release-env
44+
3945 permissions :
40- contents : read
41- packages : write
46+ contents : write # So that we can upload to release
4247
4348 steps :
4449
5964 gpg-passphrase : MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
6065 settings-path : ${{ github.workspace }} # location for the settings.xml file
6166
62- # TODO: enable tests? We don't want to release until we are 100% sure everything works.
63- - name : Build all of ICU
67+ - name : Run tests
68+ if : ${{ inputs.runTests }}
69+ run : mvn install --file icu4j ${SHARED_MVN_ARGS} --errors --fail-at-end
70+
71+ - name : Build javadoc taglets
6472 run : |
6573 # Really important to do this first because we need `tools/build` for the javadoc applets
6674 mvn install --file icu4j/tools/build \
6977
7078 - name : Build and deploy to Maven Central
7179 run : |
80+ if [ "${{ inputs.deployToMaven }}" != "true" ]; then
81+ echo Deploy to local folder
82+ # Run the deploy, but do it to a local folder, not to Sonatype / Maven Central
83+ export MAVEN_LOCAL='-DaltDeploymentRepository=tempid::file:./local-deploy-folder'
84+ else
85+ echo Deploy to Maven Central using Sonatype OSSRH
86+ fi
7287 mvn deploy --file icu4j \
73- ${SHARED_MVN_ARGS} \
88+ ${SHARED_MVN_ARGS} ${MAVEN_LOCAL} \
7489 --settings $GITHUB_WORKSPACE/settings.xml \
7590 --errors --fail-at-end -DdeployAtEnd=true \
7691 -DskipTests -DskipITs \
@@ -97,19 +112,22 @@ jobs:
97112 ${SHARED_MVN_ARGS} \
98113 -DskipITs -DskipTests \
99114 -P with_full_javadoc
115+ # Archive the full doc in a jar. Should also be posted to the web as official doc.
100116 jar -Mcf ${RELEASE_FOLDER}/icu4j-${ICU_VERSION}-fulljavadoc.jar \
101117 -C target/site/apidocs/ .
102- # Create the file with MD5 checksums
103- pushd ${RELEASE_FOLDER}
104- md5sum *.jar > icu4j-${ICU_VERSION}.md5
105- popd # out of $RELEASE_FOLDER
106118 popd # out of icu4j
107119
108- # TODO: add them to the GitHub "Release" page automatically
109120 - name : Upload build results
110121111122 with :
112- path : ./icu4j/${{ env.RELEASE_FOLDER }}/*
123+ name : icu4j-binaries
124+ path : ${{ env.RELEASE_FOLDER }}
113125 retention-days : 3 # TBD if we want to keep them longer
114126 overwrite : true
115127
128+ - name : Upload to release
129+ if : ${{ inputs.gitReleaseTag && startsWith(inputs.gitReleaseTag, 'release-') }}
130+ run : |
131+ gh release upload ${{ inputs.gitReleaseTag }} ${RELEASE_FOLDER}/* --clobber --repo=${{ github.repository }}
132+ env :
133+ GH_TOKEN : ${{ github.token }}
0 commit comments