forked from lance-format/lance
-
Notifications
You must be signed in to change notification settings - Fork 0
200 lines (176 loc) · 6.5 KB
/
make-release-commit.yml
File metadata and controls
200 lines (176 loc) · 6.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: Create release
on:
workflow_dispatch:
inputs:
release_type:
description: 'Release type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
release_channel:
description: 'Release channel'
required: true
default: 'preview'
type: choice
options:
- preview
- stable
dry_run:
description: 'Dry run (simulate the release without pushing)'
required: true
default: true
type: boolean
draft_release:
description: 'Create a draft release on GitHub'
required: true
default: true
type: boolean
jobs:
validate-and-release:
runs-on: ubuntu-latest
steps:
- name: Output Inputs
run: echo "${{ toJSON(github.event.inputs) }}"
- name: Check out main
uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.LANCE_RELEASE_TOKEN }}
fetch-depth: 0
lfs: true
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
pip install bump-my-version packaging PyGithub
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Check for breaking changes
id: breaking_changes
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python ci/check_breaking_changes.py
echo "has_breaking=$?" >> $GITHUB_OUTPUT
- name: Validate release type
run: |
if [ "${{ steps.breaking_changes.outputs.has_breaking }}" == "1" ]; then
if [ "${{ inputs.release_type }}" == "patch" ]; then
echo "Error: Breaking changes detected but patch release requested"
echo "Please use minor or major release type"
exit 1
fi
fi
- name: Get current version
id: current_version
run: |
CURRENT_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "Current version: $CURRENT_VERSION"
- name: Calculate new version
id: new_version
run: |
CURRENT="${{ steps.current_version.outputs.version }}"
TYPE="${{ inputs.release_type }}"
IFS='.' read -r major minor patch <<< "$CURRENT"
case "$TYPE" in
major)
NEW_VERSION="$((major + 1)).0.0"
;;
minor)
NEW_VERSION="${major}.$((minor + 1)).0"
;;
patch)
NEW_VERSION="${major}.${minor}.$((patch + 1))"
;;
esac
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "New version will be: $NEW_VERSION"
- name: Determine tag name
id: tag_name
run: |
if [ "${{ inputs.release_channel }}" == "stable" ]; then
VERSION="${{ steps.new_version.outputs.version }}"
TAG="v${VERSION}"
else
# For preview releases, use current version
VERSION="${{ steps.current_version.outputs.version }}"
# Find the next beta number for current version
BETA_TAGS=$(git tag -l "v${VERSION}-beta.*" | sort -V)
if [ -z "$BETA_TAGS" ]; then
BETA_NUM=1
else
LAST_BETA=$(echo "$BETA_TAGS" | tail -n 1)
LAST_NUM=$(echo "$LAST_BETA" | sed "s/v${VERSION}-beta.//")
BETA_NUM=$((LAST_NUM + 1))
fi
TAG="v${VERSION}-beta.${BETA_NUM}"
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Tag will be: $TAG"
- name: Update version (stable releases only)
if: inputs.release_channel == 'stable'
run: |
python ci/bump_version.py ${{ inputs.release_type }}
- name: Configure git identity
run: |
git config user.name 'Lance Release Bot'
git config user.email 'lance-dev@lancedb.com'
- name: Create release commit (stable releases only)
if: inputs.release_channel == 'stable'
run: |
git add -A
git commit -m "chore: release version ${{ steps.new_version.outputs.version }}"
- name: Create tag
run: |
git tag -a "${{ steps.tag_name.outputs.tag }}" -m "Release ${{ steps.tag_name.outputs.tag }}"
- name: Push changes (if not dry run)
if: ${{ !inputs.dry_run }}
run: |
if [ "${{ inputs.release_channel }}" == "stable" ]; then
# Push the commit for stable releases
git push origin main
fi
# Always push the tag
git push origin "${{ steps.tag_name.outputs.tag }}"
- name: Create GitHub Release (if not dry run)
if: ${{ !inputs.dry_run }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag_name.outputs.tag }}
name: ${{ steps.tag_name.outputs.tag }}
draft: ${{ inputs.draft_release }}
prerelease: ${{ inputs.release_channel == 'preview' }}
generate_release_notes: true
token: ${{ secrets.LANCE_RELEASE_TOKEN }}
- name: Prepare for next development cycle (stable releases only)
if: inputs.release_channel == 'stable' && !inputs.dry_run
run: |
# After a stable release, bump to the next patch version with -dev suffix
# This will be handled in a follow-up PR
echo "Next steps: Create a PR to bump version for next development cycle"
- name: Summary
run: |
echo "## Release Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Release Type:** ${{ inputs.release_type }}" >> $GITHUB_STEP_SUMMARY
echo "- **Release Channel:** ${{ inputs.release_channel }}" >> $GITHUB_STEP_SUMMARY
echo "- **Current Version:** ${{ steps.current_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **New Version:** ${{ steps.new_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Tag:** ${{ steps.tag_name.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "- **Dry Run:** ${{ inputs.dry_run }}" >> $GITHUB_STEP_SUMMARY
if [ "${{ inputs.dry_run }}" == "true" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "⚠️ This was a dry run. No changes were pushed." >> $GITHUB_STEP_SUMMARY
fi