Add checksum validation. Use "latest" version by default. (#3)

- Add checksum
- Use "latest" by default
This commit is contained in:
Eugene 2024-04-13 21:13:47 +09:00 committed by GitHub
parent c233d6e746
commit c4c13caf68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 7 deletions

View File

@ -23,7 +23,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: ["ubuntu", "macos"] os: ["ubuntu", "macos"]
version: ["9.11.1", "9.11.0", "9.10.1", "9.10.0", "9.9.0"] version: ["latest", "9.12.0", "9.11.1", "9.11.0", "9.10.1", "9.10.0"]
runs-on: ${{ matrix.os }}-latest runs-on: ${{ matrix.os }}-latest
steps: steps:
- name: Checkout ${{ github.repository }} - name: Checkout ${{ github.repository }}

View File

@ -38,7 +38,7 @@ repos:
hooks: hooks:
- id: prettier - id: prettier
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0 rev: v4.6.0
hooks: hooks:
- id: check-merge-conflict - id: check-merge-conflict
- id: check-json - id: check-json

View File

@ -9,7 +9,7 @@ inputs:
version: version:
description: "mark version." description: "mark version."
required: false required: false
default: "9.11.1" default: "latest"
runs: runs:
using: "composite" using: "composite"
steps: steps:

View File

@ -9,18 +9,24 @@ if command -v mark >/dev/null 2>&1; then
exit 0 exit 0
fi fi
if [ "${mark_version}" = "latest" ]; then
url_prefix="https://github.com/kovetskiy/mark/releases/latest/download"
else
url_prefix="https://github.com/kovetskiy/mark/releases/download/${mark_version}"
fi
url="" url=""
if [ "${RUNNER_OS}" = "macOS" ]; then if [ "${RUNNER_OS}" = "macOS" ]; then
if [ "${RUNNER_ARCH}" = "X64" ]; then if [ "${RUNNER_ARCH}" = "X64" ]; then
url="https://github.com/kovetskiy/mark/releases/download/${mark_version}/mark_Darwin_x86_64.tar.gz" url="${url_prefix}/mark_Darwin_x86_64.tar.gz"
elif [ "${RUNNER_ARCH}" = "ARM64" ]; then elif [ "${RUNNER_ARCH}" = "ARM64" ]; then
url="https://github.com/kovetskiy/mark/releases/download/${mark_version}/mark_Darwin_arm64.tar.gz" url="${url_prefix}/mark_Darwin_arm64.tar.gz"
fi fi
elif [ "${RUNNER_OS}" = "Linux" ]; then elif [ "${RUNNER_OS}" = "Linux" ]; then
if [ "${RUNNER_ARCH}" = "X64" ]; then if [ "${RUNNER_ARCH}" = "X64" ]; then
url="https://github.com/kovetskiy/mark/releases/download/${mark_version}/mark_Linux_x86_64.tar.gz" url="${url_prefix}/mark_Linux_x86_64.tar.gz"
elif [ "${RUNNER_ARCH}" = "ARM64" ]; then elif [ "${RUNNER_ARCH}" = "ARM64" ]; then
url="https://github.com/kovetskiy/mark/releases/download/${mark_version}/mark_Linux_arm64.tar.gz" url="${url_prefix}/mark_Linux_arm64.tar.gz"
fi fi
fi fi
@ -32,7 +38,15 @@ fi
bin_path="${RUNNER_TEMP}/bin" bin_path="${RUNNER_TEMP}/bin"
mkdir -p "${bin_path}" mkdir -p "${bin_path}"
tar_path="${bin_path}/mark.tar.gz" tar_path="${bin_path}/mark.tar.gz"
checksums_path="${bin_path}/checksums.txt"
curl -sL "${url}" -o "${tar_path}" curl -sL "${url}" -o "${tar_path}"
curl -sL "${url_prefix}/checksums.txt" -o "${checksums_path}"
if ! grep -qF "$(shasum -a 256 "${tar_path}" | cut -d ' ' -f 1)" "${checksums_path}"; then
echo "::error title=Checksum error::Checksum is different from the downloaded binary"
exit 1
fi
tar -xf "${tar_path}" -C "${bin_path}" tar -xf "${tar_path}" -C "${bin_path}"
rm -f "${tar_path}" rm -f "${tar_path}"
echo "${bin_path}" >> "$GITHUB_PATH" echo "${bin_path}" >> "$GITHUB_PATH"