Skip to content

Commit 9718d22

Browse files
authored
chore: adopt auto-version-bump action from BCP (#897)
Signed-off-by: Yi Cai <yicai@redhat.com>
1 parent 3cf608f commit 9718d22

2 files changed

Lines changed: 89 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Auto Version Bump
2+
3+
on:
4+
workflow_dispatch:
5+
6+
concurrency:
7+
group: auto-version-bump
8+
cancel-in-progress: false
9+
10+
jobs:
11+
prepare:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
matrix: ${{ steps.set-matrix.outputs.matrix }}
15+
steps:
16+
- name: Checkout repo
17+
uses: actions/checkout@v4
18+
19+
- name: Generate workspace matrix
20+
id: set-matrix
21+
run: |
22+
matrix=$(node scripts/ci/generate-auto-bump-matrix.js)
23+
echo "matrix=$matrix" >> $GITHUB_OUTPUT
24+
25+
batch-dispatch:
26+
needs: prepare
27+
runs-on: ubuntu-latest
28+
strategy:
29+
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
30+
steps:
31+
- name: Checkout repo
32+
uses: actions/checkout@v4
33+
34+
- name: Delay batches (5 min between)
35+
if: ${{ strategy.job-index != 0 }}
36+
run: |
37+
delay=$(( ${{ strategy.job-index }} * 300 ))
38+
echo "Sleeping $delay seconds before triggering batch ${{ strategy.job-index }}..."
39+
sleep $delay
40+
41+
- name: Trigger Version Bump Workflow via GitHub CLI
42+
env:
43+
GH_TOKEN: ${{ secrets.RHDH_BOT_TOKEN }}
44+
run: |
45+
echo "Triggering version bump for workspace ${{ matrix.workspace }}"
46+
json_input='${{ toJson(matrix.workspace) }}'
47+
echo "Rendered json_input: $json_input"
48+
gh workflow run version-bump.yml \
49+
--ref main \
50+
--field release_line=main \
51+
--field workspace_input="$json_input" \
52+
--field version-bump-type=minor
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright The Backstage Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import fs from 'fs';
18+
import path from 'path';
19+
20+
const workspacesDir = path.resolve('workspaces');
21+
22+
// Only include directories that contain a `.auto-version-bump` marker file
23+
function getWorkspaceDirs() {
24+
return fs.readdirSync(workspacesDir).filter(entry => {
25+
const dirPath = path.join(workspacesDir, entry);
26+
const bumpFile = path.join(dirPath, '.auto-version-bump');
27+
28+
return fs.statSync(dirPath).isDirectory() && fs.existsSync(bumpFile);
29+
});
30+
}
31+
32+
const workspaces = getWorkspaceDirs().sort();
33+
34+
// Final matrix: one workspace per job
35+
const matrix = workspaces.map(workspace => ({ workspace }));
36+
37+
console.log(JSON.stringify(matrix));

0 commit comments

Comments
 (0)