From 2133604d57eee1b2def613d9311d256274513d73 Mon Sep 17 00:00:00 2001 From: Paillat-dev Date: Sat, 28 Feb 2026 14:07:12 +0100 Subject: [PATCH] :sparkles: Add `setup-licensor` action and document usage in README --- .github/actions/setup-licensor/action.yml | 53 +++++++++++++++++++++++ README.md | 18 ++++++++ 2 files changed, 71 insertions(+) create mode 100644 .github/actions/setup-licensor/action.yml diff --git a/.github/actions/setup-licensor/action.yml b/.github/actions/setup-licensor/action.yml new file mode 100644 index 0000000..e5345e1 --- /dev/null +++ b/.github/actions/setup-licensor/action.yml @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: MIT +# Copyright: 2026 NiceBots.xyz +name: Setup Licensor +description: Download licensor and Temurin 21, add both to PATH. + +inputs: + version: + description: Licensor version to install (e.g. "v1.2.3"). + required: true + +runs: + using: composite + steps: + - name: Set up Java (Temurin 21) + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: "21" + + - name: Download and install licensor + shell: bash + env: + VERSION: ${{ inputs.version }} + run: | + set -euo pipefail + + case "${{ runner.os }}" in + Linux) ASSET="licensor-${VERSION}-linux-x86_64.tar.gz" ;; + macOS) ASSET="licensor-${VERSION}-macos-universal.tar.gz" ;; + Windows) ASSET="licensor-${VERSION}-windows-x86_64.zip" ;; + *) echo "Unsupported OS: ${{ runner.os }}" >&2; exit 1 ;; + esac + + BASE_URL="https://github.com/${{ github.repository }}/releases/download/${VERSION}" + + curl -fsSL "${BASE_URL}/${ASSET}" -o "${ASSET}" + curl -fsSL "${BASE_URL}/SHA256SUMS.txt" -o SHA256SUMS.txt + + grep "${ASSET}" SHA256SUMS.txt | sha256sum -c - + + INSTALL_DIR="${HOME}/.licensor" + mkdir -p "${INSTALL_DIR}" + + case "${{ runner.os }}" in + Linux|macOS) + tar -xzf "${ASSET}" -C "${INSTALL_DIR}" + ;; + Windows) + unzip -q "${ASSET}" -d "${INSTALL_DIR}" + ;; + esac + + echo "${INSTALL_DIR}" >> "${GITHUB_PATH}" \ No newline at end of file diff --git a/README.md b/README.md index 7d8820d..f65ce04 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,24 @@ Use `-c` to point at a different config path, `--ignore` to exclude globs, and ` - `0`: Success (check passes; add did nothing). - `1`: Failure (missing licenses in check, files updated in add, or no inputs matched). +## GitHub Actions + +### `setup-licensor` + +Downloads a licensor release and Temurin 21, then adds both to `PATH`. + +```yaml +- uses: nicebots/licensor/.github/actions/setup-licensor@ + with: + version: v1.2.3 +``` + +| Input | Required | Description | +|-----------|----------|------------------------------------------| +| `version` | yes | Licensor version to install (e.g. `v1.2.3`). | + +The action pin (`@`) and the `version` input are intentionally separate so you can security-pin the action to a specific commit while still choosing which licensor release to download. + ## Inspiration - HashiCorp copywrite: https://github.com/hashicorp/copywrite