Skip to content

Commit 702b753

Browse files
feat: [DevOps] Release notes automation (#390)
* release notes on docs repo * fix release_notes_automation.py * fix release_notes_automation.py * fix release_notes_automation.py forreal * run ci on release commit * Add missing workflows * feat: Release 1.6.0 (#12) * Update to version 1.6.0 * Reset release notes * Update to version 1.7.0-SNAPSHOT --------- Co-authored-by: SAP Cloud SDK Bot <[email protected]> * Revert "feat: Release 1.6.0 (#12)" This reverts commit 11b7737. * reset release notes * revert disable release --------- Co-authored-by: SAP Cloud SDK Bot <[email protected]>
1 parent 75a8683 commit 702b753

File tree

7 files changed

+333
-43
lines changed

7 files changed

+333
-43
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: "Await Workflow"
2+
description: "Waits until a workflow run completes."
3+
4+
inputs:
5+
run-id:
6+
description: "The id of the workflow run to wait for."
7+
required: true
8+
poll-interval:
9+
description: "The interval (in seconds) to poll for the workflow run status."
10+
required: false
11+
default: "60"
12+
commit-status:
13+
description: "The commit status message. Leave empty to not create a commit status."
14+
required: false
15+
16+
outputs:
17+
succeeded:
18+
description: "Whether the triggered run succeeded."
19+
value: ${{ steps.wait-for-workflow.outputs.RUN_SUCCEEDED }}
20+
conclusion:
21+
description: "The conclusion of the triggered workflow run."
22+
value: ${{ steps.wait-for-workflow.outputs.CONCLUSION }}
23+
24+
runs:
25+
using: composite
26+
steps:
27+
- name: Print Action Input
28+
run: |
29+
echo "[DEBUG] Starting 'Await Workflow' Action; inputs = ${{ toJson(inputs) }}"
30+
shell: bash
31+
32+
- name: View Run
33+
if: ${{ inputs.commit-status != '' }}
34+
id: view-run
35+
env:
36+
GH_TOKEN: ${{ github.token }}
37+
run: |
38+
JSON=$(gh run view ${{ inputs.run-id }} --json url,headSha)
39+
echo "URL=$(echo $JSON | jq -r '.url')" >> $GITHUB_OUTPUT
40+
echo "HEAD_SHA=$(echo $JSON | jq -r '.headSha')" >> $GITHUB_OUTPUT
41+
shell: bash
42+
43+
- name: Create Commit Status
44+
if: ${{ inputs.commit-status != '' }}
45+
uses: actions/github-script@v7
46+
with:
47+
script: |
48+
github.rest.repos.createCommitStatus({
49+
owner: context.repo.owner,
50+
repo: context.repo.repo,
51+
sha: '${{ steps.view-run.outputs.HEAD_SHA }}',
52+
state: 'pending',
53+
target_url: '${{ steps.view-run.outputs.URL }}',
54+
context: '${{ inputs.commit-status }}'
55+
})
56+
57+
- name: Wait for Workflow to Complete
58+
id: wait-for-workflow
59+
env:
60+
GH_TOKEN: ${{ github.token }}
61+
run: |
62+
echo "[DEBUG] Waiting for run '${{ inputs.run-id }}' to complete..."
63+
gh run watch ${{ inputs.run-id }} --interval ${{ inputs.poll-interval }} > /dev/null
64+
CONCLUSION=$(gh run view ${{ inputs.run-id }} --json conclusion | jq -r '.conclusion')
65+
66+
echo "CONCLUSION=$CONCLUSION" >> $GITHUB_OUTPUT
67+
echo "[DEBUG] Run '${{ inputs.run-id }}' finished with conclusion '$CONCLUSION'."
68+
69+
if [[ "$CONCLUSION" != "success" ]]; then
70+
echo "RUN_SUCCEEDED=false" >> $GITHUB_OUTPUT
71+
exit 1
72+
fi
73+
74+
echo "RUN_SUCCEEDED=true" >> $GITHUB_OUTPUT
75+
shell: bash
76+
77+
- name: Determine Final Commit Status
78+
id: determine-final-commit-status
79+
if: ${{ always() && inputs.commit-status != '' }}
80+
run: |
81+
if [[ "${{ steps.wait-for-workflow.outputs.CONCLUSION }}" == "success" ]]; then
82+
echo "FINAL_COMMIT_STATUS=success" >> $GITHUB_OUTPUT
83+
else
84+
echo "FINAL_COMMIT_STATUS=failure" >> $GITHUB_OUTPUT
85+
fi
86+
shell: bash
87+
88+
- name: Update Commit Status
89+
if: ${{ always() && inputs.commit-status != '' }}
90+
uses: actions/github-script@v7
91+
with:
92+
script: |
93+
github.rest.repos.createCommitStatus({
94+
owner: context.repo.owner,
95+
repo: context.repo.repo,
96+
sha: '${{ steps.view-run.outputs.HEAD_SHA }}',
97+
state: '${{ steps.determine-final-commit-status.outputs.FINAL_COMMIT_STATUS }}',
98+
target_url: '${{ steps.view-run.outputs.URL }}',
99+
context: '${{ inputs.commit-status }}'
100+
})
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: "Trigger Workflow"
2+
description: "Triggers a workflow without waiting for it to complete."
3+
4+
inputs:
5+
workflow:
6+
description: "The workflow file name"
7+
required: true
8+
workflow-ref:
9+
description: "The ref (i.e. branch name, or tag name) where the workflow is located."
10+
required: true
11+
parameters:
12+
description: "The workflow parameters"
13+
required: false
14+
commit-sha:
15+
description: "The commit SHA to trigger the workflow on"
16+
required: false
17+
default: ${{ github.sha }}
18+
19+
outputs:
20+
run-id:
21+
description: "The id of the workflow run that was triggered."
22+
value: ${{ steps.trigger-workflow.outputs.RUN_ID }}
23+
run-url:
24+
description: "The url of the workflow run that was triggered."
25+
value: ${{ steps.trigger-workflow.outputs.RUN_URL }}
26+
27+
runs:
28+
using: composite
29+
steps:
30+
- name: Print Action Input
31+
run: |
32+
echo "[DEBUG] Starting 'Trigger Workflow' Action; inputs = ${{ toJson(inputs) }}"
33+
shell: bash
34+
35+
- name: Trigger Workflow
36+
id: trigger-workflow
37+
env:
38+
GH_TOKEN: ${{ github.token }}
39+
run: |
40+
PREVIOUS_RUN_ID=$(gh run list --workflow=${{ inputs.workflow}} --commit=${{ inputs.commit-sha }} --json databaseId | jq -r '.[0].databaseId')
41+
echo "[DEBUG] Previous run id = '$PREVIOUS_RUN_ID'"
42+
43+
gh workflow run "${{ inputs.workflow }}" --ref "${{ inputs.workflow-ref }}" ${{ inputs.parameters }}
44+
# allow for some initial delay as workflows take a moment to spin up
45+
sleep 20
46+
47+
for i in {0..6}; do
48+
LATEST_RUN_ID=$(gh run list --workflow=${{ inputs.workflow }} --commit=${{ inputs.commit-sha }} --json databaseId | jq -r '.[0].databaseId')
49+
50+
if [[ -z "$LATEST_RUN_ID" || "$LATEST_RUN_ID" == "$PREVIOUS_RUN_ID" ]]; then
51+
echo "[DEBUG] No new run detected. Waiting for 10 seconds."
52+
sleep 10
53+
else
54+
echo "[DEBUG] New workflow run detected: '$LATEST_RUN_ID'."
55+
56+
RUN_URL=$(gh run view $LATEST_RUN_ID --json url | jq -r '.url')
57+
echo "[DEBUG] ${{ inputs.workflow }} run #$LATEST_RUN_ID successfully triggered: $RUN_URL"
58+
echo "[${{ inputs.workflow }} run (#$LATEST_RUN_ID)]($RUN_URL)" >> $GITHUB_STEP_SUMMARY
59+
echo "RUN_ID=$LATEST_RUN_ID" >> $GITHUB_OUTPUT
60+
echo "RUN_URL=$RUN_URL" >> $GITHUB_OUTPUT
61+
exit 0
62+
fi
63+
done
64+
65+
echo "[DEBUG] Unable to detect new run of workflow '${{ inputs.workflow }}'."
66+
exit 1
67+
shell: bash

.github/workflows/perform-release.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ on:
1515
env:
1616
MVN_CLI_ARGS: --batch-mode --no-transfer-progress --fail-at-end --show-version -DskipTests
1717
JAVA_VERSION: 17
18+
DOCS_REPO: SAP/ai-sdk
1819

1920
jobs:
2021
prerequisites:
2122
name: "Prerequisites"
2223
outputs:
2324
code-branch: ${{ steps.determine-branch-names.outputs.CODE_BRANCH_NAME }}
25+
release-notes-branch: ${{ steps.determine-branch-names.outputs.RELEASE_NOTES_BRANCH_NAME }}
2426
release-tag: ${{ steps.determine-branch-names.outputs.RELEASE_TAG }}
2527
release-commit: ${{ steps.determine-branch-names.outputs.RELEASE_COMMIT }}
2628
permissions: write-all # contents and push are needed to see the draft release
@@ -33,11 +35,13 @@ jobs:
3335
RELEASE_VERSION=$(echo $CODE_BRANCH_NAME | cut -d '-' -f2)
3436
RELEASE_TAG=rel/$RELEASE_VERSION
3537
RELEASE_COMMIT=$(gh release view $RELEASE_TAG --repo ${{github.repository}} --json targetCommitish --jq '.targetCommitish')
38+
RELEASE_NOTES_BRANCH_NAME=java/release-notes-$RELEASE_VERSION
3639
3740
echo "CODE_BRANCH_NAME=$CODE_BRANCH_NAME" >> $GITHUB_OUTPUT
3841
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT
3942
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_OUTPUT
4043
echo "RELEASE_COMMIT=$RELEASE_COMMIT" >> $GITHUB_OUTPUT
44+
echo "RELEASE_NOTES_BRANCH_NAME=$RELEASE_NOTES_BRANCH_NAME" >> $GITHUB_OUTPUT
4145
4246
echo -e "[DEBUG] Current GITHUB_OUTPUT:\n$(cat $GITHUB_OUTPUT)"
4347
env:
@@ -64,6 +68,18 @@ jobs:
6468
workflow: "Continuous Integration"
6569
sha: ${{ steps.determine-branch-names.outputs.RELEASE_COMMIT }}
6670

71+
- name: "Check Whether Release Notes PR Can Be Merged"
72+
if: ${{ inputs.skip-pr-merge != 'true' }}
73+
uses: ./.github/actions/pr-is-mergeable
74+
with:
75+
pr-ref: ${{ steps.determine-branch-names.outputs.RELEASE_NOTES_BRANCH_NAME }}
76+
repo: ${{ env.DOCS_REPO }}
77+
token: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }}
78+
excluded-check-runs: |
79+
{
80+
\"Build Cloud SDK Documentation\": [\"dependabot\"]
81+
}
82+
6783
release:
6884
name: "Release"
6985
needs: [ prerequisites ]
@@ -114,3 +130,9 @@ jobs:
114130
run: gh release edit ${{ needs.prerequisites.outputs.release-tag }} --draft=false --repo "${{ github.repository }}"
115131
env:
116132
GH_TOKEN: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }}
133+
134+
- name: "Merge Release Notes PR"
135+
if: ${{ inputs.skip-pr-merge != 'true' }}
136+
run: gh pr merge --squash "${{ needs.prerequisites.outputs.release-notes-branch }}" --delete-branch --repo "${{ env.DOCS_REPO }}"
137+
env:
138+
GH_TOKEN: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }}

0 commit comments

Comments
 (0)