diff --git a/github/publish/repo/metadata.json b/github/publish/repo/metadata.json index cd485c3b..fde33ca7 100755 --- a/github/publish/repo/metadata.json +++ b/github/publish/repo/metadata.json @@ -1,7 +1,6 @@ { "execution": [ - "local", - "docker" + "local" ], "os": { "deps": [], diff --git a/gitlab/publish/repo/config.json b/gitlab/publish/repo/config.json index bdb5e9bb..dd77a90a 100755 --- a/gitlab/publish/repo/config.json +++ b/gitlab/publish/repo/config.json @@ -20,7 +20,7 @@ "qty": 6 }, "label": "Project Name : ", - "name": "projectname", + "name": "project_name", "type": "text" }, { diff --git a/gitlab/publish/repo/metadata.json b/gitlab/publish/repo/metadata.json index 08d53078..96a5d1b7 100755 --- a/gitlab/publish/repo/metadata.json +++ b/gitlab/publish/repo/metadata.json @@ -1,7 +1,6 @@ { "execution": [ - "local", - "docker" + "local" ], "os": { "deps": [], diff --git a/gitlab/publish/repo/src/formula/formula.sh b/gitlab/publish/repo/src/formula/formula.sh index f3f7ed26..a4a423c0 100755 --- a/gitlab/publish/repo/src/formula/formula.sh +++ b/gitlab/publish/repo/src/formula/formula.sh @@ -25,7 +25,7 @@ checkProjectName() { runFormula() { - slug_name=$(cleanName "$PROJECTNAME") + slug_name=$(cleanName "$PROJECT_NAME") checkProjectName $slug_name cd $WORKSPACE_PATH diff --git a/publish/help.json b/publish/help.json new file mode 100755 index 00000000..66f3ce88 --- /dev/null +++ b/publish/help.json @@ -0,0 +1,4 @@ +{ + "long": "Command to publish contents on any platform", + "short": "Publish command" +} diff --git a/publish/repo/Dockerfile b/publish/repo/Dockerfile new file mode 100755 index 00000000..536d3655 --- /dev/null +++ b/publish/repo/Dockerfile @@ -0,0 +1,15 @@ +FROM cimg/base:stable-20.04 + +USER root + +RUN curl -fsSL https://commons-repo.ritchiecli.io/install.sh | bash + +RUN mkdir /rit +COPY . /rit +RUN sed -i 's/\r//g' /rit/set_umask.sh +RUN sed -i 's/\r//g' /rit/run.sh +RUN chmod +x /rit/set_umask.sh + +WORKDIR /app +ENTRYPOINT ["/rit/set_umask.sh"] +CMD ["/rit/run.sh"] diff --git a/publish/repo/Makefile b/publish/repo/Makefile new file mode 100755 index 00000000..1d689da0 --- /dev/null +++ b/publish/repo/Makefile @@ -0,0 +1,14 @@ +# SH +BINARY_NAME=run.sh +BIN_FOLDER=bin + +build: bash-build docker + +bash-build: + mkdir -p $(BIN_FOLDER) + cp -r src/* $(BIN_FOLDER) + mv $(BIN_FOLDER)/main.sh $(BIN_FOLDER)/$(BINARY_NAME) + chmod +x $(BIN_FOLDER)/$(BINARY_NAME) + +docker: + cp Dockerfile set_umask.sh $(BIN_FOLDER) diff --git a/publish/repo/README.md b/publish/repo/README.md new file mode 100755 index 00000000..bf6cdb99 --- /dev/null +++ b/publish/repo/README.md @@ -0,0 +1,54 @@ + + + + +# Ritchie Publish Repo Formula + +## Command + +- Set GITHUB or GITLAB credentials ($ rit set credentials) with USERNAME, TOKEN & EMAIL. + +- This formula can currently only be executed locally on MacOs or Linux. + +## Command + +- Prompt + +```bash +rit publish repo +``` + +- Stdin + +```bash +echo '{"provider":"Github","privacy":"true", "project_name":"ritchie-formulas-demo", "workspace_path":"/home/users/dennis/ritchie-formulas-local", "version":"v1.0.0"}' | rit publish repo --stdin +``` + +## Description + +This publish command allows the user to create a Githab or Gitlab Ritchie formulas repository based on a local repository. + +It encapsulates the `rit github publish repo` and the `rit gitlab publish repo` formulas. + +Therefore, it also generates a release and add it to Ritchie repositories ($ rit add repo). +If the repository already exists, it will commit the new code and generate the new release version informed, before updating Ritchie repositories ($ rit update repo). + +The user has to inform 5 different kinds of inputs: + +- the provider (Github or Gitlab) + +- the repository's privacy + +- the repository's name + +- the local repository path you wish to publish + +- the release version to generate + +## Demonstration + +- Command execution + + + + diff --git a/publish/repo/config.json b/publish/repo/config.json new file mode 100755 index 00000000..427a23cd --- /dev/null +++ b/publish/repo/config.json @@ -0,0 +1,45 @@ +{ + "dockerImageBuilder": "cimg/base:stable-20.04", + "inputs": [ + { + "items": [ + "Github", + "Gitlab" + ], + "label": "Provider : ", + "name": "provider", + "type": "text" + }, + { + "cache": { + "active": true, + "newLabel": "Type new value. ", + "qty": 6 + }, + "label": "Project Name : ", + "name": "project_name", + "type": "text" + }, + { + "default": "true", + "items": [ + "true", + "false" + ], + "label": "Will it be a private repository? ", + "name": "privacy", + "type": "text" + }, + { + "label": "Workspace to publish path: (ex: /home/user/dennis/ritchie-formulas)", + "name": "workspace_path", + "type": "text" + }, + { + "default": "v1.0.0", + "label": "Version: (default: v1.0.0)", + "name": "version", + "type": "text" + } + ] +} diff --git a/publish/repo/docs/img/Github.png b/publish/repo/docs/img/Github.png new file mode 100644 index 00000000..d002d0ee Binary files /dev/null and b/publish/repo/docs/img/Github.png differ diff --git a/publish/repo/docs/img/Gitlab.png b/publish/repo/docs/img/Gitlab.png new file mode 100644 index 00000000..d2af137b Binary files /dev/null and b/publish/repo/docs/img/Gitlab.png differ diff --git a/publish/repo/help.json b/publish/repo/help.json new file mode 100755 index 00000000..97cb612f --- /dev/null +++ b/publish/repo/help.json @@ -0,0 +1,4 @@ +{ + "long": "Publish formula repository on Github or Gitlab using rit github/gitlab publish repo formulas", + "short": "Publish formula repository on Github or Gitlab" +} diff --git a/publish/repo/metadata.json b/publish/repo/metadata.json new file mode 100755 index 00000000..efd2dad2 --- /dev/null +++ b/publish/repo/metadata.json @@ -0,0 +1,18 @@ +{ + "execution": [ + "local" + ], + "os": { + "deps": [], + "support": [ + "mac", + "linux" + ] + }, + "tags": [ + "github", + "gitlab", + "publish", + "repo" + ] +} diff --git a/publish/repo/set_umask.sh b/publish/repo/set_umask.sh new file mode 100755 index 00000000..091c13d6 --- /dev/null +++ b/publish/repo/set_umask.sh @@ -0,0 +1,3 @@ +#!/bin/sh +umask 0011 +$1 diff --git a/publish/repo/src/formula/formula.sh b/publish/repo/src/formula/formula.sh new file mode 100755 index 00000000..4ad37cb3 --- /dev/null +++ b/publish/repo/src/formula/formula.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# shellcheck disable=SC2181 +# shellcheck disable=SC2086 +# shellcheck disable=SC2164 + +runFormula() { + if [ "Github" == $PROVIDER ] + then + echo "🐙 Github provider selected" + echo '{"privacy":"'$PRIVACY'", "project_name":"'$PROJECT_NAME'", "workspace_path":"'$WORKSPACE_PATH'", "version":"'$VERSION'"}' | rit github publish repo --stdin + elif [ "Gitlab" == $PROVIDER ] + then + echo "🦊 Gitlab provider selected" + echo '{"privacy":"'$PRIVACY'", "project_name":"'$PROJECT_NAME'", "workspace_path":"'$WORKSPACE_PATH'", "version":"'$VERSION'"}' | rit gitlab publish repo --stdin + else + echo "🤖 Unexpected Provider informed. Check it please and try again." + fi +} diff --git a/publish/repo/src/main.sh b/publish/repo/src/main.sh new file mode 100755 index 00000000..48c8d1ab --- /dev/null +++ b/publish/repo/src/main.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# shellcheck source=/dev/null +. "$(dirname "$0")"/formula/formula.sh --source-only + +runFormula