forked from lance-format/lance-namespace-impls
-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (171 loc) · 6.84 KB
/
release.yml
File metadata and controls
177 lines (171 loc) · 6.84 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
# 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.
name: Create Release
permissions:
contents: write
on:
workflow_dispatch:
inputs:
release_type:
description: 'Version bump type (patch/minor/major bumps version, current keeps it unchanged)'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
- current
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
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
create-release:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag_name.outputs.tag }}
version: ${{ steps.new_version.outputs.version }}
steps:
- name: Output Inputs
run: echo "${{ toJSON(github.event.inputs) }}"
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: "maven"
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Install python dependencies
run: |
pip install packaging bump-my-version toml
- name: Get current version
id: current_version
run: |
CURRENT_VERSION=$(python -c "import toml; print(toml.load('.bumpversion.toml')['tool']['bumpversion']['current_version'])")
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "Current version: $CURRENT_VERSION"
- name: Calculate new version
id: new_version
run: |
python ci/calculate_version.py \
--current "${{ steps.current_version.outputs.version }}" \
--type "${{ inputs.release_type }}" \
--channel "${{ inputs.release_channel }}"
- 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 with beta suffix
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: Configure git identity
run: |
git config user.name 'Lance Release Bot'
git config user.email 'dev+gha@lance.org'
- name: Update version (stable releases only)
if: inputs.release_channel == 'stable'
run: |
python ci/bump_version.py --version "${{ steps.new_version.outputs.version }}"
git diff
- 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 }}" || echo "No changes to commit"
- 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 Draft (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 }}
generate_release_notes: true
draft: true
prerelease: ${{ inputs.release_channel == 'preview' }}
token: ${{ secrets.GITHUB_TOKEN }}
- 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
if [ "${{ inputs.release_channel }}" == "stable" ]; then
echo "- **New Version:** ${{ steps.new_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
fi
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
else
echo "" >> $GITHUB_STEP_SUMMARY
echo "Draft release created successfully!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Next Steps:" >> $GITHUB_STEP_SUMMARY
echo "1. Review the draft release on the [releases page](https://github.com/${{ github.repository }}/releases)" >> $GITHUB_STEP_SUMMARY
echo "2. Edit the release notes if needed" >> $GITHUB_STEP_SUMMARY
echo "3. Publish the release to:" >> $GITHUB_STEP_SUMMARY
if [ "${{ inputs.release_channel }}" == "stable" ]; then
echo " - Create the official release" >> $GITHUB_STEP_SUMMARY
echo " - Trigger automatic publishing to Maven Central and PyPI" >> $GITHUB_STEP_SUMMARY
else
echo " - Create a preview/beta release" >> $GITHUB_STEP_SUMMARY
echo " - Note: Preview releases are not published to package repositories" >> $GITHUB_STEP_SUMMARY
fi
fi