From 42c85d1b6d8f662ce4a18564c811c107e4c8cc6d Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 18 Dec 2019 09:26:30 -0500 Subject: [PATCH] Initial commit --- Dockerfile | 7 +++++++ README.md | 27 +++++++++++++++++++++++++++ action.yml | 18 ++++++++++++++++++ entrypoint.sh | 29 +++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 action.yml create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0611741 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM alpine:latest + +RUN apk add --no-cache zip + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..73bc76b --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# Koha Plugin kpz Builder + +This action builds a kpz file from a given name and version. +The file will be in your GitHub workspace after the action is run. + +## Inputs + +### `release-version` + +**Required** Version for this koha plugin release, e.g. "v1.0.3" + +### `release-name` + +**Required** Name of plugin, should almost always be the repo name, e.g. "koha-plugin-kitchen-sink" + +## Outputs + +### `filename` + +The name of the built kpz file + +## Example usage + +uses: actions/koha-plugin-create-kpz@v1 +with: + release-version: 'v1.2.3' + release-name: 'koha-plugin-kitchen-sink' diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..b9c5dd6 --- /dev/null +++ b/action.yml @@ -0,0 +1,18 @@ +name: 'Koha Plugin kpz Builder' +description: 'Accepts a plugin name and version, and creates a Koha Plugin kpz file' +inputs: + release-version: # id of input + description: 'Version for this koha plugin release, e.g. v1.0.3' + required: true + release-name: + description: 'Name of plugin repo, e.g. koha-plugin-kitchen-sink' + required: true +outputs: + filename: # id of output + description: 'The name of the built kpz file' +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.release-version }} + - ${{ inputs.release-name }} diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..5d4dc1e --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,29 @@ +#!/bin/sh -l + +PLUGIN_VERSION=$1 +PLUGIN_NAME=$2 + +RELEASE_FILENAME="${PLUGIN_NAME}-${PLUGIN_VERSION}.kpz" +TODAY_ISO=$(date '+%Y-%m-%d') + +cd /github/workspace +mkdir dist +cp -r Koha dist/. +cd dist + +PLUGIN_MODULE=$(find . -regex '\./Koha/Plugin/.*[A-Za-z]*\.pm$' | tac | sed '1q;d') + +sed -i -e "s/{VERSION}/${PLUGIN_VERSION}/g" ${PLUGIN_MODULE} +sed -i -e "s/1900-01-01/${TODAY_ISO}/g" $PLUGIN_MODULE + +zip -r ../${RELEASE_FILENAME} ./Koha +cd .. +rm -rf dist + +echo "PLUGIN VERSION: $PLUGIN_VERSION" +echo "PLUGIN NAME: $PLUGIN_NAME" +echo "TODAY ISO: $TODAY_ISO" +echo "RELEASE FILENAME: $RELEASE_FILENAME" +echo "PLUGIN MODULE: $PLUGIN_MODULE" + +echo ::set-output name=filename::${RELEASE_FILENAME}