Skip to content

πŸš€ A Containerized release-it to run anywhere

License

Notifications You must be signed in to change notification settings

juancarlosjr97/release-it-containerized

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

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 Variable Description Required
GIT_DIRECTORY Directory path to make it safe to run git changes false
GIT_EMAIL The Git email that will be identified when running release-it false
GIT_REPOSITORY The Git repository of the project to run release-it false
GIT_USERNAME The Git username that will be identified when running release-it false
GPG_PRIVATE_KEY The GPG Private Key false
GPG_PRIVATE_KEY_ID The GPG Private Key ID false
RELEASE_IT_PLUGINS List of comma separated release plugins to run false
SSH_PASSPHRASE SSH Passphrase associated to the SSH Private Key false
SSH_PRIVATE_KEY The SSH Private key associated to the GIT account running release-it false

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="[email protected]" \
    -e GIT_REPOSITORY="[email protected]: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

Field Description Required Default
command Command to execute release-it false ""
git_email Git email to run release-it false ${{ github.actor }}
git_username Git username to run release-it false ${{ github.actor }}@users.noreply.github.com
github_token Github Token to run release-it false ${{ github.token }}
gpg_private_key GPG Private Key false ""
gpg_private_key_id GPG Private Key ID false ""
image_tag Image tag used to pass specific version of the action false latest
plugins_list List of Plugins to run with release-it as comma separated false ""
ssh_passphrase SSH Passphrase false ""
ssh_private_key SSH Private Key false ""
version Release It version false latest

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