-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
84 lines (76 loc) · 2.89 KB
/
Copy pathaction.yml
File metadata and controls
84 lines (76 loc) · 2.89 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
# repository's install.sh (POLY_INSTALL_DIR-configurable, version-arg-capable),
# so there is exactly one copy of that logic. This action adds: latest-version
# default), and PATH wiring. A version bump changes the cache key, so the
# previous version's cache is naturally not restored (invalidated).
name: "Setup poly CLI"
description: "Install poly with optional local caching"
author: "Na'aman Hirschfeld"
branding:
icon: "check-circle"
color: "green"
inputs:
version:
description: 'Release version to install (e.g. v0.1.0 or 0.1.0). Omit or pass "latest" to resolve the latest release dynamically.'
required: false
default: ""
cache:
description: "Cache the installed binaries locally with actions/cache."
required: false
default: "true"
github-token:
description: "Token used to query the GitHub API when resolving the latest release."
required: false
default: ${{ github.token }}
outputs:
version:
description: "The resolved version that was installed (without the v prefix)."
value: ${{ steps.resolve.outputs.version }}
install-dir:
description: "Directory the binaries were installed into (added to PATH)."
value: ${{ steps.resolve.outputs.install-dir }}
runs:
using: "composite"
steps:
- id: resolve
shell: bash
env:
GH_TOKEN: ${{ inputs.github-token }}
run: |
set -euo pipefail
version="${{ inputs.version }}"
if [ -z "$version" ] || [ "$version" = "latest" ]; then
version="$(gh release view --repo Goldziher/poly --json tagName -q '.tagName' 2>/dev/null || true)"
if [ -z "$version" ]; then
echo "::error::could not resolve the latest polylint release" >&2
exit 1
fi
fi
version="${version#v}"
install_dir="${RUNNER_TEMP}/poly-install"
mkdir -p "$install_dir"
{
echo "version=$version"
echo "install-dir=$install_dir"
echo "cache-key=poly-v${version}-${RUNNER_OS}-${RUNNER_ARCH}"
} >> "$GITHUB_OUTPUT"
echo "Resolved poly $version -> $install_dir"
- id: cache
if: inputs.cache == 'true'
uses: actions/cache@v4
with:
path: ${{ steps.resolve.outputs.install-dir }}
key: ${{ steps.resolve.outputs.cache-key }}
- if: steps.cache.outputs.cache-hit != 'true'
shell: bash
env:
POLY_INSTALL_DIR: ${{ steps.resolve.outputs.install-dir }}
run: |
set -euo pipefail
# --no-modify-path: this action wires PATH via $GITHUB_PATH below, so the
# installer must not also edit the runner's shell profiles.
bash "${GITHUB_ACTION_PATH}/install.sh" --no-modify-path "${{ steps.resolve.outputs.version }}"
- shell: bash
run: echo "${{ steps.resolve.outputs.install-dir }}" >> "$GITHUB_PATH"
- shell: bash
run: |
"${{ steps.resolve.outputs.install-dir }}/poly" --version