Skip to content

Commit 7f347e5

Browse files
authored
infra: Automate SHA procedure during releases (#3424)
1 parent 369a9f2 commit 7f347e5

File tree

13 files changed

+86
-15
lines changed

13 files changed

+86
-15
lines changed

.github/workflows/backport.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ jobs:
4040
gh pr create --title "[$GITHUB_REF_NAME] $title" \
4141
--body "Clean cherry-pick of #$NUMBER to the \`$GITHUB_REF_NAME\` branch." \
4242
--head $branch \
43-
--base $GITHUB_REF_NAME
43+
--base $GITHUB_REF_NAME \
44+
--label backport

.github/workflows/generate_workflows_lib/src/generate_workflows_lib/lint.yml.j2

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
env:
17-
CORE_REPO_SHA: main
17+
# Set the SHA to the branch name if the PR has a label 'prepare-release' or 'backport' otherwise, set it to 'main'
18+
# For PRs you can change the inner fallback ('main')
19+
# For pushes you change the outer fallback ('main')
20+
# The logic below is used during releases and depends on having an equivalent branch name in the core repo.
21+
CORE_REPO_SHA: {% raw %}${{ github.event_name == 'pull_request' && (
22+
contains(github.event.pull_request.labels.*.name, 'prepare-release') && github.event.pull_request.head.ref ||
23+
contains(github.event.pull_request.labels.*.name, 'backport') && github.event.pull_request.base.ref ||
24+
'main'
25+
) || 'main' }}{% endraw %}
1826
CONTRIB_REPO_SHA: main
1927
PIP_EXISTS_ACTION: w
2028

.github/workflows/generate_workflows_lib/src/generate_workflows_lib/misc.yml.j2

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
env:
17-
CORE_REPO_SHA: main
17+
# Set the SHA to the branch name if the PR has a label 'prepare-release' or 'backport' otherwise, set it to 'main'
18+
# For PRs you can change the inner fallback ('main')
19+
# For pushes you change the outer fallback ('main')
20+
# The logic below is used during releases and depends on having an equivalent branch name in the core repo.
21+
CORE_REPO_SHA: {% raw %}${{ github.event_name == 'pull_request' && (
22+
contains(github.event.pull_request.labels.*.name, 'prepare-release') && github.event.pull_request.head.ref ||
23+
contains(github.event.pull_request.labels.*.name, 'backport') && github.event.pull_request.base.ref ||
24+
'main'
25+
) || 'main' }}{% endraw %}
1826
CONTRIB_REPO_SHA: main
1927
PIP_EXISTS_ACTION: w
2028

.github/workflows/generate_workflows_lib/src/generate_workflows_lib/test.yml.j2

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
env:
17-
CORE_REPO_SHA: main
17+
# Set the SHA to the branch name if the PR has a label 'prepare-release' or 'backport' otherwise, set it to 'main'
18+
# For PRs you can change the inner fallback ('main')
19+
# For pushes you change the outer fallback ('main')
20+
# The logic below is used during releases and depends on having an equivalent branch name in the core repo.
21+
CORE_REPO_SHA: {% raw %}${{ github.event_name == 'pull_request' && (
22+
contains(github.event.pull_request.labels.*.name, 'prepare-release') && github.event.pull_request.head.ref ||
23+
contains(github.event.pull_request.labels.*.name, 'backport') && github.event.pull_request.base.ref ||
24+
'main'
25+
) || 'main' }}{% endraw %}
1826
CONTRIB_REPO_SHA: main
1927
PIP_EXISTS_ACTION: w
2028

.github/workflows/lint_0.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
env:
17-
CORE_REPO_SHA: main
17+
# Set the SHA to the branch name if the PR has a label 'prepare-release' or 'backport' otherwise, set it to 'main'
18+
# For PRs you can change the inner fallback ('main')
19+
# For pushes you change the outer fallback ('main')
20+
# The logic below is used during releases and depends on having an equivalent branch name in the core repo.
21+
CORE_REPO_SHA: ${{ github.event_name == 'pull_request' && (
22+
contains(github.event.pull_request.labels.*.name, 'prepare-release') && github.event.pull_request.head.ref ||
23+
contains(github.event.pull_request.labels.*.name, 'backport') && github.event.pull_request.base.ref ||
24+
'main'
25+
) || 'main' }}
1826
CONTRIB_REPO_SHA: main
1927
PIP_EXISTS_ACTION: w
2028

.github/workflows/misc_0.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
env:
17-
CORE_REPO_SHA: main
17+
# Set the SHA to the branch name if the PR has a label 'prepare-release' or 'backport' otherwise, set it to 'main'
18+
# For PRs you can change the inner fallback ('main')
19+
# For pushes you change the outer fallback ('main')
20+
# The logic below is used during releases and depends on having an equivalent branch name in the core repo.
21+
CORE_REPO_SHA: ${{ github.event_name == 'pull_request' && (
22+
contains(github.event.pull_request.labels.*.name, 'prepare-release') && github.event.pull_request.head.ref ||
23+
contains(github.event.pull_request.labels.*.name, 'backport') && github.event.pull_request.base.ref ||
24+
'main'
25+
) || 'main' }}
1826
CONTRIB_REPO_SHA: main
1927
PIP_EXISTS_ACTION: w
2028

.github/workflows/package-prepare-patch-release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,5 @@ jobs:
118118
gh pr create --title "[$GITHUB_REF_NAME] $message" \
119119
--body "$message." \
120120
--head $branch \
121-
--base $GITHUB_REF_NAME
121+
--base $GITHUB_REF_NAME \
122+
--label prepare-release

.github/workflows/package-prepare-release.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ jobs:
142142
gh pr create --title "[$RELEASE_BRANCH_NAME] $message" \
143143
--body "$message." \
144144
--head $branch \
145-
--base $RELEASE_BRANCH_NAME
145+
--base $RELEASE_BRANCH_NAME \
146+
--label prepare-release
146147
147148
create-pull-request-against-main:
148149
runs-on: ubuntu-latest
@@ -195,4 +196,5 @@ jobs:
195196
gh pr create --title "$message" \
196197
--body "$body" \
197198
--head $branch \
198-
--base main
199+
--base main \
200+
--label prepare-release

.github/workflows/prepare-patch-release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,5 @@ jobs:
8383
gh pr create --title "[$GITHUB_REF_NAME] $message" \
8484
--body "$message." \
8585
--head $branch \
86-
--base $GITHUB_REF_NAME
86+
--base $GITHUB_REF_NAME \
87+
--label prepare-release

.github/workflows/prepare-release-branch.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ jobs:
106106
gh pr create --title "[$RELEASE_BRANCH_NAME] $message" \
107107
--body "$message." \
108108
--head $branch \
109-
--base $RELEASE_BRANCH_NAME
109+
--base $RELEASE_BRANCH_NAME \
110+
--label prepare-release
110111
111112
create-pull-request-against-main:
112113
runs-on: ubuntu-latest
@@ -192,4 +193,5 @@ jobs:
192193
gh pr create --title "$message" \
193194
--body "$body" \
194195
--head $branch \
195-
--base main
196+
--base main \
197+
--label prepare-release

.github/workflows/test_0.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
env:
17-
CORE_REPO_SHA: main
17+
# Set the SHA to the branch name if the PR has a label 'prepare-release' or 'backport' otherwise, set it to 'main'
18+
# For PRs you can change the inner fallback ('main')
19+
# For pushes you change the outer fallback ('main')
20+
# The logic below is used during releases and depends on having an equivalent branch name in the core repo.
21+
CORE_REPO_SHA: ${{ github.event_name == 'pull_request' && (
22+
contains(github.event.pull_request.labels.*.name, 'prepare-release') && github.event.pull_request.head.ref ||
23+
contains(github.event.pull_request.labels.*.name, 'backport') && github.event.pull_request.base.ref ||
24+
'main'
25+
) || 'main' }}
1826
CONTRIB_REPO_SHA: main
1927
PIP_EXISTS_ACTION: w
2028

.github/workflows/test_1.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
env:
17-
CORE_REPO_SHA: main
17+
# Set the SHA to the branch name if the PR has a label 'prepare-release' or 'backport' otherwise, set it to 'main'
18+
# For PRs you can change the inner fallback ('main')
19+
# For pushes you change the outer fallback ('main')
20+
# The logic below is used during releases and depends on having an equivalent branch name in the core repo.
21+
CORE_REPO_SHA: ${{ github.event_name == 'pull_request' && (
22+
contains(github.event.pull_request.labels.*.name, 'prepare-release') && github.event.pull_request.head.ref ||
23+
contains(github.event.pull_request.labels.*.name, 'backport') && github.event.pull_request.base.ref ||
24+
'main'
25+
) || 'main' }}
1826
CONTRIB_REPO_SHA: main
1927
PIP_EXISTS_ACTION: w
2028

.github/workflows/test_2.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
env:
17-
CORE_REPO_SHA: main
17+
# Set the SHA to the branch name if the PR has a label 'prepare-release' or 'backport' otherwise, set it to 'main'
18+
# For PRs you can change the inner fallback ('main')
19+
# For pushes you change the outer fallback ('main')
20+
# The logic below is used during releases and depends on having an equivalent branch name in the core repo.
21+
CORE_REPO_SHA: ${{ github.event_name == 'pull_request' && (
22+
contains(github.event.pull_request.labels.*.name, 'prepare-release') && github.event.pull_request.head.ref ||
23+
contains(github.event.pull_request.labels.*.name, 'backport') && github.event.pull_request.base.ref ||
24+
'main'
25+
) || 'main' }}
1826
CONTRIB_REPO_SHA: main
1927
PIP_EXISTS_ACTION: w
2028

0 commit comments

Comments
 (0)