test: update tool tests #86
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: publish | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version number (e.g. 2.0.8) - leave empty to use branch/tag name' | |
| required: false | |
| type: string | |
| default: '' | |
| publish_maven: | |
| description: 'Publish to Maven' | |
| required: false | |
| type: boolean | |
| default: true | |
| publish_javadoc: | |
| description: 'Publish JavaDoc to gh-pages branch' | |
| required: false | |
| type: boolean | |
| default: true | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # JavaDoc has not been published for a very long time. | |
| publish-javadoc: | |
| name: Publish Javadoc | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| # Only publish when semantic-release creates a release commit (starts with "chore(release):") | |
| if: (github.event_name == 'push' && startsWith(github.event.head_commit.message, 'chore(release):')) || (github.event_name == 'workflow_dispatch' && inputs.publish_javadoc) | |
| permissions: | |
| contents: write | |
| pages: write | |
| steps: | |
| # Checkout the main and gh-pages branches. Main is used to generate the Javadoc, gh-pages stores the output Javadoc. | |
| - name: Checkout main branch | |
| uses: actions/checkout@v5 | |
| with: | |
| path: main | |
| persist-credentials: true | |
| fetch-depth: 0 | |
| - name: Checkout gh-pages branch | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| path: gh-pages | |
| persist-credentials: true | |
| ref: gh-pages | |
| - name: Set up Java 11 | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: '11' | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| - name: Determine version | |
| id: version | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ inputs.version }}" ]; then | |
| echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT | |
| elif [ "${{ github.ref }}" = "refs/heads/main" ]; then | |
| # When on main branch, get the latest release tag from GitHub | |
| LATEST_TAG=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| "https://api.github.com/repos/${{ github.repository }}/releases/latest" | \ | |
| jq -r '.tag_name // empty') | |
| if [ -z "$LATEST_TAG" ]; then | |
| echo "Error: Could not fetch latest release tag from GitHub" | |
| exit 1 | |
| fi | |
| echo "version=$LATEST_TAG" >> $GITHUB_OUTPUT | |
| echo "Latest release version: $LATEST_TAG" | |
| else | |
| # For other branches, use the branch/tag name | |
| echo "version=${{ github.ref_name }}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Publish Javadocs | |
| env: | |
| GITHUB_REPO_SLUG: ${{ github.repository }} | |
| GITHUB_TAG: ${{ steps.version.outputs.version }} | |
| run: | | |
| main/build/publishJavadoc-gha.sh | |
| publish-maven-central: | |
| # Requires GPG_KEYNAME, GPG_PRIVATE_KEY, GPG_PASSPHRASE, CP_USERNAME, and CP_PASSWORD | |
| name: Publish to Maven Central | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| # Only publish when semantic-release creates a release commit (starts with "chore(release):") | |
| if: (github.event_name == 'push' && startsWith(github.event.head_commit.message, 'chore(release):')) || (github.event_name == 'workflow_dispatch' && inputs.publish_maven) | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Set up Java 11 | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: '11' | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| server-id: central | |
| server-username: CP_USERNAME | |
| server-password: CP_PASSWORD | |
| # Import GPG key into build agent's local keystore | |
| gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | |
| gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
| - name: Determine version | |
| id: version | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ inputs.version }}" ]; then | |
| echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT | |
| elif [ "${{ github.ref }}" = "refs/heads/main" ]; then | |
| # When on main branch, get the latest release tag from GitHub | |
| LATEST_TAG=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| "https://api.github.com/repos/${{ github.repository }}/releases/latest" | \ | |
| jq -r '.tag_name // empty') | |
| if [ -z "$LATEST_TAG" ]; then | |
| echo "Error: Could not fetch latest release tag from GitHub" | |
| exit 1 | |
| fi | |
| echo "version=$LATEST_TAG" >> $GITHUB_OUTPUT | |
| echo "Latest release version: $LATEST_TAG" | |
| else | |
| # For other branches, use the branch/tag name | |
| echo "version=${{ github.ref_name }}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Check if version exists in Maven Central | |
| id: check_version | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| echo "Checking if version $VERSION exists in Maven Central..." | |
| # Check if the main artifact exists in Maven Central | |
| HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \ | |
| "https://repo1.maven.org/maven2/com/ibm/cloud/continuous-delivery/${VERSION}/continuous-delivery-${VERSION}.pom") | |
| if [ "$HTTP_CODE" = "200" ]; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| echo "Version $VERSION already exists in Maven Central. Skipping deployment." | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| echo "Version $VERSION does not exist in Maven Central. Proceeding with deployment." | |
| fi | |
| - name: Set Maven version | |
| if: steps.check_version.outputs.exists == 'false' | |
| run: mvn versions:set -DnewVersion=${{ steps.version.outputs.version }} -DgenerateBackupPoms=false | |
| - name: Deploy to Maven Central | |
| if: steps.check_version.outputs.exists == 'false' | |
| env: | |
| # Required variables and secrets for publishing to Maven Central | |
| # GNU Privacy Guard variables | |
| GPG_KEYNAME: ${{ vars.GPG_KEYNAME }} | |
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
| # Central portal username and password | |
| CP_USERNAME: ${{ vars.CP_USERNAME }} | |
| CP_PASSWORD: ${{ secrets.CP_PASSWORD }} | |
| run: | | |
| mvn -B -ntp deploy --settings build/.github.settings.xml -DskipTests -P central |