-
Notifications
You must be signed in to change notification settings - Fork 10
570 lines (498 loc) · 25.3 KB
/
execute-release.yml
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
name: Execute Release
on:
repository_dispatch:
types:
- execute-release
env:
CARGO_TERM_COLOR: always
APP_NAME: 'momento-cli'
MAINTAINER: 'momentohq'
DESC: 'Official CLI for Momento Serverless Cache'
jobs:
release:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.release.outputs.release }}
steps:
- uses: actions/checkout@v4
- name: semrel release
id: semrel
uses: go-semantic-release/action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
allow-initial-development-versions: true
force-bump-patch-version: true
# For whatever reason, this silly tool won't let you do releases from branches
# other than the default branch unless you pass this flag, which doesn't seem
# to actually have anything to do with CI:
# https://github.com/go-semantic-release/semantic-release/blob/master/cmd/semantic-release/main.go#L173-L194
# https://github.com/go-semantic-release/condition-github/blob/4c8af3fc516151423fff2f77eb08bf7082570676/pkg/condition/github.go#L42-L44
custom-arguments: "--no-ci"
- name: Build tar.gz
run: |
STASH_SHA=$(git stash create)
VERSION=${{ steps.semrel.outputs.version }}
ARCHIVE_FILE=archive-$VERSION.tar.gz
echo "ARCHIVE_FILE="$ARCHIVE_FILE >> $GITHUB_ENV
pip install git-archive-all
git-archive-all $ARCHIVE_FILE
SHA=$(openssl sha256 < ${ARCHIVE_FILE} | sed 's/.* //')
echo "SHA="$SHA >> $GITHUB_ENV
echo "sha is: ${SHA}"
AUTH="Authorization: token ${{ secrets.MOMENTO_MACHINE_USER_GITHUB_TOKEN }}"
LATEST_RELEASE=$(curl -sH "$AUTH" https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/v${VERSION})
RELEASE_ID=$(echo $LATEST_RELEASE | jq -r .id)
GH_ASSET="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${ARCHIVE_FILE}"
echo $GH_ASSET
curl --data-binary @$ARCHIVE_FILE -H "$AUTH" -H "Content-Type: application/octet-stream" $GH_ASSET
shell: bash
- name: Output release
id: release
run: echo "release=${{ steps.semrel.outputs.version }}" >> $GITHUB_OUTPUT
publish-linux-assets:
runs-on: ubuntu-latest
needs: [ release ]
strategy:
matrix:
architecture:
- { target: aarch64-unknown-linux-gnu, rpm-arch-shortname: aarch64, deb-arch-shortname: arm64, os: ubuntu-20.04, use-cross: true }
- { target: x86_64-unknown-linux-gnu, rpm-arch-shortname: x86_64, deb-arch-shortname: amd64, os: ubuntu-20.04, use-cross: true }
steps:
- uses: actions/checkout@v4
- name: Install protoc
run: ./scripts/install_protoc_linux.sh
- name: Install prerequisites
shell: bash
run: |
case ${{ matrix.architecture.target }} in
aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
esac
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.architecture.target }}
override: true
profile: minimal # minimal component installation (ie, no documentation)
- name: Show version information (Rust, cargo, GCC)
shell: bash
run: |
gcc --version || true
rustup -V
rustup toolchain list
rustup default
cargo -V
rustc -V
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.architecture.use-cross }}
command: build
args: --locked --release --target=${{ matrix.architecture.target }}
- name: Inspect Build
run: |
ls target
ls target/release
shell: bash
- name: Build tar.gz and publish asset
run: |
VERSION=${{ needs.release.outputs.version }}
ARCHIVE_FILE="momento-cli-$VERSION.linux_${{ matrix.architecture.rpm-arch-shortname }}.tar.gz"
BUILD_OUTPUT_DIR="./target/${{ matrix.architecture.target }}/release/"
mkdir $BUILD_OUTPUT_DIR/bash
cp $BUILD_OUTPUT_DIR/momento.bash $BUILD_OUTPUT_DIR/bash/momento
mkdir $BUILD_OUTPUT_DIR/zsh
cp $BUILD_OUTPUT_DIR/_momento $BUILD_OUTPUT_DIR/zsh/_momento
tar -C ./target/${{ matrix.architecture.target }}/release/ -zcvf $ARCHIVE_FILE momento bash/ zsh/
AUTH="Authorization: token ${{ secrets.MOMENTO_MACHINE_USER_GITHUB_TOKEN }}"
LATEST_RELEASE=$(curl -sH "$AUTH" https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/v${VERSION})
RELEASE_ID=$(echo $LATEST_RELEASE | jq -r .id)
GH_ASSET="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${ARCHIVE_FILE}"
echo $GH_ASSET
curl --data-binary @$ARCHIVE_FILE -H "$AUTH" -H "Content-Type: application/octet-stream" $GH_ASSET
shell: bash
- name: Install nfpm to build rpm and deb
run: |
echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list
sudo apt update
sudo apt install nfpm
shell: bash
- name: Update nfpm package config for rpms
run: |
export MOMENTO_VERSION=${{ needs.release.outputs.version }}
export MOMENTO_ARCH=${{ matrix.architecture.rpm-arch-shortname }}
export BUILD_OUTPUT_DIR=./target/${{ matrix.architecture.target }}/release
export MOMENTO_BINARY=$BUILD_OUTPUT_DIR/momento
export MOMENTO_BASH_COMPLETION=$BUILD_OUTPUT_DIR/bash/momento
export MOMENTO_ZSH_COMPLETION=$BUILD_OUTPUT_DIR/zsh/_momento
cat nfpm.template.yaml |envsubst \$MOMENTO_VERSION |envsubst \$MOMENTO_ARCH |envsubst \$MOMENTO_BINARY |envsubst \$MOMENTO_BASH_COMPLETION |envsubst \$MOMENTO_ZSH_COMPLETION > nfpm.yaml
cat nfpm.yaml
shell: bash
- name: Build and publish rpm via nfpm
run: |
nfpm pkg --packager rpm
VERSION=${{ needs.release.outputs.version }}
BINARY_FILE="${{ env.APP_NAME }}-$VERSION-1.${{ matrix.architecture.rpm-arch-shortname }}.rpm"
[ -e $BINARY_FILE ] || { echo "Expected rpm output file not found!: '${BINARY_FILE}'"; exit 1; }
AUTH="Authorization: token ${{ secrets.MOMENTO_MACHINE_USER_GITHUB_TOKEN }}"
LATEST_RELEASE=$(curl -sH "$AUTH" https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/v${VERSION})
RELEASE_ID=$(echo $LATEST_RELEASE | jq -r .id)
GH_ASSET="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${BINARY_FILE}"
echo $GH_ASSET
curl --data-binary @$BINARY_FILE -H "$AUTH" -H "Content-Type: application/octet-stream" $GH_ASSET
- name: Update nfpm package config for debs
run: |
export MOMENTO_VERSION=${{ needs.release.outputs.version }}
export MOMENTO_ARCH=${{ matrix.architecture.deb-arch-shortname }}
export BUILD_OUTPUT_DIR=./target/${{ matrix.architecture.target }}/release
export MOMENTO_BINARY=$BUILD_OUTPUT_DIR/momento
export MOMENTO_BASH_COMPLETION=$BUILD_OUTPUT_DIR/bash/momento
export MOMENTO_ZSH_COMPLETION=$BUILD_OUTPUT_DIR/zsh/_momento
cat nfpm.template.yaml |envsubst \$MOMENTO_VERSION |envsubst \$MOMENTO_ARCH |envsubst \$MOMENTO_BINARY |envsubst \$MOMENTO_BASH_COMPLETION |envsubst \$MOMENTO_ZSH_COMPLETION > nfpm.yaml
cat nfpm.yaml
shell: bash
- name: Build and publish deb via nfpm
run: |
nfpm pkg --packager deb
VERSION=${{ needs.release.outputs.version }}
BINARY_FILE="${{ env.APP_NAME }}_${VERSION}_${{ matrix.architecture.deb-arch-shortname }}.deb"
[ -e $BINARY_FILE ] || { echo "Expected deb output file not found!: '${BINARY_FILE}'"; exit 1; }
AUTH="Authorization: token ${{ secrets.MOMENTO_MACHINE_USER_GITHUB_TOKEN }}"
LATEST_RELEASE=$(curl -sH "$AUTH" https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/v${VERSION})
RELEASE_ID=$(echo $LATEST_RELEASE | jq -r .id)
GH_ASSET="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${BINARY_FILE}"
echo $GH_ASSET
curl --data-binary @$BINARY_FILE -H "$AUTH" -H "Content-Type: application/octet-stream" $GH_ASSET
publish-mac-assets:
runs-on: macos-latest
needs: [ release ]
strategy:
matrix:
architecture:
- { target: x86_64-apple-darwin, use-cross: false }
- { target: aarch64-apple-darwin, use-cross: true }
steps:
- uses: actions/checkout@v4
- name: Install protoc
run: ./scripts/install_protoc_osx.sh
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.architecture.target }}
override: true
profile: minimal # minimal component installation (ie, no documentation)
- name: Show version information (Rust, cargo, GCC)
shell: bash
run: |
gcc --version || true
rustup -V
rustup toolchain list
rustup default
cargo -V
rustc -V
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.architecture.use-cross }}
command: build
args: --locked --release --target=${{ matrix.architecture.target }}
- name: Inspect Build
run: |
ls target
ls target/release
shell: bash
- name: Build tar.gz and publish asset
run: |
VERSION=${{ needs.release.outputs.version }}
ARCHIVE_FILE="momento-cli-$VERSION.${{ matrix.architecture.target }}.tar.gz"
BUILD_OUTPUT_DIR="./target/${{ matrix.architecture.target }}/release/"
mkdir $BUILD_OUTPUT_DIR/bash
cp $BUILD_OUTPUT_DIR/momento.bash $BUILD_OUTPUT_DIR/bash/momento
mkdir $BUILD_OUTPUT_DIR/zsh
cp $BUILD_OUTPUT_DIR/_momento $BUILD_OUTPUT_DIR/zsh/_momento
tar -C $BUILD_OUTPUT_DIR -zcvf $ARCHIVE_FILE momento bash/ zsh/
AUTH="Authorization: token ${{ secrets.MOMENTO_MACHINE_USER_GITHUB_TOKEN }}"
LATEST_RELEASE=$(curl -sH "$AUTH" https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/v${VERSION})
RELEASE_ID=$(echo $LATEST_RELEASE | jq -r .id)
GH_ASSET="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${ARCHIVE_FILE}"
echo $GH_ASSET
curl --data-binary @$ARCHIVE_FILE -H "$AUTH" -H "Content-Type: application/octet-stream" $GH_ASSET
shell: bash
publish-windows-assets:
runs-on: windows-latest
needs: [release]
outputs:
msi_filename: ${{ steps.build_installer.outputs.asset_name }}
steps:
- uses: actions/checkout@v4
- name: Install protoc
run: choco install protoc
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt
override: true
- name: Show Cargo Version
run: |
cat Cargo.toml
shell: bash
- name: Build
id: build
env:
VERSION: ${{ needs.release.outputs.version }}
run: |
rustup target add x86_64-pc-windows-gnu
cargo build --release --target x86_64-pc-windows-gnu
echo "momento_binary_path=.\target\x86_64-pc-windows-gnu\release\momento.exe" >> $ENV:GITHUB_OUTPUT
$distributableFile64Prefix = "momento-cli-$env:VERSION.windows_x64"
echo "distributable_file_prefix=$distributableFile64Prefix" >> $ENV:GITHUB_OUTPUT
- name: Write client auth certificate file
id: write_client_auth_cert
env:
CLIENT_AUTH_CERT_BASE64_CONTENT: ${{ secrets.CODE_SIGNING_CERT_BASE64 }}
run: |
$p12Path = "cert.p12";
$encodedBytes = [System.Convert]::FromBase64String($env:CLIENT_AUTH_CERT_BASE64_CONTENT);
Set-Content $p12Path -Value $encodedBytes -AsByteStream;
echo "p12_path=$p12Path" >> $ENV:GITHUB_OUTPUT
- name: Download digicert smtools
env:
SM_API_KEY: ${{ secrets.CODE_SIGNING_API_KEY }}
run: |
curl -X GET https://one.digicert.com/signingmanager/api-ui/v1/releases/smtools-windows-x64.msi/download -H "x-api-key:%SM_API_KEY%" -o smtools-windows-x64.msi
shell: cmd
- name: Install digicert smtools
run: |
$procMain = Start-Process "msiexec" "/i smtools-windows-x64.msi /qn /l*! msi_install.log" -NoNewWindow -PassThru
echo $null >> msi_install.log
$procLog = Start-Process "powershell" "Get-Content -Path msi_install.log -Wait" -NoNewWindow -PassThru
$procMain.WaitForExit()
$procLog.Kill()
shell: powershell
- name: Add digicert tools to path
run: |
echo "C:\Program Files (x86)\Windows Kits\10\App Certification Kit" >> $GITHUB_PATH
echo "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools" >> $GITHUB_PATH
echo "C:\Program Files\DigiCert\DigiCert One Signing Manager Tools" >> $GITHUB_PATH
shell: bash
- name: Check path
run: |
echo %path%
shell: cmd
- name: List digicert dir
run: |
dir "C:\Program Files\DigiCert\DigiCert One Signing Manager Tools"
shell: cmd
- name: Verify KSP Registration
env:
SM_HOST: ${{ secrets.CODE_SIGNING_HOST }}
SM_API_KEY: ${{ secrets.CODE_SIGNING_API_KEY }}
SM_CLIENT_CERT_FILE: "${{ steps.write_client_auth_cert.outputs.p12_path }}"
SM_CLIENT_CERT_PASSWORD: ${{ secrets.CODE_SIGNING_CERT_PASSWORD }}
run: |
dir
smksp_registrar.exe list
smctl.exe keypair ls
C:\Windows\System32\certutil.exe -csp "DigiCert Signing Manager KSP" -key -user
smksp_cert_sync.exe
smctl healthcheck
shell: cmd
- name: Sign Momento binary
env:
MOMENTO_BINARY_PATH: ${{ steps.build.outputs.momento_binary_path }}
SM_HOST: ${{ secrets.CODE_SIGNING_HOST }}
SM_API_KEY: ${{ secrets.CODE_SIGNING_API_KEY }}
SM_CLIENT_CERT_FILE: "${{ steps.write_client_auth_cert.outputs.p12_path }}"
SM_CLIENT_CERT_PASSWORD: ${{ secrets.CODE_SIGNING_CERT_PASSWORD }}
run: |
signtool.exe sign /sha1 ${{ secrets.CODE_SIGNING_CERT_SHA1_HASH }} /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 $env:MOMENTO_BINARY_PATH
signtool.exe verify /v /pa $env:MOMENTO_BINARY_PATH
- name: Create zip
id: create_zip
env:
MOMENTO_BINARY_PATH: ${{ steps.build.outputs.momento_binary_path }}
DISTRIBUTABLE_FILE_PREFIX: ${{ steps.build.outputs.distributable_file_prefix }}
run: |
$zipFilename = "$env:DISTRIBUTABLE_FILE_PREFIX.zip"
$zipPath = ".\$zipFilename"
Compress-Archive -LiteralPath $env:MOMENTO_BINARY_PATH -DestinationPath $zipPath
echo "asset_path=$zipPath" >> $ENV:GITHUB_OUTPUT
echo "asset_name=$zipFilename" >> $ENV:GITHUB_OUTPUT
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
- name: Build installer
id: build_installer
env:
MOMENTO_BINARY_PATH: ${{ steps.build.outputs.momento_binary_path }}
DISTRIBUTABLE_FILE_PREFIX: ${{ steps.build.outputs.distributable_file_prefix }}
VERSION: ${{ needs.release.outputs.version }}
run: |
cp $env:MOMENTO_BINARY_PATH .\windows\installer
$env:BuildVersion = "$env:VERSION"
msbuild .\windows\installer\MomentoCLI.wixproj /p:Configuration=Release /p:OutputName=$env:DISTRIBUTABLE_FILE_PREFIX
$msiFilename = "$env:DISTRIBUTABLE_FILE_PREFIX.msi"
$msiPath = ".\windows\installer\bin\Release\$msiFilename"
echo "asset_path=$msiPath" >> $ENV:GITHUB_OUTPUT
echo "asset_name=$msiFilename" >> $ENV:GITHUB_OUTPUT
- name: Sign installer
env:
MSI_PATH: ${{ steps.build_installer.outputs.asset_path }}
SM_HOST: ${{ secrets.CODE_SIGNING_HOST }}
SM_API_KEY: ${{ secrets.CODE_SIGNING_API_KEY }}
SM_CLIENT_CERT_FILE: "${{ steps.write_client_auth_cert.outputs.p12_path }}"
SM_CLIENT_CERT_PASSWORD: ${{ secrets.CODE_SIGNING_CERT_PASSWORD }}
run: |
signtool.exe sign /sha1 ${{ secrets.CODE_SIGNING_CERT_SHA1_HASH }} /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 $env:MSI_PATH
signtool.exe verify /v /pa $env:MSI_PATH
- name: Delete PFX certificate
env:
CERT_PATH: "${{ steps.write_client_auth_cert.outputs.p12_path }}"
run: Remove-Item -Path $env:CERT_PATH
- name: Create zip and installer urls
id: create_release_urls
env:
VERSION: ${{ needs.release.outputs.version }}
ZIP_FILENAME: ${{ steps.create_zip.outputs.asset_name }}
MSI_FILENAME: ${{ steps.build_installer.outputs.asset_name }}
run: |
$latestReleaseUri = "https://api.github.com/repos/momentohq/momento-cli/releases/tags/v$env:VERSION"
$latestRelease = (Invoke-WebRequest -Uri $latestReleaseUri -Method Get -Headers @{'authorization' = 'Bearer ${{ secrets.GITHUB_TOKEN }}' } | Select-Object -Property Content).Content
$releaseId = $latestRelease | jq -r .id
$ghAssetMsi = "https://uploads.github.com/repos/momentohq/momento-cli/releases/$releaseId/assets?name=$env:MSI_FILENAME"
$ghAssetZip = "https://uploads.github.com/repos/momentohq/momento-cli/releases/$releaseId/assets?name=$env:ZIP_FILENAME"
echo "upload_url_msi=$ghAssetMsi" >> $ENV:GITHUB_OUTPUT
echo "upload_url_zip=$ghAssetZip" >> $ENV:GITHUB_OUTPUT
- name: Upload windows_x64 msi
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release_urls.outputs.upload_url_msi }}
asset_path: ${{ steps.build_installer.outputs.asset_path }}
asset_name: ${{ steps.build_installer.outputs.asset_name }}
asset_content_type: application/octet-stream
- name: Upload windows_x64 zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release_urls.outputs.upload_url_zip }}
asset_path: ${{ steps.create_zip.outputs.asset_path }}
asset_name: ${{ steps.create_zip.outputs.asset_name }}
asset_content_type: application/zip
# Commenting out building i686 since the machine doesn't seem to have i686-w64-mingw32-gcc.exe compiler installed by default.
# Come back and work on this when customers ask 32-bit build.
#
# - name: Add mingw32 to path
# shell: bash
# run: |
# echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH
# - name: Build zip for windows_i686 and create release
# id: create_release_32
# run: |
# $env:Version = "${{ needs.release.outputs.version }}"
# $env:BinaryFile32 = "momento-cli-" + $env:VERSION + ".windows_i686.zip"
# rustup target add i686-pc-windows-gnu
# cargo build --release --target i686-pc-windows-gnu
# $env:CurrentDir = Get-Location
# $env:LiteralPath = $env:CurrentDir + "\target\i686-pc-windows-gnu\release\momento.exe"
# $env:DestinationPath = $env:CurrentDir + "\" + $env:BinaryFile32
# Compress-Archive -LiteralPath $env:LiteralPath -DestinationPath $env:DestinationPath
# $env:LatestReleaseUri = "https://api.github.com/repos/momentohq/momento-cli/releases/tags/v" + $env:Version
# $env:LatestReleaseUri
# $env:LatestRelease = (Invoke-WebRequest -Uri $env:LatestReleaseUri -Method Get | Select-Object -Property Content).Content
# $env:ReleaseId = $env:LatestRelease | jq -r .id
# $GhAsset32 = "https://uploads.github.com/repos/momentohq/momento-cli/releases/" + $env:ReleaseId + "/assets?name=" + $env:BinaryFile32
# $GhAsset32
# echo "::set-output name=upload_url::$GhAsset32"
# echo "::set-output name=asset_path::$env:DestinationPath"
# echo "::set-output name=asset_name::$env:BinaryFile32"
# - name: Upload windows_i686 zip
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release_32.outputs.upload_url }}
# asset_path: ${{ steps.create_release_32.outputs.asset_path }}
# asset_name: ${{ steps.create_release_32.outputs.asset_name }}
# asset_content_type: application/zip
update-winget-package-manager:
runs-on: windows-latest
needs: [ release, publish-windows-assets ]
steps:
- name: Download winget
run: iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
- name: Build installer URL
id: build_installer_url
env:
VERSION: ${{ needs.release.outputs.version }}
MSI_FILENAME: ${{ needs.publish-windows-assets.outputs.msi_filename }}
run: |
$installerUrl = "https://github.com/momentohq/momento-cli/releases/download/v$env:VERSION/$env:MSI_FILENAME"
echo "installer_url=$installerUrl" >> $ENV:GITHUB_OUTPUT
- name: Open PR on WinGet
env:
INSTALLER_URL: ${{ steps.build_installer_url.outputs.installer_url }}
VERSION: ${{ needs.release.outputs.version }}
GITHUB_TOKEN: ${{ secrets.MOMENTO_MACHINE_USER_GITHUB_TOKEN }}
run: .\wingetcreate.exe update momento.cli -s -v $env:VERSION -u $env:INSTALLER_URL -t $env:GITHUB_TOKEN
update-homebrew-formula:
runs-on: ubuntu-latest
needs: [ release, publish-linux-assets, publish-mac-assets ]
steps:
- name: Check out homebrew-tap
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: momentohq/homebrew-tap
token: ${{ secrets.MOMENTO_MACHINE_USER_GITHUB_TOKEN }}
- name: update homebrew formulae
run: |
export MOMENTO_CLI_VERSION=${{ needs.release.outputs.version }}
echo "Version is $MOMENTO_CLI_VERSION"
git checkout -b formula/momento-cli/v${MOMENTO_CLI_VERSION}
export MOMENTO_CLI_LINUX_X86_64_URL="https://github.com/momentohq/momento-cli/releases/download/v${MOMENTO_CLI_VERSION}/momento-cli-${MOMENTO_CLI_VERSION}.linux_x86_64.tar.gz"
export MOMENTO_CLI_LINUX_AARCH64_URL="https://github.com/momentohq/momento-cli/releases/download/v${MOMENTO_CLI_VERSION}/momento-cli-${MOMENTO_CLI_VERSION}.linux_aarch64.tar.gz"
export MOMENTO_CLI_MAC_X86_64_URL="https://github.com/momentohq/momento-cli/releases/download/v${MOMENTO_CLI_VERSION}/momento-cli-${MOMENTO_CLI_VERSION}.x86_64-apple-darwin.tar.gz"
export MOMENTO_CLI_MAC_AARCH64_URL="https://github.com/momentohq/momento-cli/releases/download/v${MOMENTO_CLI_VERSION}/momento-cli-${MOMENTO_CLI_VERSION}.aarch64-apple-darwin.tar.gz"
echo "Downloading and computing SHA for ${MOMENTO_CLI_LINUX_X86_64_URL}"
wget ${MOMENTO_CLI_LINUX_X86_64_URL} -O linux-x86_64.tgz
export MOMENTO_CLI_LINUX_X86_64_SHA=$(shasum -a 256 linux-x86_64.tgz | awk '{print $1}')
rm linux-x86_64.tgz
echo "Downloading and computing SHA for ${MOMENTO_CLI_LINUX_AARCH64_URL}"
wget ${MOMENTO_CLI_LINUX_AARCH64_URL} -O linux-aarch64.tgz
export MOMENTO_CLI_LINUX_AARCH64_SHA=$(shasum -a 256 linux-aarch64.tgz | awk '{print $1}')
rm linux-aarch64.tgz
echo "Downloading and computing SHA for ${MOMENTO_CLI_MAC_X86_64_URL}"
wget ${MOMENTO_CLI_MAC_X86_64_URL} -O mac-x86_64.tgz
export MOMENTO_CLI_MAC_X86_64_SHA=$(shasum -a 256 mac-x86_64.tgz | awk '{print $1}')
rm mac-x86_64.tgz
echo "Downloading and computing SHA for ${MOMENTO_CLI_MAC_AARCH64_URL}"
wget ${MOMENTO_CLI_MAC_AARCH64_URL} -O mac-aarch64.tgz
export MOMENTO_CLI_MAC_AARCH64_SHA=$(shasum -a 256 mac-aarch64.tgz | awk '{print $1}')
rm mac-aarch64.tgz
pushd Formula
cat momento-cli.rb.template \
| envsubst \$MOMENTO_CLI_VERSION \
| envsubst \$MOMENTO_CLI_LINUX_X86_64_URL \
| envsubst \$MOMENTO_CLI_LINUX_X86_64_SHA \
| envsubst \$MOMENTO_CLI_LINUX_AARCH64_URL \
| envsubst \$MOMENTO_CLI_LINUX_AARCH64_SHA \
| envsubst \$MOMENTO_CLI_MAC_X86_64_URL \
| envsubst \$MOMENTO_CLI_MAC_X86_64_SHA \
| envsubst \$MOMENTO_CLI_MAC_AARCH64_URL \
| envsubst \$MOMENTO_CLI_MAC_AARCH64_SHA \
> momento-cli.rb
cat momento-cli.rb
popd
git config user.email "momentobot@users.noreply.github.com"
git config user.name "momentobot"
git add .
git commit -m "momento-cli ${MOMENTO_CLI_VERSION}"
git push origin formula/momento-cli/v${MOMENTO_CLI_VERSION}
shell: bash