Skip to content

Commit cc3ced6

Browse files
committed
fix bump-n-release CI workflow
- setup node.js - install napi CLI - configure git credentials
1 parent 5e3d93f commit cc3ced6

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

.github/workflows/bump-n-release.yml

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ jobs:
3333
- uses: actions/setup-python@v5
3434
with:
3535
python-version: 3.x
36+
- uses: actions/setup-node@v4
37+
with:
38+
node-version: 20.x
39+
- run: yarn install
40+
- run: yarn global add @napi-rs/cli
3641
- uses: cargo-bins/cargo-binstall@main
3742
- run: cargo binstall -y git-cliff
3843
- name: Bump ${{ inputs.component }} verion

.github/workflows/bump_version.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
import argparse
3737
from pathlib import Path
38+
from os import environ
3839
import subprocess
3940
import re
4041

@@ -132,19 +133,24 @@ def main():
132133
)
133134
print("Updated CHANGELOG.md")
134135

136+
if environ.get("CI", "false") == "true":
137+
# configure git credentials on CI runner
138+
# NOTE: this is design to fail locally with `KeyError`
139+
git_config = {"name": environ["GITHUB_ACTOR"]}
140+
git_config["email"] = (
141+
f'{environ["GITHUB_ACTOR_ID"]}+{git_config["name"]}@users.noreply.github.com'
142+
)
143+
for key, value in git_config.items():
144+
subprocess.run(
145+
["git", "config", "--global", f"user.{key}", value], check=True
146+
)
135147
subprocess.run(["git", "add", "--all"], check=True)
136148
tag = "v" + Updater.new_version
137149
subprocess.run(["git", "commit", "-m", f"Bump version to {tag}"], check=True)
138-
try:
139-
subprocess.run(["git", "push"], check=True)
140-
except subprocess.CalledProcessError as exc:
141-
raise RuntimeError(
142-
"""Failed to push commit for version bump. Please ensure that
143-
- You have the necessary permissions and are authenticated properly.
144-
- All other commits on the branch have ben pushed already."""
145-
) from exc
146-
title, notes = get_release_notes()
150+
subprocess.run(["git", "push"], check=True)
147151
print("Pushed commit to 'Bump version to", tag, "'")
152+
153+
title, notes = get_release_notes()
148154
gh_cmd = ["gh", "release", "create", tag, "--title", title, "--notes", notes]
149155
if Updater.component == "rc":
150156
gh_cmd.append("--prerelease")

0 commit comments

Comments
 (0)