Skip to content

Commit

Permalink
let's keep things simple
Browse files Browse the repository at this point in the history
  • Loading branch information
hilmarf committed Dec 19, 2024
1 parent c51fdca commit 8482a9a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 37 deletions.
35 changes: 15 additions & 20 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
name: 'Open Component Model tool installer'
description: 'Install a specific version of the ocm binary. Acceptable values are latest or any semantic version string like 1.15.0'
name: "Open Component Model command line (ocm-cli) installer"
description: "Install a specific version of the ocm binary. Acceptable values are latest or any semantic version string like 1.15.0 see: https://github.com/open-component-model/ocm/releases"
inputs:
version:
description: 'Version of the ocm tool (defaulted to latest version)'
description: "Version of the ocm-cli (defaulted to latest version)"
required: true
default: latest
repo:
description: 'Repository of the ocm tool'
description: "Repository of the ocm-cli"
required: true
default: 'open-component-model/ocm'
outputs:
ocm-path:
description: 'Path to the cached ocm binary'
value: ${{ steps.install.outputs.ocm-path }}
default: "open-component-model/ocm"
branding:
color: 'blue'
color: "blue"
runs:
using: 'composite'
using: "composite"
steps:
- shell: bash
id: install
env:
version: ${{ inputs.version }}
repo: ${{ inputs.repo }}
run: |
echo "path: ${{ github.action_path }}"
chmod +x "${{ github.action_path }}/install.sh"
"${{ github.action_path }}/install.sh"
- shell: bash
id: install
env:
version: ${{ inputs.version }}
repo: ${{ inputs.repo }}
run: |
chmod a+x "${{ github.action_path }}/install.sh"
"${{ github.action_path }}/install.sh"
28 changes: 11 additions & 17 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,26 @@
set -o pipefail

REPO=${repo:=open-component-model/ocm}
WORKSPACE=${GITHUB_WORKSPACE:=/usr/local}

if [ -z "$version" -o "$version" == latest ]; then
version="$(basename "$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/$REPO/releases/latest)")"
echo "Selecting latest version: $version"
fi

BINARY=ocm

VERSION=${version#v}
PLATFORM=linux
ARCH=amd64
ARCHIVEFILE="${BINARY}-${VERSION}-${PLATFORM}-${ARCH}.tar.gz"
ARCHIVEFILE="ocm-${VERSION}-${PLATFORM}-${ARCH}.tar.gz"
URL="https://github.com/$REPO/releases/download/v${VERSION}/$ARCHIVEFILE"
TARGET=${WORKSPACE}/ocm
TARGET="$HOME/.local/bin"

cd /tmp
echo "Installing Open Component Model CLI Tool version $version from $REPO"
# prepare target directory
mkdir -p $TARGET
cd $TARGET
rm -f ocm-cli.tgz
mkdir -p "$(dirname "$TARGET")"
curl -Ls -o ocm-cli.tgz "$URL"
echo "$TARGET" >> "$GITHUB_PATH"

echo "Installing ocm-cli version $version from $REPO"
curl -LsS -o ocm-cli.tgz "$URL"
tar --overwrite -xvzf ocm-cli.tgz >/dev/null
cp ocm "$TARGET"
chmod a+x "$TARGET"
echo "ocm installed into $TARGET"
if [ -n "$GITHUB_OUTPUT" ]; then
echo "ocm-path=$TARGET" >> "$GITHUB_OUTPUT"
fi
# add installation folder to PATH to be able to use "which ocm" in subsequent steps to detect installation path
echo "$TARGET" >> $GITHUB_PATH
chmod a+x ocm

0 comments on commit 8482a9a

Please sign in to comment.