Home

Awesome

Release It - Containerized

test Codacy Badge GitHub Release MIT

This project is a containerized version of release-it. The purpose of this project is to enable release-it to run in any environment as a standardized container without the need for a Node environment.

This project is simply a wrapper to run as containerization of release-it and execute release-it directly, providing the environment and setup around to run it.

[!NOTE] This project is released using release-it and with this containerized version including pre-releases.

Usage

As this is a containerized solution, it can be used anywhere!

The most important required is that the project has a valid configuration acceptable by release-it.

Inputs

The containerized tool accepts the following inputs.

Environmental VariableDescriptionRequired
GIT_DIRECTORYDirectory path to make it safe to run git changesfalse
GIT_EMAILThe Git email that will be identified when running release-itfalse
GIT_REPOSITORYThe Git repository of the project to run release-itfalse
GIT_USERNAMEThe Git username that will be identified when running release-itfalse
GPG_PRIVATE_KEYThe GPG Private Keyfalse
GPG_PRIVATE_KEY_IDThe GPG Private Key IDfalse
RELEASE_IT_PLUGINSList of comma separated release plugins to runfalse
SSH_PASSPHRASESSH Passphrase associated to the SSH Private Keyfalse
SSH_PRIVATE_KEYThe SSH Private key associated to the GIT account running release-itfalse

As the tool runs release-it, you can also pass additional environmental variables, such as GITHUB_TOKEN and GITLAB_TOKEN, for GitHub and GitLab, respectively.

Container - Docker

When running from the project, as the directory is passed as a volume to the container, it will inherit the Git configuration set in the project. However, if needed, this configuration can be overridden and set differently.

For example running locally.

docker run \
    -e GITHUB_TOKEN="***" \
    -e GIT_EMAIL="juancarlosjr97@gmail.com" \
    -e GIT_REPOSITORY="git@github.com:juancarlosjr97/release-it-containerized.git" \
    -e GIT_USERNAME="Juan Carlos Blanco Delgado" \
    -e GPG_PRIVATE_KEY="$(cat gpg_private_key.pgp)" \
    -e GPG_PRIVATE_KEY_ID="***" \
    -e RELEASE_IT_PLUGINS="@release-it/conventional-changelog@latest,@release-it/bumper@latest" \
    -e SSH_PASSPHRASE="***" \
    -e SSH_PRIVATE_KEY="$(cat ssh_private_key)" \
    -v $(pwd):/app \
    ghcr.io/juancarlosjr97/release-it-containerized \
    release-it --ci

The last line accepts any value, and will be accept any value from release-it CLI configuration. For example, it can execute --dry-run.

GitHub Action

The project provides a GitHub Action to used within a workflow.

Input Variables

FieldDescriptionRequiredDefault
commandCommand to execute release-itfalse""
git_emailGit email to run release-itfalse${{ github.actor }}
git_usernameGit username to run release-itfalse${{ github.actor }}@users.noreply.github.com
github_tokenGithub Token to run release-itfalse${{ github.token }}
gpg_private_keyGPG Private Keyfalse""
gpg_private_key_idGPG Private Key IDfalse""
image_tagImage tag used to pass specific version of the actionfalselatest
plugins_listList of Plugins to run with release-it as comma separatedfalse""
ssh_passphraseSSH Passphrasefalse""
ssh_private_keySSH Private Keyfalse""
versionRelease It versionfalselatest

The GitHub Action exclusively operates within a CI environment, utilizing the --ci option, ensuring a fully automated process devoid of prompts in a non-interactive mode.

Workflow

Add this step in your workflow file

- name: Running release-it using GitHub Action
    uses: juancarlosjr97/release-it-containerized:0.2.0
    with:
        git_email: ${{ vars.GIT_EMAIL }}
        git_username: ${{ vars.GIT_USERNAME }}
        github_token: ${{ secrets.PROJECT_GITHUB_TOKEN }}
        gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
        gpg_private_key_id: ${{ secrets.GPG_PRIVATE_KEY_ID }}
        plugins_list: "@release-it/conventional-changelog@latest,@release-it/bumper@latest"
        ssh_passphrase: ${{ secrets.SSH_PASSPHRASE }}
        ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}

Example

name: Release
on:
  push:
    branches: ["main"]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

- name: Running release-it using GitHub Action
    uses: juancarlosjr97/release-it-containerized:0.2.0
    with:
        git_email: ${{ vars.GIT_EMAIL }}
        git_username: ${{ vars.GIT_USERNAME }}
        github_token: ${{ secrets.PROJECT_GITHUB_TOKEN }}
        gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
        gpg_private_key_id: ${{ secrets.GPG_PRIVATE_KEY_ID }}
        plugins_list: "@release-it/conventional-changelog@latest,@release-it/bumper@latest"
        ssh_passphrase: ${{ secrets.SSH_PASSPHRASE }}
        ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}

[!NOTE] GitHub Actions mandates running containers as root to align with GitHub's requirements. Consequently, when executing a GitHub Action involving containerization, it runs with root privileges. For additional details, refer the official documentation from GitHub here.

Acknowledgment

This project is only possible due to the existence of release-it and all its contributors for the great work.

License

This project is licensed under the MIT License. See the LICENSE file.

Support Information