Skip to content

Commit ed11c7b

Browse files
committed
update installation script further, allow passing bundle for cqlsh, and resolve #254
1 parent a3d18f5 commit ed11c7b

File tree

12 files changed

+366
-48
lines changed

12 files changed

+366
-48
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
name: build.yml
22
on:
33
workflow_call:
4+
inputs: &workflow-inputs
5+
upload-artifacts:
6+
description: 'Upload build artifacts'
7+
required: false
8+
type: boolean
9+
default: true
10+
build-all-platforms:
11+
description: 'Build for all platforms'
12+
required: false
13+
type: boolean
14+
default: false
415
workflow_dispatch:
16+
inputs: *workflow-inputs
517
push:
618
branches: [ main ]
719

820
jobs:
921
build:
1022
strategy:
1123
matrix:
12-
os: [ ubuntu-24.04, windows-2022, ubuntu-24.04-arm, macos-15-intel, macos-14 ]
24+
os: ${{ inputs.build-all-platforms == true && fromJSON('["ubuntu-24.04", "windows-2022", "ubuntu-24.04-arm", "macos-15-intel", "macos-14"]') || fromJSON('["ubuntu-24.04"]') }}
1325
include:
1426
- os: ubuntu-24.04
1527
artifact-name: astra-cli-linux-x86_64
@@ -28,7 +40,7 @@ jobs:
2840
artifact-type: tar
2941

3042
runs-on: ${{ matrix.os }}
31-
43+
3244
steps:
3345
- uses: actions/checkout@v4
3446

@@ -44,6 +56,7 @@ jobs:
4456
uses: gradle/actions/setup-gradle@v4
4557
with:
4658
gradle-version: wrapper
59+
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
4760

4861
- name: Build and package native image (tar)
4962
if: matrix.artifact-type == 'tar'
@@ -54,9 +67,10 @@ jobs:
5467
run: ./gradlew nativeZip -Pprod
5568

