Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
101 lines (93 loc) · 4.05 KB
/
Copy pathaction.yml
File metadata and controls
101 lines (93 loc) · 4.05 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
name: "Setup Probitas"
description: "Install the Probitas CLI binary and add it to the path."
author: "JSR Probitas"
branding:
icon: "check-circle"
color: "green"
inputs:
probitas-version:
description: "The Probitas version to install (2.0.0 or later), or 'latest'."
default: "latest"
cache:
description: "Cache the DuckDB native binding Probitas downloads on first use."
default: "true"
outputs:
probitas-version:
description: "The Probitas version that was installed."
value: ${{ steps.version.outputs.version }}
runs:
using: "composite"
steps:
- name: Resolve Probitas version
id: version
shell: bash
env:
REQUESTED: ${{ inputs.probitas-version }}
run: |
version="${REQUESTED#v}"
if [ "$version" = "latest" ]; then
# The /latest page redirects to /tag/v<version>; reading the redirect
# avoids the GitHub API rate limit.
url=$(curl -fsSLI -o /dev/null -w '%{url_effective}' https://github.com/probitas-test/probitas/releases/latest)
version="${url##*/tag/v}"
fi
case "$version" in
0.* | 1.*)
echo "::error::setup-probitas@v2 installs Probitas 2 or later (got $version). Use probitas-test/setup-probitas@v1 for Probitas 1.x."
exit 1
;;
esac
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Probitas version: $version"
- name: Install Probitas (macOS / Linux)
if: runner.os != 'Windows'
shell: bash
env:
PROBITAS_VERSION: ${{ steps.version.outputs.version }}
PROBITAS_INSTALL_DIR: ${{ runner.tool_cache }}/probitas/${{ steps.version.outputs.version }}
run: |
# Use the install script of the release being installed, not main.
curl -fsSL "https://raw.githubusercontent.com/probitas-test/probitas/v${PROBITAS_VERSION}/install.sh" | sh
echo "${PROBITAS_INSTALL_DIR}/bin" >> "$GITHUB_PATH"
- name: Install Probitas (Windows)
if: runner.os == 'Windows'
shell: pwsh
env:
PROBITAS_VERSION: ${{ steps.version.outputs.version }}
PROBITAS_INSTALL_DIR: ${{ runner.tool_cache }}/probitas/${{ steps.version.outputs.version }}
run: |
$ErrorActionPreference = "Stop"
$base = "https://github.com/probitas-test/probitas/releases/download/v$env:PROBITAS_VERSION"
$archive = "probitas-windows-x64.zip"
$tmp = New-Item -ItemType Directory -Path (Join-Path $env:RUNNER_TEMP "probitas-$([guid]::NewGuid())")
Invoke-WebRequest "$base/$archive" -OutFile (Join-Path $tmp $archive)
Invoke-WebRequest "$base/SHA256SUMS" -OutFile (Join-Path $tmp "SHA256SUMS")
$line = Get-Content (Join-Path $tmp "SHA256SUMS") | Where-Object { $_ -match " $([regex]::Escape($archive))$" }
if (-not $line) { throw "$archive is not listed in SHA256SUMS" }
$expected = ($line -split '\s+')[0]
$actual = (Get-FileHash (Join-Path $tmp $archive) -Algorithm SHA256).Hash.ToLower()
if ($expected -ne $actual) { throw "Checksum mismatch for $archive (expected $expected, got $actual)" }
$bin = Join-Path $env:PROBITAS_INSTALL_DIR "bin"
New-Item -ItemType Directory -Force -Path $bin | Out-Null
Expand-Archive (Join-Path $tmp $archive) -DestinationPath $bin -Force
Add-Content -Path $env:GITHUB_PATH -Value $bin
- name: Locate the DuckDB cache
id: duckdb
if: inputs.cache == 'true'
shell: bash
run: |
case "$RUNNER_OS" in
macOS) dir="$HOME/Library/Caches/probitas/duckdb" ;;
Windows) dir="$LOCALAPPDATA/probitas/duckdb" ;;
*) dir="${XDG_CACHE_HOME:-$HOME/.cache}/probitas/duckdb" ;;
esac
echo "dir=$dir" >> "$GITHUB_OUTPUT"
- name: Cache the DuckDB native binding
if: inputs.cache == 'true'
uses: actions/cache@v6
with:
path: ${{ steps.duckdb.outputs.dir }}
key: probitas-duckdb-${{ runner.os }}-${{ runner.arch }}-${{ steps.version.outputs.version }}
- name: Verify Probitas
shell: bash
run: probitas --version