Skip to content

Commit

Permalink
Add action for install
Browse files Browse the repository at this point in the history
  • Loading branch information
riseshia committed Jul 19, 2024
1 parent dfe3c18 commit b661214
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
inputs:
version:
description: "A version to install fubura"
default: latest
required: false
github-token:
description: "The token used when calling GitHub API"
required: false
default: ${{ github.token }}

runs:
using: "composite"
steps:
- shell: bash
env:
github_token: ${{ inputs.github-token }}
run: |
set -e
ARCH=$(uname -m)
if [ "${ARCH}" = "x86_64" ]; then
echo "Detected architecture: ${ARCH}"
else
echo "Unsupported architecture: ${ARCH}"
exit 1
fi
VERSION="${{ inputs.version }}"
echo "VERSION=${VERSION}"
api_request_args=("-sS")
if [[ -n "$github_token" ]]; then
api_request_args=("${api_request_args[@]}" -H "authorization: token $github_token")
fi
if [ "${VERSION}" = "latest" ]; then
DOWNLOAD_URL=$(curl "${api_request_args[@]}" https://api.github.com/repos/riseshia/fubura/releases \
| jq --arg matcher "linux.musl." -r '[.[] | select(.prerelease==false)][0].assets[].browser_download_url | select(match($matcher) and (endswith("sha256sum")))')
else
DOWNLOAD_URL=https://github.com/riseshia/fubura/releases/download/${VERSION}/fubura_${VERSION}_${ARCH}-unknown-linux-musl.zip
fi
echo "DOWNLOAD_URL=${DOWNLOAD_URL}"
mkdir -p ${RUNNER_TOOL_CACHE}/fubura
cd /tmp
curl -sfLO ${DOWNLOAD_URL}
if [[ "${DOWNLOAD_URL}" =~ \.zip$ ]]; then
FILENAME=$(basename $DOWNLOAD_URL .zip)
unzip ${FILENAME}.zip
sudo install ${FILENAME} ${RUNNER_TOOL_CACHE}/fubura/fubura
else
echo "Not supported file format from ${DOWNLOAD_URL}"
exit 1
fi
echo "Adding ${RUNNER_TOOL_CACHE}/fubura to path..."
echo "${RUNNER_TOOL_CACHE}/fubura" >> $GITHUB_PATH
"${RUNNER_TOOL_CACHE}/fubura/fubura" version

0 comments on commit b661214

Please sign in to comment.