Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/actions/setup-licensor/action.yml
Original file line number Diff line number Diff line change
@@ -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}"
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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@<commit-hash>
with:
version: v1.2.3
```

| Input | Required | Description |
|-----------|----------|------------------------------------------|
| `version` | yes | Licensor version to install (e.g. `v1.2.3`). |

The action pin (`@<commit-hash>`) 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
Expand Down