@@ -3,8 +3,9 @@ version: '3'
33silent : true
44
55vars :
6- PR_TEMPLATE : https://raw.githubusercontent.com/devops-infra/.github/master/PULL_REQUEST_TEMPLATE.md
7- TEMPLATE_REPO_BASE_URL : https://raw.githubusercontent.com/devops-infra/template-action/refs/heads/master
6+ PR_TEMPLATE : https://raw.githubusercontent.com/devops-infra/.github/refs/tags/v1/PULL_REQUEST_TEMPLATE.md
7+ CONFIGS_BASE_URL : https://raw.githubusercontent.com/devops-infra/.github/refs/tags/v1/templates/actions/configs
8+ TASKFILES_BASE_URL : https://raw.githubusercontent.com/devops-infra/.github/refs/tags/v1/templates/actions/taskfiles
89
910tasks :
1011 pre-commit :
@@ -98,9 +99,12 @@ tasks:
9899 desc : Update version in README.md and action.yml
99100 cmds :
100101 - |
101- # check if VERSION if different than VERSION_FROM_ACTION_YML
102- if [ "{{.VERSION}}" = "{{.VERSION_FROM_ACTION_YML}}" ]; then
103- echo "❌ ERROR: VERSION is same as VERSION_FROM_ACTION_YML ({{.VERSION}})"
102+ if [ -z "{{.VERSION}}" ]; then
103+ echo "❌ ERROR: VERSION is empty"
104+ exit 1
105+ fi
106+ if ! echo "{{.VERSION}}" | grep -Eq '^v?[0-9]+\.[0-9]+\.[0-9]+$'; then
107+ echo "❌ ERROR: VERSION '{{.VERSION}}' is not a valid semantic version (expected vX.Y.Z or X.Y.Z)"
104108 exit 1
105109 fi
106110 - echo Updating full version from {{.VERSION_FROM_ACTION_YML}} to {{.VERSION}}
@@ -129,6 +133,53 @@ tasks:
129133 cmds :
130134 - task version:set VERSION=v{{.NEXT_MAJOR}}.0.0
131135
136+ version:resolve-next :
137+ desc : Resolve next version from bump type and profile
138+ cmds :
139+ - |
140+ set -eu
141+ bump_type="${BUMP_TYPE:-patch}"
142+ input_version="${INPUT_VERSION:-}"
143+
144+ normalize_version() {
145+ candidate="${1#v}"
146+ if ! printf "%s" "${candidate}" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then
147+ return 1
148+ fi
149+ printf "v%s" "${candidate}"
150+ }
151+
152+ current="$(task version:get 2>/dev/null || true)"
153+
154+ case "$bump_type" in
155+ set)
156+ [ -n "$input_version" ] || { echo "Missing version for type=set"; exit 1; }
157+ next="$(normalize_version "$input_version")" || {
158+ echo "Invalid explicit version: $input_version. Expected vX.Y.Z or X.Y.Z"
159+ exit 1
160+ }
161+ ;;
162+ patch|minor|major)
163+ [ -n "$current" ] || { echo "Current version not found or invalid. Expected vX.Y.Z"; exit 1; }
164+ current="$(normalize_version "$current")" || { echo "Current version not found or invalid. Expected vX.Y.Z"; exit 1; }
165+ no_v="${current#v}"
166+ major="$(printf "%s" "$no_v" | awk -F. '{print $1}')"
167+ minor="$(printf "%s" "$no_v" | awk -F. '{print $2}')"
168+ patch="$(printf "%s" "$no_v" | awk -F. '{print $3}')"
169+ case "$bump_type" in
170+ patch) next="v${major}.${minor}.$((patch + 1))" ;;
171+ minor) next="v${major}.$((minor + 1)).0" ;;
172+ major) next="v$((major + 1)).0.0" ;;
173+ esac
174+ ;;
175+ *)
176+ echo "Unknown type: $bump_type"
177+ exit 1
178+ ;;
179+ esac
180+
181+ printf "%s" "$next"
182+
132183 version:tag-release :
133184 desc : Create set of git tags
134185 cmds :
@@ -214,65 +265,43 @@ tasks:
214265 - git config user.email "github-actions[bot]@users.noreply.github.com"
215266
216267 sync:all :
217- desc : Sync all files with template-action
268+ desc : Sync all common files
218269 cmds :
219270 - task sync:configs
220271 - task sync:ignores
221272 - task sync:taskfiles
222- - task sync:workflows
223273
224274 sync:configs :
225- desc : Sync configuration files with template-action
275+ desc : Sync configuration files with devops-infra/.github
226276 cmds :
227277 - |
228- echo "▶️ Syncing configuration files from template-action ..."
229- curl -sL {{.TEMPLATE_REPO_BASE_URL }}/.editorconfig -o ./.editorconfig
230- curl -sL {{.TEMPLATE_REPO_BASE_URL }}/.hadolint.yaml -o ./.hadolint.yaml
231- curl -sL {{.TEMPLATE_REPO_BASE_URL }}/.pre-commit-config.yaml -o ./.pre-commit-config.yaml
232- curl -sL {{.TEMPLATE_REPO_BASE_URL }}/.shellcheckrc -o ./.shellcheckrc
233- curl -sL {{.TEMPLATE_REPO_BASE_URL }}/.yamllint.yml -o ./.yamllint.yml
278+ echo "▶️ Syncing configuration files from devops-infra/.github ..."
279+ curl -fsSL {{.CONFIGS_BASE_URL }}/.editorconfig -o ./.editorconfig
280+ curl -fsSL {{.CONFIGS_BASE_URL }}/.hadolint.yaml -o ./.hadolint.yaml
281+ curl -fsSL {{.CONFIGS_BASE_URL }}/.pre-commit-config.yaml -o ./.pre-commit-config.yaml
282+ curl -fsSL {{.CONFIGS_BASE_URL }}/.shellcheckrc -o ./.shellcheckrc
283+ curl -fsSL {{.CONFIGS_BASE_URL }}/.yamllint.yml -o ./.yamllint.yml
234284 git add .editorconfig .hadolint.yaml .pre-commit-config.yaml .shellcheckrc .yamllint.yml
235285 echo "✅ Synced configuration files"
236286
237287 sync:ignores :
238- desc : Sync ignore files with template-action
288+ desc : Sync ignore files with devops-infra/.github
239289 cmds :
240290 - |
241- echo "▶️ Syncing ignore files from template-action ..."
242- curl -sL {{.TEMPLATE_REPO_BASE_URL }}/.gitignore -o ./.gitignore
243- curl -sL {{.TEMPLATE_REPO_BASE_URL }}/.dockerignore -o ./.dockerignore
291+ echo "▶️ Syncing ignore files from devops-infra/.github ..."
292+ curl -fsSL {{.CONFIGS_BASE_URL }}/.gitignore -o ./.gitignore
293+ curl -fsSL {{.CONFIGS_BASE_URL }}/.dockerignore -o ./.dockerignore
244294 git add .gitignore .dockerignore
245295 echo "✅ Synced ignore files"
246296
247297 sync:taskfiles :
248- desc : Sync Taskfiles with template-action
298+ desc : Sync Taskfiles with devops-infra/.github
249299 cmds :
250300 - |
251- echo "▶️ Syncing Taskfiles from template-action ..."
252- curl -sL {{.TEMPLATE_REPO_BASE_URL }}/Taskfile.yml -o ./Taskfile.yml
253- curl -sL {{.TEMPLATE_REPO_BASE_URL }}/Taskfile.cicd.yml -o ./Taskfile.cicd.yml
254- curl -sL {{.TEMPLATE_REPO_BASE_URL }}/Taskfile.docker.yml -o ./Taskfile.docker.yml
255- curl -sL {{.TEMPLATE_REPO_BASE_URL }}/Taskfile.variables.yml -o ./Taskfile.variables.yml
301+ echo "▶️ Syncing Taskfiles from devops-infra/.github ..."
302+ curl -fsSL {{.TASKFILES_BASE_URL }}/Taskfile.yml -o ./Taskfile.yml
303+ curl -fsSL {{.TASKFILES_BASE_URL }}/Taskfile.cicd.yml -o ./Taskfile.cicd.yml
304+ curl -fsSL {{.TASKFILES_BASE_URL }}/Taskfile.docker.yml -o ./Taskfile.docker.yml
305+ curl -fsSL {{.TASKFILES_BASE_URL }}/Taskfile.variables.yml -o ./Taskfile.variables.yml
256306 git add Taskfile*.yml
257307 echo "✅ Synced Taskfiles"
258-
259- sync:workflows :
260- desc : Sync GitHub workflows with template-action
261- cmds :
262- - |
263- echo "▶️ Syncing GitHub workflows from template-action..."
264- mkdir -p .github/workflows
265- curl -sL {{.TEMPLATE_REPO_BASE_URL}}/.github/workflows/auto-create-pull-request.yml \
266- -o ./.github/workflows/auto-create-pull-request.yml
267- curl -sL {{.TEMPLATE_REPO_BASE_URL}}/.github/workflows/auto-create-release.yml \
268- -o ./.github/workflows/auto-create-release.yml
269- curl -sL {{.TEMPLATE_REPO_BASE_URL}}/.github/workflows/cron-check-dependencies.yml \
270- -o ./.github/workflows/cron-check-dependencies.yml
271- curl -sL {{.TEMPLATE_REPO_BASE_URL}}/.github/workflows/manual-sync-common-files.yml \
272- -o ./.github/workflows/manual-sync-common-files.yml
273- curl -sL {{.TEMPLATE_REPO_BASE_URL}}/.github/workflows/manual-update-version.yml \
274- -o ./.github/workflows/manual-update-version.yml
275- curl -sL {{.TEMPLATE_REPO_BASE_URL}}/.github/dependabot.yml \
276- -o ./.github/dependabot.yml
277- git add .github/workflows/
278- echo "✅ Synced GitHub workflows"
0 commit comments