-
-
Notifications
You must be signed in to change notification settings - Fork 7
204 lines (176 loc) · 6.17 KB
/
native-cli.yml
File metadata and controls
204 lines (176 loc) · 6.17 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: Publish Native CLI
on:
push:
branches:
- main
tags:
- v*
workflow_dispatch:
permissions:
contents: write
env:
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
CLI_PROJECT: src/cli/Tiktoken.Cli/Tiktoken.Cli.csproj
jobs:
# Validate install scripts (runs in parallel with builds)
validate-install-sh:
name: Validate install.sh
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Dry-run install.sh
run: bash install.sh --dry-run
validate-install-ps1:
name: Validate install.ps1
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- name: Dry-run install.ps1
shell: pwsh
run: |
$env:TTOK_DRY_RUN = '1'
. ./install.ps1
# Build the pointer (RID-agnostic) NuGet package + CoreCLR fallback
pack-pointer:
name: Pack pointer + any
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
- name: Pack pointer package
run: dotnet pack ${{ env.CLI_PROJECT }} -c Release -o nupkgs
- name: Pack CoreCLR fallback (any)
run: dotnet pack ${{ env.CLI_PROJECT }} -c Release -r any -p:PublishAot=false -o nupkgs
- uses: actions/upload-artifact@v7
with:
name: nupkgs-pointer
path: nupkgs/*.nupkg
# Build NativeAOT RID-specific packages (must run on matching OS)
pack-native:
name: Pack ${{ matrix.rid }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
rid: linux-x64
can-smoke-test: true
- os: ubuntu-latest
rid: linux-musl-x64
can-smoke-test: false
- os: ubuntu-24.04-arm
rid: linux-arm64
can-smoke-test: true
- os: ubuntu-24.04-arm
rid: linux-musl-arm64
can-smoke-test: false
- os: macos-latest
rid: osx-x64
can-smoke-test: false
- os: macos-latest
rid: osx-arm64
can-smoke-test: true
- os: windows-latest
rid: win-x64
can-smoke-test: true
- os: windows-latest
rid: win-arm64
can-smoke-test: false
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
- name: Pack NativeAOT (${{ matrix.rid }})
run: dotnet pack ${{ env.CLI_PROJECT }} -c Release -r ${{ matrix.rid }} -o nupkgs
# Smoke test: verify the AOT binary works (skipped for cross-compiled targets)
- name: Smoke test (Linux/macOS)
if: matrix.can-smoke-test && runner.os != 'Windows'
run: |
echo "Hello world" | src/cli/Tiktoken.Cli/bin/Release/net10.0/${{ matrix.rid }}/publish/Tiktoken.Cli
echo "Hello world" | src/cli/Tiktoken.Cli/bin/Release/net10.0/${{ matrix.rid }}/publish/Tiktoken.Cli | grep -q "3"
- name: Smoke test (Windows)
if: matrix.can-smoke-test && runner.os == 'Windows'
run: |
echo Hello world | src\cli\Tiktoken.Cli\bin\Release\net10.0\${{ matrix.rid }}\publish\Tiktoken.Cli.exe
- name: Codesign binary (macOS)
if: runner.os == 'macOS'
run: codesign --sign - --force src/cli/Tiktoken.Cli/bin/Release/net10.0/${{ matrix.rid }}/publish/Tiktoken.Cli
- name: Prepare release binary (Linux/macOS)
if: runner.os != 'Windows'
run: |
cp src/cli/Tiktoken.Cli/bin/Release/net10.0/${{ matrix.rid }}/publish/Tiktoken.Cli ttok
chmod +x ttok
tar czf ttok-${{ matrix.rid }}.tar.gz ttok
- name: Prepare release binary (Windows)
if: runner.os == 'Windows'
run: |
copy src\cli\Tiktoken.Cli\bin\Release\net10.0\${{ matrix.rid }}\publish\Tiktoken.Cli.exe ttok.exe
Compress-Archive -Path ttok.exe -DestinationPath ttok-${{ matrix.rid }}.zip
- uses: actions/upload-artifact@v7
with:
name: nupkgs-${{ matrix.rid }}
path: nupkgs/*.nupkg
- uses: actions/upload-artifact@v7
with:
name: release-${{ matrix.rid }}
path: ttok-${{ matrix.rid }}.*
# Push NuGet packages (prerelease on main, stable on tags)
publish-nuget:
name: Publish to NuGet
needs: [pack-pointer, pack-native]
runs-on: ubuntu-latest
steps:
- name: Download all nupkgs
uses: actions/download-artifact@v8
with:
pattern: nupkgs-*
merge-multiple: true
path: nupkgs
- name: Push RID-specific packages first
run: |
for pkg in nupkgs/*linux* nupkgs/*osx* nupkgs/*win* nupkgs/*any*; do
[ -f "$pkg" ] && dotnet nuget push "$pkg" --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }}
done
- name: Push pointer package
run: |
for pkg in nupkgs/Tiktoken.Cli.[0-9]*.nupkg; do
[ -f "$pkg" ] && dotnet nuget push "$pkg" --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }}
done
# Create GitHub Release with standalone binaries (only on tags)
release:
name: Create Release
if: startsWith(github.ref, 'refs/tags/v')
needs: pack-native
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Download release artifacts
uses: actions/download-artifact@v8
with:
pattern: release-*
merge-multiple: true
- name: Generate checksums
run: sha256sum ttok-* > checksums-sha256.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
generate_release_notes: true
files: |
ttok-linux-x64.tar.gz
ttok-linux-musl-x64.tar.gz
ttok-linux-arm64.tar.gz
ttok-linux-musl-arm64.tar.gz
ttok-osx-x64.tar.gz
ttok-osx-arm64.tar.gz
ttok-win-x64.zip
ttok-win-arm64.zip
checksums-sha256.txt