Repository navigation
Dry-run for patch release of release/1.48._ branch [release-20260803T173219Z-8212-10040] #49
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: Validated Release | |
| run-name: "${{ inputs.dry_run && 'Dry-run for ' || 'Perform ' }}${{ inputs.release_type }} release of ${{ github.ref_name }} branch [${{ inputs.request_id || 'manual' }}]" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release_type: | |
| type: choice | |
| description: The release type | |
| options: | |
| - "major" | |
| - "minor" | |
| - "patch" | |
| - "retag" | |
| default: "minor" | |
| dry_run: | |
| description: Perform the release dry-run | |
| required: true | |
| type: boolean | |
| default: true | |
| skip_tests: | |
| description: Skip pre-release tests (emergency releases only) | |
| required: false | |
| type: boolean | |
| default: false | |
| request_id: | |
| description: Unique correlation ID supplied by utils/release.sh | |
| required: false | |
| type: string | |
| default: "" | |
| source_sha: | |
| description: Exact source SHA expected by utils/release.sh | |
| required: false | |
| type: string | |
| default: "" | |
| permissions: | |
| contents: write | |
| actions: read | |
| jobs: | |
| validate-inputs: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| release_version: ${{ steps.compute-version.outputs.release_version }} | |
| next_version: ${{ steps.compute-version.outputs.next_version }} | |
| release_branch: ${{ steps.compute-version.outputs.release_branch }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.sha }} | |
| - name: Setup Java | |
| uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5.6.0 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '21' | |
| - name: Validate branch and compute versions | |
| id: compute-version | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| BRANCH="${GITHUB_REF_NAME}" | |
| TYPE="${{ inputs.release_type }}" | |
| EXPECTED_SOURCE_SHA="${{ inputs.source_sha }}" | |
| echo "Current branch: $BRANCH" | |
| echo "Release type: $TYPE" | |
| if [ -n "$EXPECTED_SOURCE_SHA" ] && [ "$GITHUB_SHA" != "$EXPECTED_SOURCE_SHA" ]; then | |
| echo "::error::Dispatched SHA $GITHUB_SHA differs from requested SHA $EXPECTED_SOURCE_SHA" | |
| exit 1 | |
| fi | |
| # Branch validation | |
| if [ "$TYPE" == "patch" ] || [ "$TYPE" == "retag" ]; then | |
| if [[ ! $BRANCH =~ ^release/[0-9]+\.[0-9]+\._$ ]]; then | |
| echo "::error::${TYPE^} can only be performed from 'release/*' branches (format: release/X.Y._)" | |
| exit 1 | |
| fi | |
| else | |
| if [ "$BRANCH" != "main" ]; then | |
| echo "::error::Major or minor releases can only be performed from 'main' branch" | |
| exit 1 | |
| fi | |
| fi | |
| # Get current version | |
| BASE=$(./gradlew printVersion -Psnapshot=false | grep 'Version:' | cut -f2 -d' ') | |
| echo "Current version: $BASE" | |
| # Parse version components | |
| if [[ $BASE =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then | |
| MAJOR="${BASH_REMATCH[1]}" | |
| MINOR="${BASH_REMATCH[2]}" | |
| PATCH="${BASH_REMATCH[3]}" | |
| else | |
| echo "::error::Invalid version format: $BASE (expected X.Y.Z)" | |
| exit 1 | |
| fi | |
| # Check if this version is already released | |
| if git rev-parse "v_${BASE}" >/dev/null 2>&1; then | |
| ALREADY_RELEASED=true | |
| echo "Version $BASE is already released" | |
| else | |
| ALREADY_RELEASED=false | |
| echo "Version $BASE is not yet released" | |
| fi | |
| # A release branch is initially created at the tagged X.Y.0 minor | |
| # release. Its first patch legitimately starts from that tag and | |
| # creates X.Y.1. A tagged patch version greater than zero instead | |
| # means the previous post-release bump PR never merged. | |
| FIRST_PATCH=false | |
| if [ "$TYPE" == "patch" ] && [ "$ALREADY_RELEASED" == "true" ] && | |
| [ "$PATCH" -eq 0 ]; then | |
| if [ "$(git cat-file -t "refs/tags/v_${BASE}" 2>/dev/null)" != "tag" ]; then | |
| echo "::error::First patch base v_${BASE} must be an annotated tag" | |
| exit 1 | |
| fi | |
| if ! git merge-base --is-ancestor "v_${BASE}^{commit}" "$GITHUB_SHA"; then | |
| echo "::error::First patch base tag v_${BASE} is not reachable from $GITHUB_SHA" | |
| exit 1 | |
| fi | |
| FIRST_PATCH=true | |
| elif [ "$TYPE" != "retag" ] && [ "$ALREADY_RELEASED" == "true" ]; then | |
| echo "::error::${BRANCH} is stuck at version ${BASE}, which is already tagged (v_${BASE})." | |
| echo "::error::The automated post-release version-bump PR for this branch was never merged." | |
| STUCK_PR=$(gh pr list --state open --base "$BRANCH" --json headRefName,url \ | |
| --jq '[.[] | select(.headRefName | startswith("automated/bump-"))][0].url' 2>/dev/null || true) | |
| if [ -n "$STUCK_PR" ]; then | |
| echo "::error::Merge the pending bump PR first, then retry: $STUCK_PR" | |
| else | |
| echo "::error::No pending bump PR was found. Bump ${BRANCH}'s version manually and merge it before retrying the release." | |
| fi | |
| exit 1 | |
| fi | |
| # Compute release version based on type | |
| if [ "$TYPE" == "MAJOR" ] || [ "$TYPE" == "major" ]; then | |
| RELEASE_VERSION="$BASE" | |
| elif [ "$TYPE" == "MINOR" ] || [ "$TYPE" == "minor" ]; then | |
| RELEASE_VERSION="$BASE" | |
| elif [ "$TYPE" == "retag" ]; then | |
| # Retag reuses the current version; tag must already exist | |
| RELEASE_VERSION="$BASE" | |
| if ! git rev-parse "v_${RELEASE_VERSION}" >/dev/null 2>&1; then | |
| echo "::error::Tag v_${RELEASE_VERSION} does not exist. Use a normal release to create a new tag." | |
| exit 1 | |
| fi | |
| # Refuse if the GitHub release is already public | |
| IS_DRAFT=$(gh release view "v_${RELEASE_VERSION}" --json isDraft --jq '.isDraft' 2>/dev/null || echo "not-found") | |
| if [ "$IS_DRAFT" == "false" ]; then | |
| echo "::error::GitHub release v_${RELEASE_VERSION} is already public. Retagging is not allowed." | |
| exit 1 | |
| fi | |
| else | |
| # The first patch starts from the already-tagged minor version and | |
| # releases the next patch. Subsequent patch runs start from the | |
| # untagged development version left by the previous bump PR. | |
| if [ "$FIRST_PATCH" == "true" ]; then | |
| RELEASE_VERSION="$MAJOR.$MINOR.$((PATCH + 1))" | |
| else | |
| RELEASE_VERSION="$BASE" | |
| fi | |
| fi | |
| # Compute release branch | |
| RELEASE_BRANCH="release/${RELEASE_VERSION%.*}._" | |
| # Check if tag already exists (skip for retag, which requires it to exist) | |
| if [ "$TYPE" != "retag" ] && git rev-parse "v_${RELEASE_VERSION}" >/dev/null 2>&1; then | |
| echo "::error::Tag v_${RELEASE_VERSION} already exists" | |
| exit 1 | |
| fi | |
| echo "Release version: $RELEASE_VERSION" | |
| echo "Release branch: $RELEASE_BRANCH" | |
| # Set outputs | |
| echo "release_version=$RELEASE_VERSION" >> $GITHUB_OUTPUT | |
| echo "release_branch=$RELEASE_BRANCH" >> $GITHUB_OUTPUT | |
| # Output summary | |
| echo "## Release Validation" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Release Type**: $TYPE" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Branch**: $BRANCH" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Release Version**: $RELEASE_VERSION" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Release Branch**: $RELEASE_BRANCH" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Tag**: v_$RELEASE_VERSION" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Dry Run**: ${{ inputs.dry_run }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Skip Tests**: ${{ inputs.skip_tests }}" >> $GITHUB_STEP_SUMMARY | |
| pre-release-tests: | |
| needs: validate-inputs | |
| if: ${{ inputs.dry_run != true && inputs.skip_tests != true && inputs.release_type != 'retag' }} | |
| uses: ./.github/workflows/test_workflow.yml | |
| with: | |
| configuration: '["debug", "asan"]' | |
| create-release: | |
| needs: [validate-inputs, pre-release-tests] | |
| if: always() && needs.validate-inputs.result == 'success' && (needs.pre-release-tests.result == 'success' || needs.pre-release-tests.result == 'skipped') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| checks: read | |
| contents: write | |
| pull-requests: write | |
| statuses: read | |
| id-token: write | |
| outputs: | |
| base_branch: ${{ steps.create-release.outputs.base_branch }} | |
| source_sha: ${{ steps.create-release.outputs.source_sha }} | |
| release_version: ${{ steps.create-release.outputs.release_version }} | |
| next_version: ${{ steps.create-release.outputs.next_version }} | |
| release_branch: ${{ steps.create-release.outputs.release_branch }} | |
| bump_branch: ${{ steps.create-release.outputs.bump_branch }} | |
| bump_head_sha: ${{ steps.create-release.outputs.bump_head_sha }} | |
| bump_pr_number: ${{ steps.create-release.outputs.bump_pr_number }} | |
| bump_pr_url: ${{ steps.create-release.outputs.bump_pr_url }} | |
| steps: | |
| - name: Check test results | |
| if: ${{ inputs.dry_run != true && inputs.skip_tests != true && inputs.release_type != 'retag' && needs.pre-release-tests.result != 'success' }} | |
| run: | | |
| echo "::error::Pre-release tests failed. Cannot proceed with release." | |
| exit 1 | |
| - name: Setup SSH agent | |
| run: | | |
| eval $(ssh-agent -s) | |
| echo "${{ secrets.SSH_PUSH_SECRET }}" | ssh-add - | |
| mkdir -p ~/.ssh | |
| ssh-keyscan github.com >> ~/.ssh/known_hosts | |
| echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $GITHUB_ENV | |
| echo "SSH_AGENT_PID=$SSH_AGENT_PID" >> $GITHUB_ENV | |
| - name: Checkout repository | |
| run: git clone git@github.com:$GITHUB_REPOSITORY.git java-profiler | |
| - name: Configure git | |
| run: | | |
| cd java-profiler | |
| git config --global user.email "java-profiler@datadoghq.com" | |
| git config --global user.name "Datadog Java Profiler" | |
| git checkout -B "$GITHUB_REF_NAME" "$GITHUB_SHA" | |
| - name: Setup Java | |
| uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5.6.0 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '21' | |
| - name: Federate release bump label token | |
| id: bump-label-token | |
| if: ${{ inputs.dry_run != true && inputs.release_type != 'retag' }} | |
| uses: DataDog/dd-octo-sts-action@96a25462dbcb10ebf0bfd6e2ccc917d2ab235b9a # v1.0.4 | |
| with: | |
| scope: DataDog/java-profiler | |
| policy: self.release-bump.label-pr | |
| - name: Create release | |
| id: create-release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| BUMP_LABEL_TOKEN: ${{ steps.bump-label-token.outputs.token }} | |
| run: | | |
| cd java-profiler | |
| if [ "${{ inputs.dry_run }}" == "true" ]; then | |
| DRY_RUN="--dry-run" | |
| else | |
| DRY_RUN="" | |
| fi | |
| TYPE="${{ inputs.release_type }}" | |
| ./.github/scripts/release.sh ${TYPE^^} $DRY_RUN | |
| - name: Wait for exact bump approval and selected CI, then merge | |
| if: ${{ inputs.dry_run != true && inputs.release_type != 'retag' }} | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| cd java-profiler | |
| ./.github/scripts/wait-release-bump.sh \ | |
| --repo "$GITHUB_REPOSITORY" \ | |
| --pr-number '${{ steps.create-release.outputs.bump_pr_number }}' \ | |
| --expected-head-sha '${{ steps.create-release.outputs.bump_head_sha }}' \ | |
| --check release-bump-ci | |
| - name: Output Release Summary | |
| if: ${{ inputs.dry_run != true }} | |
| run: | | |
| echo "## ✅ Release Created Successfully" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Release Details" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Tag**: v_${{ needs.validate-inputs.outputs.release_version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Branch**: ${{ needs.validate-inputs.outputs.release_branch }}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [ "${{ inputs.release_type }}" != "retag" ]; then | |
| echo "### Version Bump" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Automatically merged PR**: ${{ steps.create-release.outputs.bump_pr_url }}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| echo "### Next Steps (Automatic)" >> $GITHUB_STEP_SUMMARY | |
| echo "1. 🔨 GitLab pipeline will build multi-platform artifacts" >> $GITHUB_STEP_SUMMARY | |
| echo "2. 📦 GitLab will publish to Maven Central" >> $GITHUB_STEP_SUMMARY | |
| echo "3. 🚀 GitHub workflows will create release when Maven artifacts are available" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Monitoring" >> $GITHUB_STEP_SUMMARY | |
| echo "- GitHub Releases: ${{ github.server_url }}/${{ github.repository }}/releases" >> $GITHUB_STEP_SUMMARY | |
| echo "- Maven Central: https://repo1.maven.org/maven2/com/datadoghq/ddprof/${{ needs.validate-inputs.outputs.release_version }}/" >> $GITHUB_STEP_SUMMARY | |
| - name: Output Dry-Run Summary | |
| if: ${{ inputs.dry_run == true }} | |
| run: | | |
| echo "## 🔍 Dry-Run Complete" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "This was a dry-run. No changes were made." >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Would have created:" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Tag**: v_${{ needs.validate-inputs.outputs.release_version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Branch**: ${{ needs.validate-inputs.outputs.release_branch }}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "To perform the actual release, run this workflow again with **dry_run = false**" >> $GITHUB_STEP_SUMMARY |