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
matrix:
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
steps:
- name: Checkout ${{ github.repository }}

View File

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

View File

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

View File

@ -9,18 +9,24 @@ if command -v mark >/dev/null 2>&1; then
exit 0
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=""
if [ "${RUNNER_OS}" = "macOS" ]; 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
url="https://github.com/kovetskiy/mark/releases/download/${mark_version}/mark_Darwin_arm64.tar.gz"
url="${url_prefix}/mark_Darwin_arm64.tar.gz"
fi
elif [ "${RUNNER_OS}" = "Linux" ]; 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
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
@ -32,7 +38,15 @@ fi
bin_path="${RUNNER_TEMP}/bin"
mkdir -p "${bin_path}"
tar_path="${bin_path}/mark.tar.gz"
checksums_path="${bin_path}/checksums.txt"
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}"
rm -f "${tar_path}"
echo "${bin_path}" >> "$GITHUB_PATH"