Skip to content

Commit 0465f2e

Browse files
committed
chore(ci): support backport release (#17185)
* chore(ci): support backport release * z * z * z * z
1 parent 9e71e4d commit 0465f2e

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

.github/scripts/bump_version.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
module.exports = async ({ github, context, core }) => {
2+
const knownEvents = ["schedule", "workflow_dispatch", "release"];
3+
if (!knownEvents.includes(context.eventName)) {
4+
core.setFailed(`Triggerd by unknown event: ${context.eventName}`);
5+
return;
6+
}
7+
28
const { STABLE, TAG } = process.env;
9+
10+
// trigger by release event
311
if (context.ref.startsWith("refs/tags/")) {
412
let tag = context.ref.replace("refs/tags/", "");
513
core.setOutput("tag", tag);
14+
core.setOutput("sha", context.sha);
615
core.info(`Tag event triggered by ${tag}.`);
716
return;
817
}
18+
19+
// trigger by schedule or workflow_dispatch event
920
if (STABLE == "true") {
1021
if (TAG) {
1122
// trigger stable release by workflow_dispatch with a tag

.github/workflows/dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
- reopened
99
branches:
1010
- main
11+
- backport/*
1112

1213
concurrency:
1314
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
- backport/*
78

89
jobs:
910
changes:

.github/workflows/release.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ on:
1313
description: Make a stable release
1414
required: false
1515
type: boolean
16+
release:
17+
types:
18+
- published
1619

1720
permissions:
1821
id-token: write
@@ -47,19 +50,20 @@ jobs:
4750
const script = require('./.github/scripts/bump_version.js')
4851
await script({ github, context, core })
4952
- name: Create release
53+
if: github.event_name == 'workflow_dispatch'
5054
env:
5155
# we need workflow:write permission to create release if there were any workflow changes
5256
# which is not possible for github actions token
5357
GH_TOKEN: ${{ secrets.DATABEND_BOT_TOKEN }}
5458
run: |
5559
echo "Creating release ${{ steps.bump.outputs.tag }} from ${{ steps.bump.outputs.sha }}"
5660
if [[ "${{ inputs.stable }}" == "true" ]]; then
57-
echo "Stable release"
5861
previous=$(gh release list --limit 1 --exclude-pre-releases | cut -f 1)
62+
echo "Stable release with previous release: $previous"
5963
gh release create ${{ steps.bump.outputs.tag }} --target ${{ steps.bump.outputs.sha }} --generate-notes --notes-start-tag $previous --latest --draft
6064
else
61-
echo "Nightly release"
62-
previous=$(gh release list --limit 1 | cut -f 1)
65+
previous=$(gh release list --limit 10 | grep nightly | head -n 1 | cut -f 1)
66+
echo "Nightly release with previous release: $previous"
6367
gh release create ${{ steps.bump.outputs.tag }} --target ${{ steps.bump.outputs.sha }} --generate-notes --notes-start-tag $previous --prerelease --draft
6468
fi
6569

0 commit comments

Comments
 (0)