Skip to content

Commit 50ab6ce

Browse files
committed
ci: add a make-release-commit action
1 parent 1cd1641 commit 50ab6ce

File tree

8 files changed

+246
-3
lines changed

8 files changed

+246
-3
lines changed

.bumpversion.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[tool.bumpversion]
2+
current_version = "0.2.0-beta.1"
3+
parse = """(?x)
4+
(?P<major>0|[1-9]\\d*)\\.
5+
(?P<minor>0|[1-9]\\d*)\\.
6+
(?P<patch>0|[1-9]\\d*)
7+
(?:-(?P<pre_l>[a-zA-Z-]+)\\.(?P<pre_n>0|[1-9]\\d*))?
8+
"""
9+
serialize = [
10+
"{major}.{minor}.{patch}-{pre_l}.{pre_n}",
11+
"{major}.{minor}.{patch}",
12+
]
13+
search = "{current_version}"
14+
replace = "{new_version}"
15+
regex = false
16+
ignore_missing_version = false
17+
ignore_missing_files = false
18+
tag = true
19+
sign_tags = false
20+
tag_name = "v{new_version}"
21+
tag_message = "Bump version: {current_version} → {new_version}"
22+
allow_dirty = true
23+
commit = true
24+
message = "Bump version: {current_version} → {new_version}"
25+
commit_args = ""
26+
27+
[tool.bumpversion.parts.pre_l]
28+
optional_value = "final"
29+
values = ["beta", "final"]
30+
31+
[[tool.bumpversion.files]]
32+
filename = "package.json"
33+
replace = "\"version\": \"{new_version}\","
34+
search = "\"version\": \"{current_version}\","
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Create release commit
2+
3+
# This workflow increments versions, tags the version, and pushes it.
4+
# When a tag is pushed, another workflow is triggered that creates a GH release
5+
# and uploads the binaries. This workflow is only for creating the tag.
6+
7+
# This script will enforce that a minor version is incremented if there are any
8+
# breaking changes since the last minor increment
9+
on:
10+
workflow_dispatch:
11+
inputs:
12+
dry_run:
13+
description: "Dry run (create the local commit/tags but do not push it)"
14+
required: true
15+
default: false
16+
type: boolean
17+
bump-minor:
18+
description: "Bump minor version"
19+
required: true
20+
default: false
21+
type: boolean
22+
23+
jobs:
24+
make-release:
25+
# Creates tag and GH release. The GH release will trigger the build and release jobs.
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: write
29+
steps:
30+
- name: Output Inputs
31+
run: echo "${{ toJSON(github.event.inputs) }}"
32+
- uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
lfs: true
36+
# It's important we use our token here, as the default token will NOT
37+
# trigger any workflows watching for new tags. See:
38+
# https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
39+
token: ${{ secrets.FSQL_DEPLOY_TOKEN }}
40+
- name: Set git configs for bumpversion
41+
shell: bash
42+
run: |
43+
git config user.name 'Lance Release'
44+
git config user.email '[email protected]'
45+
- name: Set up Python 3.11
46+
uses: actions/setup-python@v5
47+
with:
48+
python-version: "3.11"
49+
- name: Bump Node/Rust version
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
run: |
53+
pip install bump-my-version PyGithub packaging
54+
bash ci/bump_version.sh ${{ inputs.bump-minor }} $COMMIT_BEFORE_BUMP
55+
- name: Push new version tag
56+
if: ${{ !inputs.dry_run }}
57+
uses: ad-m/github-push-action@master
58+
with:
59+
# Need to use PAT here too to trigger next workflow. See comment above.
60+
github_token: ${{ secrets.FSQL_DEPLOY_TOKEN }}
61+
branch: ${{ github.ref }}
62+
tags: true
63+
- uses: ./.github/workflows/update_package_lock
64+
if: ${{ !inputs.dry_run }}
65+
with:
66+
github_token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: update_package_lock
2+
description: "Update node's package.lock"
3+
4+
inputs:
5+
github_token:
6+
required: true
7+
description: "github token for the repo"
8+
dry_run:
9+
required: true
10+
description: "Dry run (create the local commit but do not push it)"
11+
default: false
12+
type: boolean
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version: 20
20+
- name: Set git configs
21+
shell: bash
22+
run: |
23+
git config user.name 'Lance Release'
24+
git config user.email '[email protected]'
25+
- name: Update package-lock.json file
26+
run: |
27+
npm install
28+
git add package-lock.json
29+
git commit -m "Updating package-lock.json"
30+
shell: bash
31+
- name: Push changes
32+
if: ${{ inputs.dry_run }} == "false"
33+
uses: ad-m/github-push-action@master
34+
with:
35+
github_token: ${{ inputs.github_token }}
36+
branch: main
37+
tags: true

