| name: Publish snapshot icu4j.jar to GH Maven |
| on: |
| release: |
| types: [created] |
| workflow_dispatch: |
| # To trigger the Env Test workflow manually, follow the instructions in |
| # https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow |
| |
| env: |
| SHARED_MVN_ARGS: '--show-version' |
| |
| permissions: |
| contents: read |
| |
| jobs: |
| publish: |
| runs-on: ubuntu-22.04 # Updated in BRS |
| permissions: |
| packages: write |
| outputs: |
| version: ${{ steps.mvn-proj-version.outputs.version }} |
| version-type: ${{ steps.mvn-proj-version-type.outputs.version-type }} |
| steps: |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| - uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0 |
| with: |
| distribution: 'temurin' |
| java-version: '11' |
| - name: Store Maven project version |
| id: mvn-proj-version |
| run: | |
| cd icu4j |
| version="`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`" |
| echo "version=$version" # debug/info logging for our own purposes, before sending to Github |
| echo "version=$version" >> "$GITHUB_OUTPUT" |
| # Set version-type=snapshot for tags that contain SNAPSHOT, |
| # as well as for unicode-org-internal artifacts with a dash like `icu4j-for-cldr`. |
| - name: Assess Maven version release/snapshot |
| id: mvn-proj-version-type |
| run: | |
| if echo "${{ steps.mvn-proj-version.outputs.version }}" | grep -E "\-|SNAPSHOT" |
| then echo "version-type=snapshot" >> "$GITHUB_OUTPUT" |
| else echo "version-type=release" >> "$GITHUB_OUTPUT" |
| fi |
| - name: Prevent manual deployment attempts of full release |
| if: github.event_name == 'workflow_dispatch' && steps.mvn-proj-version-type.outputs.version-type == 'release' |
| run: | |
| echo "Manual deployments of publishing artifacts should only be attempted for snapshot versions" |
| exit 1; |
| - name: Build artifacts (icu4j) |
| run: | |
| cd icu4j |
| mvn ${SHARED_MVN_ARGS} clean install -DskipTests -DskipIT -P with_sources |
| # For snapshot versions, publish icu4j |
| - name: Deploy to Github (snapshot version) |
| if: steps.mvn-proj-version-type.outputs.version-type == 'snapshot' |
| run: | |
| echo Github Ref ${GITHUB_REF} @ ${GITHUB_SHA}; |
| cd icu4j |
| mvn deploy ${SHARED_MVN_ARGS} \ |
| -pl :icu4j,:icu4j-root \ |
| -DaltDeploymentRepository=github::https://maven.pkg.github.com/${GITHUB_REPOSITORY} \ |
| -P with_sources |
| env: |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| # Note: can use 0.0.0-${GITHUB_SHA} as the version for hash-based. |
| # i.e. build on every commit |