-
Notifications
You must be signed in to change notification settings - Fork 5
211 lines (188 loc) · 7.44 KB
/
create-release.yml
File metadata and controls
211 lines (188 loc) · 7.44 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
201
202
203
204
205
206
207
208
209
210
211
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright The Lance Authors
name: Create Release
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 (preview creates beta tag, stable creates release tag)'
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
permissions:
contents: write # commit + tag + push
actions: write # gh workflow run release.yml
jobs:
create-release:
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- name: Output Inputs
run: echo "${{ toJSON(github.event.inputs) }}"
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
# persist-credentials defaults to true → git push uses GITHUB_TOKEN.
- uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install cargo-edit
run: cargo install cargo-edit --locked
- name: Get current version
id: current_version
run: |
CURRENT=$(grep '^version = ' Cargo.toml | head -1 | cut -d '"' -f2)
echo "version=$CURRENT" >>"$GITHUB_OUTPUT"
echo "Current version: $CURRENT"
- name: Calculate base version
id: base_version
run: |
CURRENT="${{ steps.current_version.outputs.version }}"
# Strip any pre-release suffix (e.g. "0.1.0-beta.3" -> "0.1.0")
BASE_CURRENT="${CURRENT%%-*}"
IFS='.' read -r MAJOR MINOR PATCH <<<"$BASE_CURRENT"
case "${{ inputs.release_type }}" in
major)
MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0
;;
minor)
MINOR=$((MINOR + 1)); PATCH=0
;;
patch)
PATCH=$((PATCH + 1))
;;
current)
# Keep the base version unchanged; useful for cutting another beta
# against the same base (e.g. v0.2.0-beta.2 after v0.2.0-beta.1).
;;
*)
echo "Unknown release_type: ${{ inputs.release_type }}" >&2
exit 1
;;
esac
BASE="${MAJOR}.${MINOR}.${PATCH}"
echo "version=$BASE" >>"$GITHUB_OUTPUT"
echo "Base version: $BASE"
- name: Determine tag and crate version
id: versions
run: |
BASE_VERSION="${{ steps.base_version.outputs.version }}"
CURRENT_VERSION="${{ steps.current_version.outputs.version }}"
if [ "${{ inputs.release_channel }}" = "stable" ]; then
TAG="v${BASE_VERSION}"
CRATE_VERSION="${BASE_VERSION}"
else
# For preview releases, find the next beta number for this base version
BETA_TAGS=$(git tag -l "v${BASE_VERSION}-beta.*" | sort -V)
if [ -z "$BETA_TAGS" ]; then
BETA_NUM=1
else
LAST_BETA=$(echo "$BETA_TAGS" | tail -n 1)
PREFIX="v${BASE_VERSION}-beta."
LAST_NUM="${LAST_BETA#"$PREFIX"}"
BETA_NUM=$((LAST_NUM + 1))
fi
TAG="v${BASE_VERSION}-beta.${BETA_NUM}"
CRATE_VERSION="${BASE_VERSION}-beta.${BETA_NUM}"
fi
if [ "$CURRENT_VERSION" != "$CRATE_VERSION" ]; then
VERSION_CHANGED="true"
else
VERSION_CHANGED="false"
fi
# Refuse to push if the tag already exists.
if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then
echo "Tag $TAG already exists; aborting." >&2
exit 1
fi
{
echo "tag=$TAG"
echo "crate_version=$CRATE_VERSION"
echo "version_changed=$VERSION_CHANGED"
} >>"$GITHUB_OUTPUT"
echo "Tag will be: $TAG"
echo "Crate version will be: $CRATE_VERSION"
echo "Version changed: $VERSION_CHANGED"
- name: Update Cargo.toml + Cargo.lock
if: steps.versions.outputs.version_changed == 'true'
run: |
cargo set-version --package lance-c "${{ steps.versions.outputs.crate_version }}"
- name: Configure git identity
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Create release commit
if: steps.versions.outputs.version_changed == 'true'
run: |
git add Cargo.toml Cargo.lock
git commit -m "chore: bump version to ${{ steps.versions.outputs.crate_version }}"
- name: Create tag
run: |
git tag -a "${{ steps.versions.outputs.tag }}" \
-m "Release ${{ steps.versions.outputs.tag }}"
- name: Push commit + tag (if not dry run)
if: ${{ !inputs.dry_run }}
run: |
if [ "${{ steps.versions.outputs.version_changed }}" = "true" ]; then
git push origin main
fi
git push origin "${{ steps.versions.outputs.tag }}"
# GITHUB_TOKEN-pushed refs do NOT trigger downstream workflows
# (GitHub's recursion guard). We dispatch the Release workflow at the
# new tag's ref so its publish job (gated on refs/tags/v*) can fire.
- name: Trigger Release workflow on the new tag
if: ${{ !inputs.dry_run }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh workflow run release.yml \
--ref "${{ steps.versions.outputs.tag }}" \
-f version="${{ steps.versions.outputs.crate_version }}"
- name: Summary
run: |
{
echo "## Release Summary"
echo ""
echo "- **Release Type:** ${{ inputs.release_type }}"
echo "- **Release Channel:** ${{ inputs.release_channel }}"
echo "- **Current Version:** ${{ steps.current_version.outputs.version }}"
if [ "${{ steps.versions.outputs.version_changed }}" = "true" ]; then
echo "- **New Version:** ${{ steps.versions.outputs.crate_version }}"
fi
echo "- **Tag:** ${{ steps.versions.outputs.tag }}"
echo "- **Dry Run:** ${{ inputs.dry_run }}"
} >>"$GITHUB_STEP_SUMMARY"
if [ "${{ inputs.dry_run }}" = "true" ]; then
{
echo ""
echo "⚠️ This was a dry run. No commits, tags, or releases were pushed."
} >>"$GITHUB_STEP_SUMMARY"
else
{
echo ""
echo "✅ Tag pushed and Release workflow dispatched."
echo ""
echo "### Next Steps:"
echo "1. Watch the [Release workflow](https://github.com/${{ github.repository }}/actions/workflows/release.yml) finish (~20 min)."
echo "2. Verify the published assets at the [release page](https://github.com/${{ github.repository }}/releases/tag/${{ steps.versions.outputs.tag }})."
echo "3. Copy the SHA512 snippet from the publish job log into vcpkg/conan recipes."
} >>"$GITHUB_STEP_SUMMARY"
fi