5669
- name: Upload artifacts
70+
if: inputs.upload-artifacts == true
5771
uses: actions/upload-artifact@v4
5872
with:
5973
name: ${{ matrix.artifact-name }}
6074
path: build/distributions/*.${{ matrix.artifact-type }}*
6175
if-no-files-found: error
62-
retention-days: 1
76+
retention-days: 7

.github/workflows/release.yml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,14 @@ on:
1313
default: false
1414

1515
jobs:
16-
build:
17-
uses: ./.github/workflows/build.yml
18-
19-
release:
20-
needs: build
16+
verify:
2117
runs-on: ubuntu-latest
22-
permissions:
23-
contents: write
24-
2518
steps:
2619
- uses: actions/checkout@v4
2720

2821
- name: Verify versions are up to date
2922
run: |
3023
files=(
31-
"scripts/install.ps1"
32-
"scripts/install.sh"
3324
"build.gradle.kts"
3425
"src/test/resources/snapshots/AstraCli/help_output.human.approved.txt"
3526
)
@@ -49,6 +40,29 @@ jobs:
4940
exit 1
5041
fi
5142
43+
build:
44+
needs: verify
45+
uses: ./.github/workflows/build.yml
46+
with:
47+
upload-artifacts: true
48+
build-all-platforms: true
49+
50+
update-install-scripts:
51+
needs: build
52+
uses: update-install-scripts.yml
53+
permissions:
54+
contents: write
55+
pull-requests: write
56+
with:
57+
tag: ${{ inputs.tag }}
58+
59+
release:
60+
needs: [build, update-install-scripts]
61+
runs-on: ubuntu-latest
62+
permissions:
63+
contents: write
64+
65+
steps:
5266
- name: Download all artifacts
5367
uses: actions/download-artifact@v4
5468
with:
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Update Checksums
2+
on:
3+
workflow_call:
4+
inputs:
5+
tag:
6+
required: true
7+
type: string
8+
9+
jobs:
10+
update-install-scripts:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Download all artifacts
22+
uses: actions/download-artifact@v4
23+
with:
24+
path: artifacts
25+
26+
- name: Calculate checksums
27+
id: checksums
28+
run: |
29+
set -euo pipefail
30+
31+
# Linux x86_64
32+
LINUX_X86_64_FILES=(artifacts/astra-cli-linux-x86_64/*.tar.gz)
33+
if [ ${#LINUX_X86_64_FILES[@]} -eq 0 ]; then
34+
echo "ERROR: No Linux x86_64 artifact found"
35+
exit 1
36+
fi
37+
LINUX_X86_64=$(sha256sum "${LINUX_X86_64_FILES[0]}" | cut -d' ' -f1)
38+
39+
# Linux ARM64
40+
LINUX_ARM64_FILES=(artifacts/astra-cli-linux-arm64/*.tar.gz)
41+
if [ ${#LINUX_ARM64_FILES[@]} -eq 0 ]; then
42+
echo "ERROR: No Linux ARM64 artifact found"
43+
exit 1
44+
fi
45+
LINUX_ARM64=$(sha256sum "${LINUX_ARM64_FILES[0]}" | cut -d' ' -f1)
46+
47+
# macOS x86_64
48+
MACOS_X86_64_FILES=(artifacts/astra-cli-macos-x86_64/*.tar.gz)
49+
if [ ${#MACOS_X86_64_FILES[@]} -eq 0 ]; then
50+
echo "ERROR: No macOS x86_64 artifact found"
51+
exit 1
52+
fi
53+
MACOS_X86_64=$(sha256sum "${MACOS_X86_64_FILES[0]}" | cut -d' ' -f1)
54+
55+
# macOS ARM64
56+
MACOS_ARM64_FILES=(artifacts/astra-cli-macos-arm64/*.tar.gz)
57+
if [ ${#MACOS_ARM64_FILES[@]} -eq 0 ]; then
58+
echo "ERROR: No macOS ARM64 artifact found"
59+
exit 1
60+
fi
61+
MACOS_ARM64=$(sha256sum "${MACOS_ARM64_FILES[0]}" | cut -d' ' -f1)
62+
63+
# Windows x86_64
64+
WINDOWS_X86_64_FILES=(artifacts/astra-cli-windows-x86_64/*.zip)
65+
if [ ${#WINDOWS_X86_64_FILES[@]} -eq 0 ]; then
66+
echo "ERROR: No Windows x86_64 artifact found"
67+
exit 1
68+
fi
69+
WINDOWS_X86_64=$(sha256sum "${WINDOWS_X86_64_FILES[0]}" | cut -d' ' -f1)
70+
71+
echo "linux_x86_64=$LINUX_X86_64" >> $GITHUB_OUTPUT
72+
echo "linux_arm64=$LINUX_ARM64" >> $GITHUB_OUTPUT
73+
echo "macos_x86_64=$MACOS_X86_64" >> $GITHUB_OUTPUT
74+
echo "macos_arm64=$MACOS_ARM64" >> $GITHUB_OUTPUT
75+
echo "windows_x86_64=$WINDOWS_X86_64" >> $GITHUB_OUTPUT
76+
77+
- name: Extract version from tag
78+
id: version
79+
run: |
80+
# Remove 'v' prefix from tag (e.g., v1.0.0 -> 1.0.0)
81+
VERSION="${{ inputs.tag }}"
82+
VERSION="${VERSION#v}"
83+
echo "version=$VERSION" >> $GITHUB_OUTPUT
84+
85+
- name: Validate variables exist in scripts
86+
run: |
87+
set -euo pipefail
88+
89+
# Check checksum variables
90+
for var in LINUX_X86_64_CHECKSUM LINUX_ARM64_CHECKSUM MACOS_X86_64_CHECKSUM MACOS_ARM64_CHECKSUM; do
91+
grep -q "^${var}=" scripts/install.sh || { echo "ERROR: ${var} not found in install.sh"; exit 1; }
92+
done
93+
grep -q '^\$WINDOWS_X86_64_CHECKSUM' scripts/install.ps1 || { echo "ERROR: WINDOWS_X86_64_CHECKSUM not found in install.ps1"; exit 1; }
94+
95+
# Check version variables
96+
grep -q '^ASTRA_CLI_VERSION=' scripts/install.sh || { echo "ERROR: ASTRA_CLI_VERSION not found in install.sh"; exit 1; }
97+
grep -q '^\$ASTRA_CLI_VERSION' scripts/install.ps1 || { echo "ERROR: ASTRA_CLI_VERSION not found in install.ps1"; exit 1; }
98+
99+
- name: Update install.sh
100+
run: |
101+
set -euo pipefail
102+
103+
# Update checksums
104+
sed -i 's/^LINUX_X86_64_CHECKSUM=.*/LINUX_X86_64_CHECKSUM="${{ steps.checksums.outputs.linux_x86_64 }}"/' scripts/install.sh
105+
sed -i 's/^LINUX_ARM64_CHECKSUM=.*/LINUX_ARM64_CHECKSUM="${{ steps.checksums.outputs.linux_arm64 }}"/' scripts/install.sh
106+
sed -i 's/^MACOS_X86_64_CHECKSUM=.*/MACOS_X86_64_CHECKSUM="${{ steps.checksums.outputs.macos_x86_64 }}"/' scripts/install.sh
107+
sed -i 's/^MACOS_ARM64_CHECKSUM=.*/MACOS_ARM64_CHECKSUM="${{ steps.checksums.outputs.macos_arm64 }}"/' scripts/install.sh
108+
109+
# Update version
110+
sed -i 's/^ASTRA_CLI_VERSION=.*/ASTRA_CLI_VERSION="${{ steps.version.version }}"/' scripts/install.sh
111+
112+
- name: Update install.ps1
113+
run: |
114+
set -euo pipefail
115+
116+
# Update checksum
117+
sed -i 's/^\(\$WINDOWS_X86_64_CHECKSUM\s*=\s*\).*/\1"${{ steps.checksums.outputs.windows_x86_64 }}"/' scripts/install.ps1
118+
119+
# Update version
120+
sed -i 's/^\(\$ASTRA_CLI_VERSION\s*=\s*\).*/\1"${{ steps.version.version }}"/' scripts/install.ps1
121+
122+
- name: Create Pull Request
123+
uses: peter-evans/create-pull-request@v7
124+
with:
125+
branch: update-install-scripts-${{ github.run_id }}
126+
commit-message: "chore: update checksums and version for ${{ inputs.tag }}"
127+
title: "Update checksums and version for ${{ inputs.tag }}"
128+
body: |
129+
Automated update for release ${{ inputs.tag }}
130+
131+
**Changes:**
132+
- Updated version to ${{ steps.version.version }}
133+
- Updated checksums for all platforms
134+
labels: automated

