Repository navigation
203 lines (170 loc) · 5.91 KB
/
Copy pathrust-runtime-release.yml
File metadata and controls
203 lines (170 loc) · 5.91 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
name: Rust Runtime Release
on:
workflow_dispatch:
inputs:
publish_crate:
description: "Publish the Rust crate when CARGO_REGISTRY_TOKEN is available"
required: false
default: false
type: boolean
create_github_release:
description: "Create or update a GitHub release with CLI artifacts"
required: false
default: false
type: boolean
push:
tags:
- "sqlctx-rs-v*"
- "rust-runtime-v*"
pull_request:
paths:
- ".github/actions/**"
- ".github/workflows/rust-runtime-release.yml"
- "sqlctx-rs/tests/packaged_cli_smoke.py"
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
package:
name: Check crate package
runs-on: ubuntu-latest
defaults:
run:
working-directory: sqlctx-rs
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust compilation
if: github.event_name == 'pull_request'
id: rust-cache
uses: ./.github/actions/setup-rust-cache
with:
suffix: ${{ github.workflow }}-${{ github.job }}-${{ strategy.job-index || 0 }}
- name: Run package metadata tests
run: cargo test --locked --test package_metadata
- name: Check package contents
run: cargo package --locked --no-verify
- name: Check publish dry run
run: cargo publish --locked --dry-run
- name: Publish crate
if: ${{ github.event_name == 'workflow_dispatch' && inputs.publish_crate == true }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
if [ -z "$CARGO_REGISTRY_TOKEN" ]; then
echo "Skipping cargo publish because CARGO_REGISTRY_TOKEN is not configured."
exit 0
fi
cargo publish --locked
- name: Save completed build caches
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
uses: ./.github/actions/save-build-caches
with:
rust-key: ${{ steps.rust-cache.outputs.key }}
cli-artifacts:
name: Build CLI artifact (${{ matrix.artifact }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
artifact: linux-x86_64
- os: macos-15-intel
artifact: macos-x86_64
- os: macos-14
artifact: macos-arm64
- os: windows-latest
artifact: windows-x86_64
defaults:
run:
working-directory: sqlctx-rs
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust compilation
if: github.event_name == 'pull_request'
id: rust-cache
uses: ./.github/actions/setup-rust-cache
with:
suffix: ${{ github.workflow }}-${{ github.job }}-${{ strategy.job-index || 0 }}
- name: Build CLI
run: cargo build --release --locked --bin sqlctx
- name: Package CLI artifact
shell: bash
run: |
mkdir -p dist
if [ "$RUNNER_OS" = "Windows" ]; then
cp ../target/release/sqlctx.exe "dist/sqlctx-${{ matrix.artifact }}.exe"
else
cp ../target/release/sqlctx "dist/sqlctx-${{ matrix.artifact }}"
tar -czf "dist/sqlctx-${{ matrix.artifact }}.tar.gz" -C dist "sqlctx-${{ matrix.artifact }}"
fi
- name: Install uv
id: uv
uses: ./.github/actions/setup-uv
with:
enable-cache: ${{ github.event_name == 'pull_request' }}
suffix: ${{ github.workflow }}-${{ github.job }}-${{ strategy.job-index || 0 }}
- name: Smoke packaged CLI
shell: bash
run: |
if [ "$RUNNER_OS" = "Windows" ]; then
uv run --no-project tests/packaged_cli_smoke.py dist/sqlctx-${{ matrix.artifact }}.exe
else
mkdir -p dist/smoke
tar -xzf dist/sqlctx-${{ matrix.artifact }}.tar.gz -C dist/smoke
uv run --no-project tests/packaged_cli_smoke.py dist/smoke/sqlctx-${{ matrix.artifact }}
rm -r dist/smoke
fi
- name: Upload CLI artifact
uses: actions/upload-artifact@v4
with:
name: sqlctx-cli-${{ matrix.artifact }}
path: sqlctx-rs/dist/*
if-no-files-found: error
- name: Save completed build caches
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
uses: ./.github/actions/save-build-caches
with:
rust-key: ${{ steps.rust-cache.outputs.key }}
uv-key: ${{ steps.uv.outputs.cache-key }}
github-release:
name: Attach CLI artifacts to GitHub release
needs:
- package
- cli-artifacts
if: ${{ startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.create_github_release == true) }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download CLI artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Resolve release tag
id: release
run: |
if [ "${{ github.ref_type }}" = "tag" ]; then
TAG="${{ github.ref_name }}"
else
VERSION=$(grep '^version = ' sqlctx-rs/Cargo.toml | sed 's/version = "\(.*\)"/\1/')
TAG="sqlctx-rs-v${VERSION}"
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
- name: Create or update GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${{ steps.release.outputs.tag }}"
if gh release view "$TAG" >/dev/null 2>&1; then
gh release upload "$TAG" dist/* --clobber
else
gh release create "$TAG" dist/* --title "$TAG" --generate-notes
fi