From 58a61a15cc853bd13e083de95b4b08e96ed3ca80 Mon Sep 17 00:00:00 2001 From: AnimMouse Date: Mon, 9 Jan 2023 00:06:37 +0800 Subject: [PATCH] refactor: Shorten variables, use Bash conditional, and update README.md --- README.md | 4 ++-- scripts/download/Unix-like.sh | 10 +++++----- scripts/version/Unix-like.sh | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0e2840d..ebbbf24 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ steps: ``` ### Specific version -You can specify the version you want. +You can specify the version you want. By default, this action downloads the latest version. ```yaml steps: @@ -131,7 +131,7 @@ steps: version: 0.14.0 ``` -### GitHub Token +### GitHub token This action automatically uses a GitHub token in order to authenticate with GitHub API and avoid rate limiting. You can also specify your own read-only fine-grained personal access token. ```yaml diff --git a/scripts/download/Unix-like.sh b/scripts/download/Unix-like.sh index d362c20..a15afbf 100755 --- a/scripts/download/Unix-like.sh +++ b/scripts/download/Unix-like.sh @@ -1,10 +1,10 @@ #!/bin/sh set -eu -if [ $RUNNER_OS = macOS ]; then restic_os=darwin; else restic_os=linux; fi -echo ::group::Downloading Restic $version for $restic_os -aria2c -x 16 $GITHUB_SERVER_URL/restic/restic/releases/download/v$version/restic_${version}_${restic_os}_amd64.bz2 -bzip2 -d restic_${version}_${restic_os}_amd64.bz2 +if [ $RUNNER_OS = macOS ]; then os=darwin; else os=linux; fi +echo ::group::Downloading Restic $version for $RUNNER_OS +aria2c -x 16 $GITHUB_SERVER_URL/restic/restic/releases/download/v$version/restic_${version}_${os}_amd64.bz2 +bzip2 -d restic_${version}_${os}_amd64.bz2 mkdir Restic -mv restic_${version}_${restic_os}_amd64 Restic/restic +mv restic_${version}_${os}_amd64 Restic/restic chmod +x Restic/restic echo ::endgroup:: \ No newline at end of file diff --git a/scripts/version/Unix-like.sh b/scripts/version/Unix-like.sh index c8bc190..82c6e6d 100755 --- a/scripts/version/Unix-like.sh +++ b/scripts/version/Unix-like.sh @@ -1,6 +1,6 @@ #!/bin/bash set -eu -if [ $version == latest ] +if [[ $version == latest ]] then latest_version=$(gh api repos/restic/restic/releases/latest -q .tag_name) echo version=${latest_version/v} >> $GITHUB_OUTPUT