ci/bump_version.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
set -e
2+
3+
BUMP_MINOR=${1:-false}
4+
HEAD_SHA=${2:-$(git rev-parse HEAD)}
5+
6+
TAG_PREFIX="v"
7+
8+
readonly SELF_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
9+
10+
PREV_TAG=$(git tag --sort='version:refname' | grep ^$TAG_PREFIX | python $SELF_DIR/semver_sort.py $TAG_PREFIX | tail -n 1)
11+
echo "Found previous tag $PREV_TAG"
12+
13+
if [[ "$BUMP_MINOR" != "false" ]]; then
14+
# X.Y.Z -> X.(Y+1).0-beta.0
15+
bump-my-version bump -vv --no-commit --no-tag minor
16+
else
17+
# X.Y.Z -> X.Y.(Z+1)-beta.0
18+
bump-my-version bump -vv --no-commit --no-tag patch
19+
fi
20+
21+
# The above bump will always bump to a pre-release version.
22+
# Now bump the pre-release level ("pre_l") to make it stable.
23+
24+
# X.Y.Z-beta.N -> X.Y.Z
25+
bump-my-version bump -vv pre_l
26+
27+
# Validate that we have incremented version appropriately for breaking changes
28+
NEW_TAG=$(git describe --tags --exact-match HEAD)
29+
NEW_VERSION=$(echo $NEW_TAG | sed "s/^$TAG_PREFIX//")
30+
LAST_STABLE_RELEASE=$(git tag --sort='version:refname' | grep ^$TAG_PREFIX | grep -v beta | grep -vF "$NEW_TAG" | python $SELF_DIR/semver_sort.py $TAG_PREFIX | tail -n 1)
31+
LAST_STABLE_VERSION=$(echo $LAST_STABLE_RELEASE | sed "s/^$TAG_PREFIX//")
32+
33+
echo "Checking for breaking changes between $LAST_STABLE_RELEASE / $LAST_STABLE_VERSION and $HEAD_SHA / $NEW_VERSION"
34+
35+
python $SELF_DIR/check_breaking_changes.py $LAST_STABLE_RELEASE $HEAD_SHA $LAST_STABLE_VERSION $NEW_VERSION

ci/check_breaking_changes.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
Check whether there are any breaking changes in the PRs between the base and head commits.
3+
If there are, assert that we have incremented the minor version.
4+
"""
5+
import argparse
6+
import os
7+
from packaging.version import parse
8+
9+
from github import Github
10+
11+
if __name__ == "__main__":
12+
parser = argparse.ArgumentParser()
13+
parser.add_argument("base")
14+
parser.add_argument("head")
15+
parser.add_argument("last_stable_version")
16+
parser.add_argument("current_version")
17+
args = parser.parse_args()
18+
19+
repo = Github(os.environ["GITHUB_TOKEN"]).get_repo(os.environ["GITHUB_REPOSITORY"])
20+
commits = repo.compare(args.base, args.head).commits
21+
prs = (pr for commit in commits for pr in commit.get_pulls())
22+
23+
for pr in prs:
24+
if any(label.name == "breaking-change" for label in pr.labels):
25+
print(f"Breaking change in PR: {pr.html_url}")
26+
break
27+
else:
28+
print("No breaking changes found.")
29+
exit(0)
30+
31+
last_stable_version = parse(args.last_stable_version)
32+
current_version = parse(args.current_version)
33+
if current_version.minor <= last_stable_version.minor:
34+
print("Minor version is not greater than the last stable version.")
35+
exit(1)

ci/semver_sort.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""
2+
Takes a list of semver strings and sorts them in ascending order.
3+
"""
4+
5+
import sys
6+
from packaging.version import parse, InvalidVersion
7+
8+
if __name__ == "__main__":
9+
import argparse
10+
11+
parser = argparse.ArgumentParser()
12+
parser.add_argument("prefix", default="v")
13+
args = parser.parse_args()
14+
15+
# Read the input from stdin
16+
lines = sys.stdin.readlines()
17+
18+
# Parse the versions
19+
versions = []
20+
for line in lines:
21+
line = line.strip()
22+
try:
23+
version_str = line.removeprefix(args.prefix)
24+
version = parse(version_str)
25+
except InvalidVersion:
26+
# There are old tags that don't follow the semver format
27+
print(f"Invalid version: {line}", file=sys.stderr)
28+
continue
29+
versions.append((line, version))
30+
31+
# Sort the versions
32+
versions.sort(key=lambda x: x[1])
33+
34+
# Print the sorted versions as original strings
35+
for line, _ in versions:
36+
print(line)

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lancedb/arrow-flight-sql-client",
3-
"version": "0.1.0",
3+
"version": "0.2.0-beta.1",
44
"description": "A native typescript project for querying Flight SQL endpoints",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

0 commit comments

Comments
 (0)