Skip to content

Commit 7951fca

Browse files
feat: improve workflow linting and update workflow files
1 parent c4ad097 commit 7951fca

9 files changed

Lines changed: 324 additions & 305 deletions

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
# Include
55
!Dockerfile
6-
!entrypoint.sh
76
!LICENSE
87
!README.md
8+
!entrypoint.sh
9+
!pip

.github/workflows/auto-pull-request-create.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
name: (Auto) Pull Request Create
1+
name: (Automatic) Pull Request Create
22

33
on:
44
push:
55
branches-ignore:
66
- master
77
- main
8+
- release/**
89
- dependabot/**
910

1011
permissions:
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: (Automatic) Release Create
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
workflow_dispatch:
9+
inputs:
10+
release_branch:
11+
description: Release branch to publish from (e.g. release/v1.3.0)
12+
required: false
13+
default: ''
14+
type: string
15+
release_version:
16+
description: Explicit release version override (e.g. v1.3.0)
17+
required: false
18+
default: ''
19+
type: string
20+
21+
permissions:
22+
contents: write
23+
pull-requests: read
24+
25+
jobs:
26+
call:
27+
uses: devops-infra/.github/.github/workflows/reusable-auto-release-create.yml@v1
28+
with:
29+
profile: actions
30+
release-branch: ${{ inputs.release_branch }}
31+
release-version: ${{ inputs.release_version }}
32+
secrets: inherit
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: (Manual) Release Branch Prepare
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
type:
7+
description: Bump type
8+
required: false
9+
default: patch
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
- set
16+
version:
17+
description: Explicit version when type="set" (e.g., v1.2.3)
18+
required: false
19+
default: ''
20+
build_only:
21+
description: Build and push artifacts without version bump
22+
required: false
23+
default: false
24+
type: boolean
25+
26+
permissions:
27+
contents: write
28+
packages: write
29+
pull-requests: write
30+
31+
jobs:
32+
call:
33+
uses: devops-infra/.github/.github/workflows/reusable-manual-release-branch-prepare.yml@v1
34+
with:
35+
bump-type: ${{ inputs.type }}
36+
explicit-version: ${{ inputs.version }}
37+
build-and-push-only: ${{ inputs.build_only }}
38+
profile: actions
39+
secrets: inherit

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Intellij
2-
/.idea/
2+
.idea/
33
*.iml
44

55
# Custom
@@ -10,3 +10,10 @@
1010
.envrc
1111
.env
1212
.tmp
13+
14+
# Python
15+
build/
16+
dist/
17+
*.egg-info/
18+
*.pyc
19+
__py

Taskfile.cicd.yml

Lines changed: 12 additions & 207 deletions
Original file line numberDiff line numberDiff line change
@@ -1,273 +1,78 @@
11
version: '3'
2-
32
silent: true
4-
53
vars:
64
PR_TEMPLATE: https://raw.githubusercontent.com/devops-infra/.github/refs/tags/v1/PULL_REQUEST_TEMPLATE.md
75
CONFIGS_BASE_URL: https://raw.githubusercontent.com/devops-infra/.github/refs/tags/v1/templates/actions/configs
86
TASKFILES_BASE_URL: https://raw.githubusercontent.com/devops-infra/.github/refs/tags/v1/templates/actions/taskfiles
9-
107
tasks:
118
pre-commit:
129
desc: Run all pre-commit hooks
1310
cmds:
1411
- pre-commit run --all-files
15-
1612
pre-commit:install:
1713
desc: Install pre-commit hooks
1814
cmds:
1915
- pre-commit install
20-
2116
lint:
2217
desc: Run all linters (Dockerfile, shell scripts, workflows, YAML)
2318
cmds:
2419
- task: lint:actionlint
2520
- task: lint:hadolint
2621
- task: lint:shellcheck
2722
- task: lint:yamllint
28-
2923
lint:actionlint:
3024
desc: Lint GitHub Actions workflows with actionlint
3125
cmds:
32-
- |
33-
echo "▶️ Running actionlint..."
34-
set +e
35-
docker run --rm -i -v "$PWD:/work" -w /work rhysd/actionlint:latest -color
36-
rc=$?
37-
set -e
38-
if [ "$rc" -eq 0 ]; then
39-
echo "✅ actionlint passed"
40-
else
41-
echo "❌ actionlint failed"
42-
exit $rc
43-
fi
44-
26+
- task: scripts:lint:actionlint
4527
lint:hadolint:
4628
desc: Lint Dockerfile with hadolint
4729
cmds:
48-
- |
49-
echo "▶️ Running hadolint..."
50-
set +e
51-
docker run --rm -i -v "$PWD:/work" -w /work hadolint/hadolint:latest-debian < Dockerfile
52-
rc=$?
53-
set -e
54-
if [ "$rc" -eq 0 ]; then
55-
echo "✅ hadolint passed"
56-
else
57-
echo "❌ hadolint failed"
58-
exit $rc
59-
fi
60-
30+
- task: scripts:lint:hadolint
6131
lint:shellcheck:
6232
desc: Lint shell scripts with shellcheck
6333
cmds:
64-
- |
65-
echo "▶️ Running shellcheck..."
66-
set +e
67-
docker run --rm -i -v "$PWD:/work" -w /work koalaman/shellcheck:stable -x -S style entrypoint.sh
68-
rc=$?
69-
set -e
70-
if [ "$rc" -eq 0 ]; then
71-
echo "✅ shellcheck passed"
72-
else
73-
echo "❌ shellcheck failed"
74-
exit $rc
75-
fi
76-
34+
- task: scripts:lint:shellcheck
7735
lint:yamllint:
7836
desc: Lint YAML files with yamllint
7937
cmds:
80-
- |
81-
echo "▶️ Running yamllint..."
82-
set +e
83-
docker run --rm -i -v "$PWD:/work" -w /work cytopia/yamllint -c .yamllint.yml .
84-
rc=$?
85-
set -e
86-
if [ "$rc" -eq 0 ]; then
87-
echo "✅ yamllint passed"
88-
else
89-
echo "❌ yamllint failed"
90-
exit $rc
91-
fi
92-
38+
- task: scripts:lint:yamllint
9339
dependency:update:
94-
desc: Check main dependency not covered by dependabot
40+
desc: 'No-op: no dedicated dependency updater configured for this profile'
9541
cmds:
96-
- |
97-
echo "ℹ️ No dedicated dependency updater configured for this repository."
98-
echo "ℹ️ Dependabot handles GitHub Actions and package metadata updates."
99-
echo "ℹ️ Docker build validation remains the runtime safety net."
100-
42+
- task: scripts:dependency:update
10143
version:set:
10244
desc: Update version in README.md and action.yml
10345
cmds:
104-
- |
105-
if [ -z "{{.VERSION}}" ]; then
106-
echo "❌ ERROR: VERSION is empty"
107-
exit 1
108-
fi
109-
if ! echo "{{.VERSION}}" | grep -Eq '^v?[0-9]+\.[0-9]+\.[0-9]+$'; then
110-
echo "❌ ERROR: VERSION '{{.VERSION}}' is not a valid semantic version (expected vX.Y.Z or X.Y.Z)"
111-
exit 1
112-
fi
113-
- echo Updating full version from {{.VERSION_FROM_ACTION_YML}} to {{.VERSION}}
114-
- echo Updating minor version from {{.MINOR_FROM_ACTION_YML}} to {{.VERSION_MINOR}}
115-
- echo Updating major version from {{.MAJOR_FROM_ACTION_YML}} to {{.VERSION_MAJOR}}
116-
- "{{.SED}} -i 's#{{.DOCKER_NAME}}:{{.VERSION_FROM_ACTION_YML}}#{{.DOCKER_NAME}}:{{.VERSION}}#g' action.yml"
117-
- "{{.SED}} -i 's#{{.DOCKER_NAME}}@{{.VERSION_FROM_ACTION_YML}}#{{.DOCKER_NAME}}@{{.VERSION}}#g' README.md"
118-
- "{{.SED}} -i 's#{{.GITHUB_NAME}}@{{.VERSION_FROM_ACTION_YML}}#{{.GITHUB_NAME}}@{{.VERSION}}#g' README.md"
119-
- "{{.SED}} -i 's#{{.DOCKER_NAME}}@{{.MINOR_FROM_ACTION_YML}}#{{.DOCKER_NAME}}@{{.VERSION_MINOR}}#g' README.md"
120-
- "{{.SED}} -i 's#{{.GITHUB_NAME}}@{{.MINOR_FROM_ACTION_YML}}#{{.GITHUB_NAME}}@{{.VERSION_MINOR}}#g' README.md"
121-
- "{{.SED}} -i 's#{{.DOCKER_NAME}}@{{.MAJOR_FROM_ACTION_YML}}#{{.DOCKER_NAME}}@{{.VERSION_MAJOR}}#g' README.md"
122-
- "{{.SED}} -i 's#{{.GITHUB_NAME}}@{{.MAJOR_FROM_ACTION_YML}}#{{.GITHUB_NAME}}@{{.VERSION_MAJOR}}#g' README.md"
123-
46+
- task: scripts:version:set
12447
version:update:patch:
12548
desc: Increment patch version (e.g., 1.2.3 -> 1.2.4)
12649
cmds:
12750
- task version:set VERSION=v{{.MAJOR}}.{{.MINOR}}.{{.NEXT_PATCH}}
128-
12951
version:update:minor:
13052
desc: Increment minor version (e.g., 1.2.3 -> 1.3.0)
13153
cmds:
13254
- task version:set VERSION=v{{.MAJOR}}.{{.NEXT_MINOR}}.0
133-
13455
version:update:major:
13556
desc: Increment major version (e.g., 1.2.3 -> 2.0.0)
13657
cmds:
13758
- task version:set VERSION=v{{.NEXT_MAJOR}}.0.0
138-
13959
version:resolve-next:
14060
desc: Resolve next version from bump type and profile
14161
cmds:
142-
- |
143-
set -eu
144-
bump_type="${BUMP_TYPE:-patch}"
145-
input_version="${INPUT_VERSION:-}"
146-
147-
normalize_version() {
148-
candidate="${1#v}"
149-
if ! printf "%s" "${candidate}" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then
150-
return 1
151-
fi
152-
printf "v%s" "${candidate}"
153-
}
154-
155-
current="$(task version:get 2>/dev/null || true)"
156-
157-
case "$bump_type" in
158-
set)
159-
[ -n "$input_version" ] || { echo "Missing version for type=set"; exit 1; }
160-
next="$(normalize_version "$input_version")" || {
161-
echo "Invalid explicit version: $input_version. Expected vX.Y.Z or X.Y.Z"
162-
exit 1
163-
}
164-
;;
165-
patch|minor|major)
166-
[ -n "$current" ] || { echo "Current version not found or invalid. Expected vX.Y.Z"; exit 1; }
167-
current="$(normalize_version "$current")" || { echo "Current version not found or invalid. Expected vX.Y.Z"; exit 1; }
168-
no_v="${current#v}"
169-
major="$(printf "%s" "$no_v" | awk -F. '{print $1}')"
170-
minor="$(printf "%s" "$no_v" | awk -F. '{print $2}')"
171-
patch="$(printf "%s" "$no_v" | awk -F. '{print $3}')"
172-
case "$bump_type" in
173-
patch) next="v${major}.${minor}.$((patch + 1))" ;;
174-
minor) next="v${major}.$((minor + 1)).0" ;;
175-
major) next="v$((major + 1)).0.0" ;;
176-
esac
177-
;;
178-
*)
179-
echo "Unknown type: $bump_type"
180-
exit 1
181-
;;
182-
esac
183-
184-
printf "%s" "$next"
185-
62+
- task: scripts:version:resolve-next
18663
version:tag-release:
18764
desc: Create set of git tags
18865
cmds:
189-
- |
190-
set -eu
191-
if (set -o | grep -q pipefail) 2>/dev/null; then set -o pipefail; fi
192-
193-
REMOTE='origin'
194-
FULL='{{.VERSION_FULL}}'
195-
MINOR='{{.VERSION_MINOR}}'
196-
MAJOR='{{.VERSION_MAJOR}}'
197-
198-
# Validate vX.Y.Z
199-
if ! printf "%s" "$FULL" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
200-
echo "❌ ERROR: VERSION '$FULL' must match vX.Y.Z" >&2
201-
exit 1
202-
fi
203-
204-
tag_sha() { git rev-parse "refs/tags/$1" 2>/dev/null || true; }
205-
remote_tag_sha() { git ls-remote --tags "$REMOTE" "refs/tags/$1" 2>/dev/null | awk '{print $1}' || true; }
206-
207-
echo "ℹ️ INFO: Tags - Full: $FULL | Minor: $MINOR | Major: $MAJOR"
208-
209-
# Full tag: must NOT exist on remote; fail fast if it does
210-
full_remote_sha="$(remote_tag_sha "$FULL")"
211-
if [ -n "$full_remote_sha" ]; then
212-
echo "❌ ERROR: Full tag '$FULL' already exists on remote; aborting" >&2
213-
exit 1
214-
fi
215-
216-
# Create full tag locally (if missing) and push
217-
if git rev-parse --quiet --verify "refs/tags/$FULL" >/dev/null 2>&1; then
218-
echo "ℹ️ INFO: Full tag '$FULL' exists locally but not on remote; pushing"
219-
else
220-
echo "ℹ️ INFO: Creating full tag '$FULL'"
221-
git tag --annotate "$FULL" --message "$FULL"
222-
fi
223-
git push "$REMOTE" "refs/tags/$FULL"
224-
echo "✅ OK: Pushed full tag '$FULL'"
225-
226-
# Minor tag: create or update
227-
git tag --force --annotate "$MINOR" --message "$FULL"
228-
minor_local_sha="$(tag_sha "$MINOR")"
229-
minor_remote_sha="$(remote_tag_sha "$MINOR")"
230-
if [ -z "$minor_remote_sha" ]; then
231-
git push "$REMOTE" "refs/tags/$MINOR"
232-
echo "✅ OK: Created and pushed minor tag '$MINOR' -> $minor_local_sha"
233-
else
234-
if [ "$minor_local_sha" != "$minor_remote_sha" ]; then
235-
echo "⚠️ WARN: Updating remote minor tag '$MINOR' to $minor_local_sha (was $minor_remote_sha)"
236-
git push --force "$REMOTE" "refs/tags/$MINOR"
237-
else
238-
echo "ℹ️ INFO: Minor tag '$MINOR' already up-to-date"
239-
fi
240-
fi
241-
242-
# Major tag: create or update
243-
git tag --force --annotate "$MAJOR" --message "$FULL"
244-
major_local_sha="$(tag_sha "$MAJOR")"
245-
major_remote_sha="$(remote_tag_sha "$MAJOR")"
246-
if [ -z "$major_remote_sha" ]; then
247-
git push "$REMOTE" "refs/tags/$MAJOR"
248-
echo "✅ OK: Created and pushed major tag '$MAJOR' -> $major_local_sha"
249-
else
250-
if [ "$major_local_sha" != "$major_remote_sha" ]; then
251-
echo "⚠️ WARN: Updating remote major tag '$MAJOR' to $major_local_sha (was $major_remote_sha)"
252-
git push --force "$REMOTE" "refs/tags/$MAJOR"
253-
else
254-
echo "ℹ️ INFO: Major tag '$MAJOR' already up-to-date"
255-
fi
256-
fi
257-
66+
- task: scripts:version:tag-release
25867
git:get-pr-template:
25968
desc: Get pull request template
26069
cmds:
261-
- mkdir -p .tmp
262-
- curl -LsS {{.PR_TEMPLATE}} -o .tmp/PULL_REQUEST_TEMPLATE.md
263-
70+
- task: scripts:git:get-pr-template
26471
git:set-config:
26572
desc: Set git user config
26673
cmds:
267-
- git config user.name "github-actions[bot]"
268-
- git config user.email "github-actions[bot]@users.noreply.github.com"
269-
74+
- task: scripts:git:set-config
27075
version:get:
27176
desc: Get current version
27277
cmds:
273-
- echo "{{.VERSION}}"
78+
- task: scripts:version:get

0 commit comments

Comments
 (0)