diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3d434b1..8ab9222 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Release on: push: tags: - - "v[0-9]+.[0-9]+.[0-9]+" # Semantic versions only (e.g., v1.0.0), excludes action tags (v1) + - "v*" permissions: contents: write diff --git a/README.md b/README.md index 41e9742..2dd651b 100644 --- a/README.md +++ b/README.md @@ -393,7 +393,7 @@ jobs: - uses: actions/checkout@v4 - name: Validate markdown - uses: jackchuka/mdschema@v1 + uses: jackchuka/mdschema@v0.9.1 with: files: "README.md docs/**/*.md" schema: ".mdschema.yml" @@ -401,18 +401,18 @@ jobs: ### Inputs -| Input | Description | Default | -| ------------------- | -------------------------------- | --------------- | -| `version` | mdschema version (e.g., v0.9.1) | `latest` | -| `files` | Files or glob patterns | `**/*.md` | -| `schema` | Path to schema file | `.mdschema.yml` | -| `args` | Additional CLI arguments | (empty) | -| `working-directory` | Working directory for validation | `.` | +| Input | Description | Default | +| ------------------- | ---------------------------------------------- | --------------- | +| `version` | mdschema CLI version (use `latest` for newest) | Action ref | +| `files` | Files or glob patterns | `**/*.md` | +| `schema` | Path to schema file | `.mdschema.yml` | +| `args` | Additional CLI arguments | (empty) | +| `working-directory` | Working directory for validation | `.` | ### Monorepo Example ```yaml -- uses: jackchuka/mdschema@v1 +- uses: jackchuka/mdschema@v0.9.1 with: working-directory: "./packages/docs" files: "**/*.md" diff --git a/action.yml b/action.yml index a88c59e..aed5022 100644 --- a/action.yml +++ b/action.yml @@ -8,9 +8,9 @@ branding: inputs: version: - description: "mdschema version to install (e.g., v0.9.1, latest)" + description: "mdschema version to install. Defaults to the action ref (e.g., @v0.9.1 uses v0.9.1). Use 'latest' to always get the newest release." required: false - default: "latest" + default: "" files: description: "Files or glob patterns to validate" required: false @@ -35,11 +35,20 @@ runs: id: version shell: bash run: | - if [ "${{ inputs.version }}" = "latest" ]; then - VERSION=$(curl -s https://api.github.com/repos/jackchuka/mdschema/releases/latest | grep '"tag_name"' | cut -d'"' -f4) + INPUT_VERSION="${{ inputs.version }}" + ACTION_REF="${{ github.action_ref }}" + + if [ -n "$INPUT_VERSION" ] && [ "$INPUT_VERSION" != "latest" ]; then + # Use explicitly specified version + VERSION="$INPUT_VERSION" + elif [ -n "$ACTION_REF" ] && [ "$INPUT_VERSION" != "latest" ]; then + # Use action ref (e.g., v0.9.1 from @v0.9.1) + VERSION="$ACTION_REF" else - VERSION="${{ inputs.version }}" + # Fallback to latest (for local dev with ./ or explicit 'latest') + VERSION=$(curl -s https://api.github.com/repos/jackchuka/mdschema/releases/latest | grep '"tag_name"' | cut -d'"' -f4) fi + echo "version=${VERSION}" >> $GITHUB_OUTPUT - name: Download mdschema