Skip to content

Commit

Permalink
fix path issues (#13)
Browse files Browse the repository at this point in the history
works now
  • Loading branch information
hilmarf authored Dec 19, 2024
1 parent b21e1d5 commit 6f7684d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 70 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ jobs:
id: setup
uses: open-component-model/ocm-setup-action@main
# with:
# version: v0.3.0-rc.1
# version: v0.19.0
- name: Output
run: |
echo "OCM: ${{ steps.setup.outputs.ocm-path }}"
echo "DIR:"
pwd
echo "GITHUB_WORKSPACE: $GITHUB_WORKSPACE"
make
which ocm
ocm --version
11 changes: 0 additions & 11 deletions Makefile

This file was deleted.

32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,35 @@

[![REUSE status](https://api.reuse.software/badge/github.com/open-component-model/ocm-setup-action)](https://api.reuse.software/info/github.com/open-component-model/ocm-setup-action)

This GitHub Action installs a dedicated version of the OCM tool to be used
in further steps. For example, it could be used in a Makefile executed as
subsequenet step to build a project.
This GitHub Action installs a dedicated version of the ocm-cli to be used in further steps. For example, it could be used in a Makefile executed as subsequent step to build a project.

## Inputs

### `version`

**Optional** The tool version to install. By default the latest version is installed.
**Optional** The ocm-cli version to install. By default the latest version is installed.

### `repo`

**Optional** The repository of the tool to install. Default `"open-component-model/ocm"`.

## Outputs

## `ocm-path`

The installation path of the tool.
It is installed into a PATH folder. Therefore it can be directly be used, also.
**Optional** The repository of the ocm-cli to install. Default `"open-component-model/ocm"`.

## Example usage

```
uses: open-component-model/ocm-setup-action@main
with:
version: v0.3.0-rc.1
```yaml

jobs:
ocm-setup-action:
runs-on: ubuntu-latest
name: ocm-setup-action
steps:
- uses: open-component-model/ocm-setup-action@main
with:
version: v0.19.0
- run: ocm --version
```
## Licensing
Copyright 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
Copyright 2024 SAP SE or an SAP affiliate company and Open Component Model contributors.
Please see our [LICENSE](LICENSE) for copyright and license information.
Detailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/open-component-model/ocm-setup-action).
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 6f7684d

Please sign in to comment.