Skip to content

Commit

Permalink
Add Windows support to s5cmd action
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Herger <michael@herger.net>
  • Loading branch information
michaelherger committed Jan 23, 2025
1 parent 91a7c7e commit f555cce
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 0 deletions.
134 changes: 134 additions & 0 deletions .github/actions/setup-s5cmd/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: "setup-s5cmd"
description: "Setup s5cmd"
author: peak
branding:
icon: zap
color: yellow
inputs:
version:
description: s5cmd version to install
required: false
default: v2.0.0
runs:
using: composite
steps:
- name: Print version
shell: bash
run: |
echo "${{ inputs.version }}"
- name: Find release asset
id: find_release_asset
shell: bash
run: |
set -e
echo "::Group::Inputs"
echo "${{ toJSON(inputs) }}"
echo "::endgroup::"
echo "::group::Runner Context"
echo "${{ toJSON(runner) }}"
echo "::endgroup::"
tag="${{ inputs.version }}"
version="${tag#v}"
os="${{ runner.os }}"
arch="${{ runner.arch || 'X64' }}"
extension=".tar.gz"
case "${os}" in
Linux)
os="Linux"
;;
macOS)
os="macOS"
;;
Windows)
os="Windows"
extension=".zip"
;;
*)
echo "Unknown OS: ${os}"
exit 1
;;
esac
case "${arch}" in
X32)
arch="32bit"
;;
X64)
arch="64bit"
;;
ARM)
arch="armv6"
;;
ARM64)
arch="arm64"
;;
*)
echo "Unknown architecture: ${arch}"
exit 1
;;
esac
asset_name="s5cmd_${version}_${os}-${arch}${extension}"
asset_url=$(
curl -s https://api.github.com/repos/peak/s5cmd/releases |
jq --arg tag "${tag}" --arg asset_name "${asset_name}" '.[]| select(.tag_name==$tag) | .assets[].browser_download_url | select(. | test(".+" + $asset_name + "$"))' | xargs
)
echo "::group::Asset URL"
echo "${asset_url}"
echo "::endgroup::"
if [ -z "$asset_url" ]; then
echo "Unable to find asset ${asset_name} for version ${tag}"
exit 1
fi
echo "url=${asset_url}" >> "$GITHUB_OUTPUT"
echo "extension=${extension}" >> "$GITHUB_OUTPUT"
- name: Download release asset
id: download_release
if: steps.find_release_asset.outputs.url != ''
shell: bash
run: |
set -e
asset_url="${{ steps.find_release_asset.outputs.url }}"
tmp_dir="${{ runner.temp }}"
download_dir="$tmp_dir/s5cmd-asset"
binary_dir="$tmp_dir/s5cmd-bin"
mkdir -p "$download_dir"
mkdir -p "$binary_dir"
archive_path="${download_dir}/s5cmd${{ steps.find_release_asset.outputs.extension }}"
curl -sL -o "${archive_path}" "${asset_url}"
echo "::group::Download archive"
file "${archive_path}"
echo "::endgroup::"
if [ "${{ runner.os }}" = "Windows" ]; then
7z x "${archive_path}" -o"${binary_dir}" s5cmd.exe
else
tar -xf "${archive_path}" -C "${binary_dir}" s5cmd
fi
echo "::group::Binary path"
ls -l "${binary_dir}"
echo "::endgroup::"
echo "binary_dir=${binary_dir}" >> "$GITHUB_OUTPUT"
- name: Add s5cmd to path
shell: bash
run: |
s5cmd_binary_dir="${{ steps.download_release.outputs.binary_dir }}"
echo "${s5cmd_binary_dir}" >> $GITHUB_PATH
9 changes: 9 additions & 0 deletions .github/workflows/00_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ on:
jobs:
mac:
name: Build LMS for Mac (MenuBar Item)
if: false
runs-on: macos-13
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
Expand Down Expand Up @@ -69,6 +70,7 @@ jobs:

linux:
name: Build LMS for Linux
if: false
runs-on: ubuntu-22.04
strategy:
matrix:
Expand Down Expand Up @@ -107,6 +109,7 @@ jobs:

docker:
name: Build LMS for Docker
if: false
runs-on: ubuntu-22.04

steps:
Expand Down Expand Up @@ -143,6 +146,9 @@ jobs:
path: server
ref: ${{ inputs.branch }}

- name: install s5cmd
uses: ./server/.github/actions/setup-s5cmd

- name: Launch build process
uses: ./server/.github/actions/build
with:
Expand All @@ -151,6 +157,9 @@ jobs:
AWS_KEY_ID: ${{ secrets.R2_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}

- name: fail!
run: exit 1

updateRepoFile:
name: Trigger repository file update
if: ${{ success() && inputs.build_type == 'nightly' && github.repository_owner == 'LMS-Community' }}
Expand Down

0 comments on commit f555cce

Please sign in to comment.