Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): support backport release #17185

Merged
merged 5 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading