Skip to content

Commit

Permalink
Add install-bender action (#3)
Browse files Browse the repository at this point in the history
* Add install-bender action

Installs the specified or latest version of bender.

Signed-off-by: Nils Wistoff <[email protected]>

* bender-install: Rename from install-bender

Signed-off-by: Nils Wistoff <[email protected]>

* bender-install: Handle existing installations

Signed-off-by: Nils Wistoff <[email protected]>

* bender-install.sh: Propagate errors

Signed-off-by: Nils Wistoff <[email protected]>

* bender-install.sh: Take bender version as argument

Signed-off-by: Nils Wistoff <[email protected]>

* bender-install: Unify capitalization

Signed-off-by: Nils Wistoff <[email protected]>

---------

Signed-off-by: Nils Wistoff <[email protected]>
  • Loading branch information
niwis authored Apr 13, 2023
1 parent 37a67d6 commit 6d96be8
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
22 changes: 22 additions & 0 deletions bender-install/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Bender Install

This action installs the specified or latest version of Bender.

## Action usage

Simply add the action to your desired upstream workflow. Indicate the desired version with the `version` argument, or omit it to install the latest version. If no version is specified and bender is already installed, the existing version will be used. For example:

```yaml
name: bender-install

on: [ push, pull_request, workflow_dispatch ]

jobs:
bender-install:
runs-on: ubuntu-latest
steps:
- name: bender install
uses: pulp-platform/pulp-actions/bender-install@v2
with:
version: 0.27.1
```
23 changes: 23 additions & 0 deletions bender-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2023 ETH Zurich and University of Bologna.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

# Author: Nils Wistoff <[email protected]>

name: 'Bender Install'
description: 'Install the specified or latest version of Bender.'

inputs:
# Optional argument
version:
description: 'Bender version to install (default: latest)'
required: false
default: ''

runs:
using: "composite"
steps:
- name: Bender install
shell: bash
run: |
${{ github.action_path }}/bender-install.sh ${{ inputs.version }}
31 changes: 31 additions & 0 deletions bender-install/bender-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
#
# Copyright 2023 ETH Zurich and University of Bologna.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#
# Nils Wistoff <[email protected]>

set -e

# Parse args
VERSION=""
if [ $# -eq 1 ]; then
VERSION=$1
fi

# Check for existing bender installation
if [ -x "$(command -v bender)" ]; then
if [[ $VERSION = "" ]] || [[ "$(bender --version)" = "bender $VERSION" ]]; then
echo "bender-install: $(bender --version) already installed."
exit 0
else
echo "bender-install: bender $VERSION requested but $(bender --version) is already installed. Aborting."
exit 1
fi
fi

# Install bender
sudo mkdir -p /tools/bender && sudo chmod 777 /tools/bender
cd /tools/bender && curl --proto '=https' --tlsv1.2 -sSf https://pulp-platform.github.io/bender/init | bash -s -- $VERSION
echo "PATH=/tools/bender:$PATH" >> ${GITHUB_ENV}

0 comments on commit 6d96be8

Please sign in to comment.