-
Notifications
You must be signed in to change notification settings - Fork 483
ci: refactor bump downstream versions worflow and adds demo-scene #6171
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
Merged
killme2008
merged 5 commits into
GreptimeTeam:main
from
killme2008:feature/bump-demo-version
Jun 9, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| /* | ||
| * Copyright 2023 Greptime Team | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import * as core from "@actions/core"; | ||
| import {obtainClient} from "@/common"; | ||
|
|
||
| interface RepoConfig { | ||
| tokenEnv: string; | ||
| repo: string; | ||
| workflowLogic: (version: string) => [string, string] | null; | ||
| } | ||
|
|
||
| const REPO_CONFIGS: Record<string, RepoConfig> = { | ||
| website: { | ||
| tokenEnv: "WEBSITE_REPO_TOKEN", | ||
| repo: "website", | ||
| workflowLogic: (version: string) => { | ||
| // Skip nightly versions for website | ||
| if (version.includes('nightly')) { | ||
| console.log('Nightly version detected for website, skipping workflow trigger.'); | ||
| return null; | ||
| } | ||
| return ['bump-patch-version.yml', version]; | ||
| } | ||
| }, | ||
| demo: { | ||
| tokenEnv: "DEMO_REPO_TOKEN", | ||
| repo: "demo-scene", | ||
| workflowLogic: (version: string) => { | ||
| // Skip nightly versions for demo | ||
| if (version.includes('nightly')) { | ||
| console.log('Nightly version detected for demo, skipping workflow trigger.'); | ||
| return null; | ||
| } | ||
| return ['bump-patch-version.yml', version]; | ||
| } | ||
| }, | ||
| docs: { | ||
| tokenEnv: "DOCS_REPO_TOKEN", | ||
| repo: "docs", | ||
| workflowLogic: (version: string) => { | ||
| // Check if it's a nightly version | ||
| if (version.includes('nightly')) { | ||
| return ['bump-nightly-version.yml', version]; | ||
| } | ||
|
|
||
| const parts = version.split('.'); | ||
| if (parts.length !== 3) { | ||
| throw new Error('Invalid version format'); | ||
| } | ||
|
|
||
| // If patch version (last number) is 0, it's a major version | ||
| // Return only major.minor version | ||
| if (parts[2] === '0') { | ||
| return ['bump-version.yml', `${parts[0]}.${parts[1]}`]; | ||
| } | ||
|
|
||
| // Otherwise it's a patch version, use full version | ||
| return ['bump-patch-version.yml', version]; | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| async function triggerWorkflow(repoConfig: RepoConfig, workflowId: string, version: string) { | ||
| const client = obtainClient(repoConfig.tokenEnv); | ||
| try { | ||
| await client.rest.actions.createWorkflowDispatch({ | ||
| owner: "GreptimeTeam", | ||
| repo: repoConfig.repo, | ||
| workflow_id: workflowId, | ||
| ref: "main", | ||
| inputs: { | ||
| version, | ||
| }, | ||
| }); | ||
| console.log(`Successfully triggered ${workflowId} workflow for ${repoConfig.repo} with version ${version}`); | ||
| } catch (error) { | ||
| core.setFailed(`Failed to trigger workflow for ${repoConfig.repo}: ${error.message}`); | ||
| throw error; | ||
| } | ||
| } | ||
|
|
||
| async function processRepo(repoName: string, version: string) { | ||
| const repoConfig = REPO_CONFIGS[repoName]; | ||
| if (!repoConfig) { | ||
| throw new Error(`Unknown repository: ${repoName}`); | ||
| } | ||
|
|
||
| try { | ||
| const workflowResult = repoConfig.workflowLogic(version); | ||
| if (workflowResult === null) { | ||
| // Skip this repo (e.g., nightly version for website) | ||
| return; | ||
| } | ||
|
|
||
| const [workflowId, apiVersion] = workflowResult; | ||
| await triggerWorkflow(repoConfig, workflowId, apiVersion); | ||
| } catch (error) { | ||
| core.setFailed(`Error processing ${repoName} with version ${version}: ${error.message}`); | ||
| throw error; | ||
| } | ||
| } | ||
|
|
||
| async function main() { | ||
| const version = process.env.VERSION; | ||
| if (!version) { | ||
| core.setFailed("VERSION environment variable is required"); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| // Remove 'v' prefix if exists | ||
| const cleanVersion = version.startsWith('v') ? version.slice(1) : version; | ||
|
|
||
| // Get target repositories from environment variable | ||
| // Default to both if not specified | ||
| const targetRepos = process.env.TARGET_REPOS?.split(',').map(repo => repo.trim()) || ['website', 'docs']; | ||
|
|
||
| console.log(`Processing version ${cleanVersion} for repositories: ${targetRepos.join(', ')}`); | ||
|
|
||
| const errors: string[] = []; | ||
|
|
||
| // Process each repository | ||
| for (const repo of targetRepos) { | ||
| try { | ||
| await processRepo(repo, cleanVersion); | ||
| } catch (error) { | ||
| errors.push(`${repo}: ${error.message}`); | ||
| } | ||
| } | ||
|
|
||
| if (errors.length > 0) { | ||
| core.setFailed(`Failed to process some repositories: ${errors.join('; ')}`); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| console.log('All repositories processed successfully'); | ||
| } | ||
|
|
||
| // Execute main function | ||
| main().catch((error) => { | ||
| core.setFailed(`Unexpected error: ${error.message}`); | ||
| process.exit(1); | ||
| }); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.