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
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ name: Release
# The result is a draft GitHub release; publish it by hand after review.
on:
push:
tags: ["v*"]
# Only version tags; the moving major and minor tags (v1, v1.2) are not
# releases.
tags: ["v[0-9]+.[0-9]+.[0-9]+*"]

permissions:
contents: write
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/version-tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Version tags

# Keeps the major and minor tags (v1, v1.2) on the newest published release in
# their line, so "uses: devblac/docker-lint@v1" gets every compatible update.
# Publishing a patch for an older line leaves the newer lines' tags alone.
on:
release:
types: [published]

permissions:
contents: write

jobs:
tags:
if: ${{ !github.event.release.prerelease }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7

- name: Move the major and minor tags
env:
TAG: ${{ github.event.release.tag_name }}
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
if ! printf '%s' "$TAG" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "$TAG is not a vX.Y.Z release; leaving the version tags alone"
exit 0
fi

minor="${TAG%.*}"
major="${minor%.*}"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
for line in "$major" "$minor"; do
newest="$(gh release list --exclude-drafts --exclude-pre-releases \
--limit 1000 --json tagName --jq "[.[].tagName | select(startswith(\"$line.\"))
| select(test(\"^v[0-9]+\\\\.[0-9]+\\\\.[0-9]+\$\"))]
| sort_by(ltrimstr(\"v\") | split(\".\") | map(tonumber)) | last // empty")"
if [ "$newest" != "$TAG" ]; then
echo "$line stays on $newest"
continue
fi
# A release event checks out the release's tag, so GITHUB_SHA is its commit.
git tag --force --annotate "$line" --message "$line -> $TAG" "$GITHUB_SHA"
git push --force origin "refs/tags/$line"
echo "$line -> $TAG"
done
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Major and minor version tags for the GitHub Action: `@v0` and `@v0.1` follow
the newest release in their line and install that release of docker-lint, as
does `version: v0`

## [0.1.1] - 2026-10-24

First published release. The Changed, Removed and Fixed sections describe
Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ release, so nothing is public until a maintainer publishes it.
6. Publishing the release runs the Image workflow, which pushes
`ghcr.io/devblac/docker-lint` for linux/amd64 and linux/arm64. The first time,
make the package public in its settings on GitHub; packages start out private.
It also runs the Version tags workflow, which moves the major and minor tags
(`v0`, `v0.1`) to the release when it is the newest in their line. Never push
those tags by hand.

## Questions?

Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ steps:
|-------|---------|-------------|
| `dockerfile` | `Dockerfile` | Files, directories or glob patterns to lint, one per line |
| `config` | | Configuration file (default: `.docker-lint.yaml` at the repository root) |
| `version` | action's tag | docker-lint release to install: by default the one matching the action's tag (`@v0.1.1` installs v0.1.1), or the latest release when the action is used from a branch. Also `latest` or a tag such as `v0.1.1` |
| `version` | action's tag | docker-lint release to install: by default the one matching the action's tag (`@v0.1.1` installs v0.1.1, `@v0` the newest v0.x.y), or the latest release when the action is used from a branch. Also `latest`, a tag such as `v0.1.1` or a line such as `v0` |
| `format` | `github` | Log output: `github` (annotations), `text`, `json` or `sarif` |
| `strict` | `false` | Fail on warnings, not only on errors |
| `quiet` | `false` | Hide informational findings |
Expand All @@ -358,8 +358,11 @@ steps:
| `exit-code` | docker-lint's exit code: `0` clean, `1` lint errors (or warnings with `strict`), `2` fatal error |
| `sarif-file` | Path of the SARIF report, when one was written |

Pinning the action pins the linter: `@v0.1.1` installs docker-lint v0.1.1. When you pin the action to a commit
SHA, also set `version` to the matching tag; otherwise the latest release is installed.
Pinning the action pins the linter: `@v0.1.1` installs docker-lint v0.1.1. To get fixes and new rules
without editing the workflow, use `@v0` (or `@v0.1` for fixes only): these tags follow the newest release in
their line, and the action installs that release. Bear in mind that a new rule can fail a build that passed
before. When you pin the action to a commit SHA, also set `version` to the matching tag; otherwise the latest
release is installed.

The action fails the step with docker-lint's exit code and exposes it as the `exit-code` output. A SARIF
report is still written and uploaded when the lint fails, and covers every Dockerfile that could be parsed;
Expand Down
32 changes: 24 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ inputs:
version:
description: >-
docker-lint release to use. By default, the release matching the tag the
action is used at (uses: devblac/docker-lint@v1.2.3 installs v1.2.3), or
the latest release when the action is used from a branch or commit. Also
accepts "latest", a tag such as "v0.1.1", or "source" to build the
action's own checkout (needs Go; used to test the action).
action is used at (uses: devblac/docker-lint@v1.2.3 installs v1.2.3, and
@v1 the newest v1.x.y), or the latest release when the action is used
from a branch or commit. Also accepts "latest", a tag such as "v0.1.1", a
line such as "v0" or "v0.1", or "source" to build the action's own
checkout (needs Go; used to test the action).
default: ""
format:
description: >-
Expand Down Expand Up @@ -95,12 +96,16 @@ runs:
mkdir -p "$bin_dir"

# Pinning the action pins the linter: by default, install the release
# whose tag the action is used at. The runner checks the action out
# under .../_actions/<owner>/<repo>/<ref>, which also gives the ref when
# github.action_ref is empty, as it is in some nested composite actions.
# whose tag the action is used at. A major or minor tag (v1, v1.2)
# installs the newest release in that line. The runner checks the action
# out under .../_actions/<owner>/<repo>/<ref>, which also gives the ref
# when github.action_ref is empty, as it is in some nested composite
# actions.
semver='^v[0-9]+\.[0-9]+\.[0-9]+([-+][0-9A-Za-z.-]+)?$'
line='^v[0-9]+(\.[0-9]+)?$'
if [ -z "$VERSION" ]; then
ref="${ACTION_REF:-$(basename "$ACTION_PATH")}"
if printf '%s' "$ref" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+([-+][0-9A-Za-z.-]+)?$'; then
if printf '%s' "$ref" | grep -Eq "$semver|$line"; then
VERSION="$ref"
else
VERSION=latest
Expand All @@ -115,6 +120,17 @@ runs:
tag="$VERSION"
if [ "$tag" = latest ]; then
tag="$(gh release view --repo "$repo" --json tagName --jq .tagName)"
elif printf '%s' "$tag" | grep -Eq "$line"; then
# The prefix passed the check above, so it is safe inside the filter.
tag="$(gh release list --repo "$repo" --exclude-drafts --exclude-pre-releases \
--limit 1000 --json tagName --jq "[.[].tagName | select(startswith(\"$tag.\"))
| select(test(\"^v[0-9]+\\\\.[0-9]+\\\\.[0-9]+\$\"))]
| sort_by(ltrimstr(\"v\") | split(\".\") | map(tonumber)) | last // empty")"
if [ -z "$tag" ]; then
echo "::error::docker-lint: no published release matches $VERSION"
exit 1
fi
echo "docker-lint: $VERSION resolves to $tag"
fi
ext=tar.gz
if [ "$os" = windows ]; then ext=zip; fi
Expand Down
Loading