|
| 1 | +name: Create Release Branch and Pin System-Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v[0-9]+.[0-9]+.0' # Trigger on minor release tags (e.g. v1.54.0) |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + tag: |
| 10 | + description: 'The minor release tag (e.g. v1.54.0)' |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + |
| 14 | +jobs: |
| 15 | + create-release-branch: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + permissions: |
| 18 | + contents: read |
| 19 | + id-token: write # Required for OIDC token federation |
| 20 | + steps: |
| 21 | + - uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3 |
| 22 | + id: octo-sts |
| 23 | + with: |
| 24 | + scope: DataDog/dd-trace-java |
| 25 | + policy: self.create-release-branch.push |
| 26 | + |
| 27 | + - name: Determine tag |
| 28 | + id: determine-tag |
| 29 | + run: | |
| 30 | + if [ -n "${{ github.event.inputs.tag }}" ]; then |
| 31 | + TAG=${{ github.event.inputs.tag }} |
| 32 | + else |
| 33 | + TAG=${GITHUB_REF#refs/tags/} |
| 34 | + fi |
| 35 | + echo "tag=${TAG}" >> "$GITHUB_OUTPUT" |
| 36 | + echo "Processing release tag: ${TAG}" |
| 37 | +
|
| 38 | + - name: Validate tag format |
| 39 | + run: | |
| 40 | + TAG=${{ steps.determine-tag.outputs.tag }} |
| 41 | + if ! [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.0$ ]]; then |
| 42 | + echo "Error: Tag $TAG is not a valid minor release tag (expected format: vX.Y.0)" |
| 43 | + exit 1 |
| 44 | + fi |
| 45 | + echo "Tag format is valid" |
| 46 | +
|
| 47 | + - name: Define branch name from tag |
| 48 | + id: define-branch |
| 49 | + run: | |
| 50 | + TAG=${{ steps.determine-tag.outputs.tag }} |
| 51 | + BRANCH=$(echo "$TAG" | sed -E 's/^(v[0-9]+\.[0-9]+)\.0$/release\/\1.x/') |
| 52 | + echo "branch=${BRANCH}" >> "$GITHUB_OUTPUT" |
| 53 | + echo "Target branch: ${BRANCH}" |
| 54 | +
|
| 55 | + - name: Checkout dd-trace-java |
| 56 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0 |
| 57 | + |
| 58 | + - name: Check if branch already exists |
| 59 | + id: check-branch |
| 60 | + run: | |
| 61 | + BRANCH=${{ steps.define-branch.outputs.branch }} |
| 62 | + if git ls-remote --heads origin "$BRANCH" | grep -q "$BRANCH"; then |
| 63 | + echo "exists=true" >> "$GITHUB_OUTPUT" |
| 64 | + echo "Branch $BRANCH already exists, skipping following steps" |
| 65 | + else |
| 66 | + echo "exists=false" >> "$GITHUB_OUTPUT" |
| 67 | + echo "Branch $BRANCH does not exist, proceeding with following steps" |
| 68 | + fi |
| 69 | +
|
| 70 | + - name: Checkout system-tests to get latest SHA |
| 71 | + if: steps.check-branch.outputs.exists == 'false' |
| 72 | + id: system-test-ref |
| 73 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0 |
| 74 | + with: |
| 75 | + repository: "DataDog/system-tests" |
| 76 | + path: system-tests |
| 77 | + ref: main |
| 78 | + |
| 79 | + - name: Update reference 1/2 in run-system-tests.yaml |
| 80 | + if: steps.check-branch.outputs.exists == 'false' |
| 81 | + run: .github/scripts/update_system_test_reference.sh |
| 82 | + env: |
| 83 | + TARGET: ".github/workflows/run-system-tests.yaml" |
| 84 | + PATTERN: '(\s*system-tests\.yml@)(\S+)(\s+# system tests.*)' |
| 85 | + REF: ${{ steps.system-test-ref.outputs.commit }} |
| 86 | + |
| 87 | + - name: Update reference 2/2 in run-system-tests.yaml |
| 88 | + if: steps.check-branch.outputs.exists == 'false' |
| 89 | + run: .github/scripts/update_system_test_reference.sh |
| 90 | + env: |
| 91 | + TARGET: ".github/workflows/run-system-tests.yaml" |
| 92 | + PATTERN: '(\s*ref: )(\S+)(\s+# system tests.*)' |
| 93 | + REF: ${{ steps.system-test-ref.outputs.commit }} |
| 94 | + |
| 95 | + - name: Commit changes |
| 96 | + if: steps.check-branch.outputs.exists == 'false' |
| 97 | + id: create-commit |
| 98 | + run: | |
| 99 | + BRANCH=${{ steps.define-branch.outputs.branch }} |
| 100 | + SHA=${{ steps.system-test-ref.outputs.commit }} |
| 101 | + |
| 102 | + git config user.name "github-actions[bot]" |
| 103 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 104 | + git commit -m "chore: Pin system-tests for release branch" .github/workflows/run-system-tests.yaml |
| 105 | + echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT |
| 106 | + |
| 107 | + - name: Push changes |
| 108 | + if: steps.check-branch.outputs.exists == 'false' |
| 109 | + uses: DataDog/commit-headless@5a0f3876e0fbdd3a86b3e008acf4ec562db59eee # action/v2.0.1 |
| 110 | + with: |
| 111 | + token: "${{ steps.octo-sts.outputs.token }}" |
| 112 | + branch: "${{ steps.define-branch.outputs.branch }}" |
| 113 | + branch-from: "${{ github.sha }}" |
| 114 | + command: push |
| 115 | + commits: "${{ steps.create-commit.outputs.commit }}" |
0 commit comments