.idea/dictionaries/project.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/install.ps1

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
#!/usr/bin/env pwsh
22
param(
3-
# Skips adding the astra.exe directory to the user's %PATH%
3+
# Skips adding the astra.exe directory to the user's %PATH%
44
[Switch]$NoPathUpdate = $false,
5-
# Skips adding Astra CLI to the list of installed programs
5+
# Skips adding Astra CLI to the list of installed programs
66
[Switch]$NoRegisterInstallation = $false
77
);
88

99
$ErrorActionPreference = "Stop"
1010

11+
# https://stackoverflow.com/questions/64581966/default-securityprotocol-in-powershell-5-1
12+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
13+
1114
# Utilities
1215
function Write-MultiColor {
1316
param(
@@ -116,6 +119,9 @@ function Get-Env {
116119
# Constants
117120
$ASTRA_CLI_VERSION = "1.0.1"
118121

122+
# Checksum constant (updated automatically by CI)
123+
$WINDOWS_X86_64_CHECKSUM = "0000000000000000000000000000000000000000000000000000000000000000"
124+
119125
if ($env:ASTRA_HOME) {
120126
$ASTRA_CLI_DIR = "$env:ASTRA_HOME\cli"
121127
}
@@ -228,6 +234,16 @@ catch {
228234
}
229235
}
230236

237+
$actualChecksum = (Get-FileHash -Path $zipPath -Algorithm SHA256).Hash.ToLower()
238+
$expectedChecksum = $WINDOWS_X86_64_CHECKSUM.ToLower()
239+
240+
if ($actualChecksum -ne $expectedChecksum) {
241+
Remove-Item $zipPath -ErrorAction SilentlyContinue
242+
Panic "`nError: Checksum verification failed. Expected $expectedChecksum but got $actualChecksum. The downloaded file may be corrupted."
243+
}
244+
245+
Checklist "Checksum verified."
246+
231247
try {
232248
$lastProgressPreference = $global:ProgressPreference
233249
$global:ProgressPreference = 'SilentlyContinue';

scripts/install.sh

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ renderCommand() {
4848
# Constants
4949
ASTRA_CLI_VERSION="1.0.1"
5050

51+
# Checksum constants (updated automatically by CI)
52+
LINUX_X86_64_CHECKSUM="0000000000000000000000000000000000000000000000000000000000000000"
53+
LINUX_ARM64_CHECKSUM="0000000000000000000000000000000000000000000000000000000000000000"
54+
MACOS_X86_64_CHECKSUM="0000000000000000000000000000000000000000000000000000000000000000"
55+
MACOS_ARM64_CHECKSUM="0000000000000000000000000000000000000000000000000000000000000000"
56+
5157
if [ -n "${ASTRA_HOME:-}" ]; then
5258
ASTRA_CLI_DIR_RESOLVER="custom"
5359
ASTRA_CLI_DIR="$ASTRA_HOME/cli"
@@ -100,6 +106,10 @@ if ! exists tar; then
100106
error "Error: tar is not installed. Please install tar and try again."
101107
fi
102108

109+
if ! exists sha256sum && ! exists shasum && ! exists openssl; then
110+
error "Error: No SHA-256 checksum tool found. Please install sha256sum, shasum, or openssl and try again."
111+
fi
112+
103113
checklist "Required tools are available."
104114

105115
# Make installation URL
@@ -341,7 +351,38 @@ else
341351
error "\nError: Failed to download the archive to $(underline "$(tildify "$TAR_PATH")"). Please check your internet connection, verify write permissions, and try again."
342352
fi
343353

344-
if tar -xzf "$TAR_PATH" -C "$ASTRA_CLI_DIR" --strip-components=2 astra/bin/astra; then
354+
# Verify checksum
355+
case "$os-$arch" in
356+
linux-x86_64)
357+
expected_checksum="$LINUX_X86_64_CHECKSUM"
358+
;;
359+
linux-arm64)
360+
expected_checksum="$LINUX_ARM64_CHECKSUM"
361+
;;
362+
macos-x86_64)
363+
expected_checksum="$MACOS_X86_64_CHECKSUM"
364+
;;
365+
macos-arm64)
366+
expected_checksum="$MACOS_ARM64_CHECKSUM"
367+
;;
368+
esac
369+
370+
if exists sha256sum; then
371+
actual_checksum=$(sha256sum "$TAR_PATH" | cut -d' ' -f1)
372+
elif exists shasum; then
373+
actual_checksum=$(shasum -a 256 "$TAR_PATH" | awk '{print $1}')
374+
else
375+
actual_checksum=$(openssl dgst -sha256 "$TAR_PATH" | awk '{print $2}')
376+
fi
377+
378+
if [ "$actual_checksum" != "$expected_checksum" ]; then
379+
rm "$TAR_PATH" 2>/dev/null || true
380+
error "\nError: Checksum verification failed. Expected $expected_checksum but got $actual_checksum. The downloaded file may be corrupted."
381+
fi
382+
383+
checklist "Checksum verified."
384+
385+
if tar -xzf "$TAR_PATH" -C "$ASTRA_CLI_DIR" --strip-components=2 --no-same-owner astra/bin/astra; then
345386
checklist "Archive verified and extracted."
346387
else
347388
rm "$TAR_PATH" "$EXE_PATH" 2>/dev/null || true

0 commit comments

Comments
 (0)