Skip to content

Commit 47b2a5a

Browse files
[Internal] Enable Automated Tagging for SDK (#409)
## What changes are proposed in this pull request? Enable Automated Tagging for SDK to support faster releases. ## How is this tested? Automated Tagging process has been already enabled in `terraform-provider-databricks` repository.
1 parent 039c4f6 commit 47b2a5a

File tree

7 files changed

+746
-4
lines changed

7 files changed

+746
-4
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"mode": "java_v0",
3-
"changelog_config": ".codegen/changelog_config.yml",
3+
"api_changelog": true,
44
"version": {
55
"pom.xml": "<artifactId>databricks-sdk-parent</artifactId>\n <version>$VERSION</version>",
66
"databricks-sdk-java/pom.xml": "<artifactId>databricks-sdk-parent</artifactId>\n <version>$VERSION</version>",

.codegen/changelog_config.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@ change_types:
77
tag: "[Doc]"
88
- message: Internal Changes
99
tag: "[Internal]"
10-
# Does not appear in the Changelog. Only for PR validation.
11-
- message: Release
12-
tag: "[Release]"
1310
# Default for messages without a tag
1411
- message: Other Changes

.github/workflows/next-changelog.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Generated file. DO NOT EDIT.
2+
name: Check for NEXT_CHANGELOG.md Changes
3+
4+
on:
5+
# Use pull_request_target to have access to GitHub API
6+
pull_request_target:
7+
8+
jobs:
9+
check-next-changelog:
10+
runs-on:
11+
group: databricks-deco-testing-runner-group
12+
labels: ubuntu-latest-deco
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
- name: Fetch list of changed files
19+
id: changed-files
20+
env:
21+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
run: |
23+
# Use the GitHub API to fetch changed files
24+
files=$(gh pr view ${{ github.event.pull_request.number }} --json files -q '.files[].path')
25+
26+
# Sanitize to avoid code injection
27+
sanitized_files=$(echo "$files" | sed 's/[^a-zA-Z0-9._/-]/_/g')
28+
29+
# Store the sanitized list of files in a temporary file to avoid env variable issues
30+
echo "$sanitized_files" > modified_files.txt
31+
32+
- name: Fetch PR message
33+
id: pr-message
34+
env:
35+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
run: |
37+
# Use the GitHub API to fetch the PR message
38+
pr_message=$(gh pr view ${{ github.event.pull_request.number }} --json body -q '.body')
39+
40+
# Sanitize the PR message to avoid code injection, keeping the equal sign
41+
sanitized_pr_message=$(echo "$pr_message" | sed 's/[^a-zA-Z0-9._/-=]/_/g')
42+
43+
# Store the sanitized PR message
44+
echo "$sanitized_pr_message" > pr_message.txt
45+
46+
- name: Verify NEXT_CHANGELOG.md was modified or PR message contains NO_CHANGELOG=true
47+
run: |
48+
# Read the sanitized files and PR message from the temporary files
49+
modified_files=$(cat modified_files.txt)
50+
pr_message=$(cat pr_message.txt)
51+
52+
# Check if NEXT_CHANGELOG.md exists in the list of changed files
53+
echo "Changed files: $modified_files"
54+
if ! echo "$modified_files" | grep -q "NEXT_CHANGELOG.md"; then
55+
echo "NEXT_CHANGELOG.md not modified."
56+
57+
# Check if PR message contains NO_CHANGELOG=true
58+
if echo "$pr_message" | grep -q "NO_CHANGELOG=true"; then
59+
echo "NO_CHANGELOG=true found in PR message. Skipping changelog check."
60+
exit 0
61+
else
62+
echo "WARNING: file NEXT_CHANGELOG.md not changed. If this is expected, add NO_CHANGELOG=true to the PR message."
63+
exit 1
64+
fi
65+
fi
66+
67+
- name: Comment on PR with instructions if needed
68+
if: failure() # This step will only run if the previous step fails (i.e., if NEXT_CHANGELOG.md was not modified and NO_CHANGELOG=true was not in the PR message)
69+
env:
70+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
run: |
72+
# Check if a comment exists with the instructions
73+
previous_comment_ids=$(gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
74+
--jq '.[] | select(.body | startswith("<!-- NEXT_CHANGELOG_INSTRUCTIONS -->")) | .id')
75+
echo "Previous comment IDs: $previous_comment_ids"
76+
77+
# If no previous comment exists, add one with instructions
78+
if [ -z "$previous_comment_ids" ]; then
79+
echo "Adding instructions comment."
80+
gh pr comment ${{ github.event.pull_request.number }} --body \
81+
"<!-- NEXT_CHANGELOG_INSTRUCTIONS -->
82+
Please ensure that the NEXT_CHANGELOG.md file is updated with any relevant changes.
83+
If this is not necessary for your PR, please include the following in your PR description:
84+
NO_CHANGELOG=true
85+
and rerun the job."
86+
fi
87+
88+
- name: Delete instructions comment on success
89+
if: success() # This step will only run if the previous check passed (i.e., if NEXT_CHANGELOG.md was modified or NO_CHANGELOG=true is in the PR message)
90+
env:
91+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
run: |
93+
# Check if there is a previous instructions comment
94+
previous_comment_ids=$(gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
95+
--jq '.[] | select(.body | startswith("<!-- NEXT_CHANGELOG_INSTRUCTIONS -->")) | .id')
96+
97+
# If a comment exists, delete it
98+
if [ -n "$previous_comment_ids" ]; then
99+
echo "Deleting previous instructions comment."
100+
for comment_id in $previous_comment_ids; do
101+
gh api "repos/${{ github.repository }}/issues/comments/$comment_id" --method DELETE
102+
done
103+
else
104+
echo "No instructions comment found to delete."
105+
fi

.github/workflows/tagging.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Generated file. DO NOT EDIT.
2+
name: tagging
3+
4+
on:
5+
workflow_dispatch:
6+
# Enable for automatic tagging
7+
#schedule:
8+
# - cron: '0 0 * * TUE'
9+
10+
# Ensure that only a single instance of the workflow is running at a time.
11+
concurrency:
12+
group: "tagging"
13+
14+
15+
jobs:
16+
tag:
17+
environment: "release-is"
18+
runs-on:
19+
group: databricks-deco-testing-runner-group
20+
labels: ubuntu-latest-deco
21+
steps:
22+
- name: Generate GitHub App Token
23+
id: generate-token
24+
uses: actions/create-github-app-token@v1
25+
with:
26+
app-id: ${{ secrets.DECO_SDK_TAGGING_APP_ID }}
27+
private-key: ${{ secrets.DECO_SDK_TAGGING_PRIVATE_KEY }}
28+
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
token: ${{ steps.generate-token.outputs.token }}
34+
35+
#NOTE: email must be the GitHub App email or the commit will not be verified.
36+
- name: Set up Git configuration
37+
run: |
38+
git config user.name "Databricks SDK Release Bot"
39+
git config user.email "DECO-SDK-Tagging[bot]@users.noreply.github.com"
40+
41+
- name: Install dependencies
42+
run: |
43+
python -m pip install --upgrade pip
44+
pip install PyGithub
45+
46+
- name: Run script
47+
env:
48+
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
49+
GITHUB_REPOSITORY: ${{ github.repository }}
50+
run: |
51+
python tagging.py
52+

.package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

NEXT_CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# NEXT CHANGELOG
2+
3+
## Release v0.42.0
4+
5+
### New Features and Improvements
6+
7+
### Bug Fixes
8+
9+
### Documentation
10+
11+
### Internal Changes
12+
* Introduce automated tagging ([#409](https://github.com/databricks/databricks-sdk-java/pull/409)).
13+
* Update Jobs GetJob API to support paginated responses ([#403](https://github.com/databricks/databricks-sdk-java/pull/403)).
14+
* Update Jobs GetRun API to support paginated responses ([#402](https://github.com/databricks/databricks-sdk-java/pull/402)).
15+
16+
### API Changes

0 commit comments

Comments
 (0)