-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
73 lines (57 loc) · 2.42 KB
/
action.yml
File metadata and controls
73 lines (57 loc) · 2.42 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
# SPDX-FileCopyrightText: 2026 Dominik Wombacher <dominik@wombacher.cc>
#
# SPDX-License-Identifier: Apache-2.0
name: "Install params2env"
description: "Installs params2env tool, matching the action version"
inputs:
version:
description: "Version of params2env to install (Format: x.y.z). Defaults to latest release."
required: true
default: "latest"
runs:
using: composite
steps:
- name: Install params2env
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
if [ "$RUNNER_OS" != "Linux" ]; then
echo "Only Linux runners are currently supported. Detected OS: $RUNNER_OS"
exit 1
fi
case "$RUNNER_ARCH" in
X86|X64) ARCH="amd64" ;;
ARM|ARM64) ARCH="arm64" ;;
*) echo "Unsupported architecture: $RUNNER_ARCH" && exit 1 ;;
esac
OS="${RUNNER_OS,,}"
VERSION="${{ inputs.version }}"
if [ "$VERSION" = "latest" ]; then
VERSION=$(gh release list --repo wombelix/params2env --limit 1 --json tagName | jq -r '.[0].tagName')
VERSION="${VERSION#v}"
echo "Resolved latest release version: $VERSION"
fi
BASE_URL="https://github.com/wombelix/params2env/releases/download/v${VERSION}"
ARCHIVE="params2env_${VERSION}_${OS}_${ARCH}.tar.gz"
CHECKSUMS="params2env_${VERSION}_checksums.txt"
echo "Downloading ${ARCHIVE}..."
curl -fsSL --retry 3 --retry-delay 2 "${BASE_URL}/${ARCHIVE}" -o "${ARCHIVE}"
curl -fsSL --retry 3 --retry-delay 2 "${BASE_URL}/${CHECKSUMS}" -o "${CHECKSUMS}"
echo "Verifying checksum..."
CHECKSUM_LINE=$(grep " ${ARCHIVE}$" "${CHECKSUMS}" || true)
if [ -z "$CHECKSUM_LINE" ]; then
echo "Checksum entry not found for ${ARCHIVE}!"
exit 1
fi
echo "$CHECKSUM_LINE" | sha256sum -c -
echo "Extracting and installing params2env..."
tar xzf "${ARCHIVE}" || { echo "Failed to extract ${ARCHIVE}"; exit 1; }
INSTALL_DIR="$HOME/.local/bin"
mkdir -p "$INSTALL_DIR"
mv "params2env_${VERSION}_${OS}_${ARCH}/params2env" "$INSTALL_DIR"
rm -rf "${ARCHIVE}" "${CHECKSUMS}" "params2env_${VERSION}_${OS}_${ARCH}" || true
# Add to PATH for the rest of the job
echo "$INSTALL_DIR" >> "$GITHUB_PATH"
echo "params2env ${VERSION} installed successfully to $INSTALL_DIR."