Skip to content

Commit

Permalink
chore(ci): support backport release (#17185)
Browse files Browse the repository at this point in the history
* chore(ci): support backport release

* z

* z

* z

* z
  • Loading branch information
everpcpc committed Jan 7, 2025
1 parent 9e71e4d commit 0465f2e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
11 changes: 11 additions & 0 deletions .github/scripts/bump_version.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
module.exports = async ({ github, context, core }) => {
const knownEvents = ["schedule", "workflow_dispatch", "release"];
if (!knownEvents.includes(context.eventName)) {
core.setFailed(`Triggerd by unknown event: ${context.eventName}`);
return;
}

const { STABLE, TAG } = process.env;

// trigger by release event
if (context.ref.startsWith("refs/tags/")) {
let tag = context.ref.replace("refs/tags/", "");
core.setOutput("tag", tag);
core.setOutput("sha", context.sha);
core.info(`Tag event triggered by ${tag}.`);
return;
}

// trigger by schedule or workflow_dispatch event
if (STABLE == "true") {
if (TAG) {
// trigger stable release by workflow_dispatch with a tag
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- reopened
branches:
- main
- backport/*

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- backport/*

jobs:
changes:
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ on:
description: Make a stable release
required: false
type: boolean
release:
types:
- published

permissions:
id-token: write
Expand Down Expand Up @@ -47,19 +50,20 @@ jobs:
const script = require('./.github/scripts/bump_version.js')
await script({ github, context, core })
- name: Create release
if: github.event_name == 'workflow_dispatch'
env:
# we need workflow:write permission to create release if there were any workflow changes
# which is not possible for github actions token
GH_TOKEN: ${{ secrets.DATABEND_BOT_TOKEN }}
run: |
echo "Creating release ${{ steps.bump.outputs.tag }} from ${{ steps.bump.outputs.sha }}"
if [[ "${{ inputs.stable }}" == "true" ]]; then
echo "Stable release"
previous=$(gh release list --limit 1 --exclude-pre-releases | cut -f 1)
echo "Stable release with previous release: $previous"
gh release create ${{ steps.bump.outputs.tag }} --target ${{ steps.bump.outputs.sha }} --generate-notes --notes-start-tag $previous --latest --draft
else
echo "Nightly release"
previous=$(gh release list --limit 1 | cut -f 1)
previous=$(gh release list --limit 10 | grep nightly | head -n 1 | cut -f 1)
echo "Nightly release with previous release: $previous"
gh release create ${{ steps.bump.outputs.tag }} --target ${{ steps.bump.outputs.sha }} --generate-notes --notes-start-tag $previous --prerelease --draft
fi
Expand Down

0 comments on commit 0465f2e

Please sign in to comment.