Skip to content

Commit

Permalink
simplify logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mre authored Oct 7, 2024
1 parent 0eca6a3 commit 437d088
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,42 +53,41 @@ runs:
mkdir -p "$HOME/.local/bin"
shell: bash

- name: Determine lychee filename
id: lychee-filename
- name: Clean up existing lychee files
run: |
# Older releases (prior to 0.16.x) had the version number in the archive name.
# This determines the correct filename based on the version string.
# Remove any existing lychee binaries or archives to prevent conflicts
rm -f "$HOME/.local/bin/lychee"
rm -rf lychee
rm -f "${{ steps.lychee-filename.outputs.filename }}"
shell: bash

- name: Determine lychee filename and download
id: lychee-download
run: |
# Determine filename and download URL based on version
if [[ '${{ inputs.lycheeVersion }}' =~ ^v0\.0|^v0\.1[0-5]\. ]]; then
echo "filename=lychee-${{ inputs.lycheeVersion }}-x86_64-unknown-linux-gnu.tar.gz" >> $GITHUB_OUTPUT
echo "tag=${{ inputs.lycheeVersion }}" >> $GITHUB_OUTPUT
FILENAME="lychee-${{ inputs.lycheeVersion }}-x86_64-unknown-linux-gnu.tar.gz"
DOWNLOAD_URL="https://github.com/lycheeverse/lychee/releases/download/${{ inputs.lycheeVersion }}/${FILENAME}"
else
echo "filename=lychee-x86_64-unknown-linux-gnu.tar.gz" >> $GITHUB_OUTPUT
# Each crate in the workspace has its own tag, so we need to specify the tag for the binary.
# The binary is released under the 'lychee' tag, the library under 'lychee-lib'.
# For nightly builds, we use the 'nightly' tag.
FILENAME="lychee-x86_64-unknown-linux-gnu.tar.gz"
if [[ '${{ inputs.lycheeVersion }}' == 'nightly' ]]; then
echo "tag=${{ inputs.lycheeVersion }}" >> $GITHUB_OUTPUT
DOWNLOAD_URL="https://github.com/lycheeverse/lychee/releases/download/nightly/${FILENAME}"
elif [[ '${{ inputs.lycheeVersion }}' == 'latest' ]]; then
echo "tag=latest" >> $GITHUB_OUTPUT
DOWNLOAD_URL="https://github.com/lycheeverse/lychee/releases/latest/download/${FILENAME}"
else
echo "tag=lychee-${{ inputs.lycheeVersion }}" >> $GITHUB_OUTPUT
# 0.16.x and onwards
DOWNLOAD_URL="https://github.com/lycheeverse/lychee/releases/download/lychee-${{ inputs.lycheeVersion }}/${FILENAME}"
fi
fi
shell: bash
- name: Clean up existing lychee files
run: |
# Remove any existing lychee binaries or archives to prevent conflicts
rm -f "$HOME/.local/bin/lychee"
rm -rf lychee
rm -f "${{ steps.lychee-filename.outputs.filename }}"
shell: bash
# Download lychee
curl -sfLO "${DOWNLOAD_URL}"
- name: Download lychee
run: |
curl -sfLO "https://github.com/lycheeverse/lychee/releases/download/${{ steps.lychee-filename.outputs.tag }}/${{ steps.lychee-filename.outputs.filename }}"
# Output filename for use in later steps
echo "filename=${FILENAME}" >> $GITHUB_OUTPUT
shell: bash


- name: Extract lychee
run: |
tar -xvzf "${{ steps.lychee-filename.outputs.filename }}"
Expand Down

0 comments on commit 437d088

Please sign in to comment.