Tag chaining with match and semver
Behaviour
My context is kind of mono repository that each project has itself life-cycle.
Currently, I separate GitHub release tag as: project/semver
Steps to reproduce this issue
- Input
# Ref context
refs/tags/project1/v1.0.0
# GH docker meta
tags: type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha
type=match,pattern=project1\/v(.*),group=1
- Output
project1-v1.0.0
It should be 1.0.0 ???
Expected behaviour
I'm wondering how to make tag chaining from match to semver. I have not yet understand prefix/suffix/value for what purpose.
In my case: I expect tag output is
-
1.0.0 -
1.0 -
latest
Another thing, typo in https://github.com/crazy-max/ghaction-docker-meta#typematch
tags: |
type=group,enable=true,priority=800,prefix=,suffix=,pattern=,group=0,value=
Should be type=match?
@zero88
It should be
1.0.0???
That's because your pattern is incorrect I guess. What is the value of GITHUB_REF in your pipeline? I would need the link to your repo to know why. I think I will add more logs in this action to enhance the bug reports.
Also you got project1-v1.0.0 because it matches type=ref,event=tag. But again I would need a link to your repo to be sure.
In my case: I expect tag output is *
1.0.0*1.0*latest
Same as before I would need the link to your repo/workflow to understand what you want and the current behavior.
Should be
type=match?
Yes good catch! Feel free to open a PR to fix the README thanks :)
My current project is private repo, but I can reproduce in my test project.
I updated github_ref in description also:
# Ref context
refs/tags/project1/v1.0.0
That's because your pattern is incorrect I guess
I don't think my pattern is wrong. I guess your implementation normalizes tag with / then regex matching. I tried both escape \/ and non escape /, still doesn't work
Also you got
project1-v1.0.0because it matchestype=ref,event=tag
If I understand your description correctly:
-
type=refpriority = 600 <type=matchpriority = 800,gh-actionhandles greater priority first, then it makes a chaining processmatch->ref - In my case, if I want to transform github tag from
refs/tags/project1/v1.0.0->1.0.0, I need provideghaction inputas:
tags: type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha
type=semver
type=match,pattern=project1\/v(.*),group=1,priority=1000
Then I should receive: 1.0.0, 1.0, latest
@zero88 I have improved the logging. Can you give me the output of the meta step please?
@crazy-max
Please check this one: https://github.com/zero88/gh-test/runs/2267140740?check_suite_focus=true
Compare step project_context (from mine) and docker_context (yours)
It is release workflow.
Other runs seem fine from main to pr: https://github.com/zero88/gh-test/actions/workflows/p1.yml
@zero88 I think the following should work:
tags:
type=match,pattern=p1-v(\d.\d.\d),group=1
type=match,pattern=p1-v(\d.\d),group=1
type=ref,event=pr
type=sha
or
tags:
type=match,pattern=\d.\d.\d
type=match,pattern=\d.\d
type=ref,event=pr
type=sha
@crazy-max Thank you for your response.
After your suggestion, it works. But, 2 points that make me confusing:
-
Regex pattern
-
/will be escaped to-in prepare step then you do regex matching? So iffeature/a/b-cthenfeature-a-b-c? So it doesn't clear to identify which one is/or- - For correcting regex pattern that follow
semver(without pre-release/metadata), it should be\d+\.\d+\.\d+in strict mode. Then12.1.0is valid but1a3.4is invalid
-
-
Priorityproperty: it seems not correct usage, or not yet join a processing party as my expectation in above comment.type=ref priority = 600 < type=match priority = 800, gh-action handles greater priority first, then it makes a chaining process match -> ref
I want to release sub project with tag as
<sub_project_name>/<sem_ver>So, my solution ismatchis first pattern with highest priority then its output will be input of other follow patterns. Do you consider to include this trick in future? I can contribute if you want, but not today, might be next month :)
Click to expand!
Context info
eventName: push
sha: 7bd3423c87f22638de66f435cbe85c496d7c19d8
ref: refs/tags/p1/v1.1.2
workflow: build-p1
action: crazy-maxghaction-docker-meta
actor: zero88
runNumber: 18
runId: 721013978
Processing tags input
type=match,pattern=p1-v(.*),group=1,priority=1000,value=,enable=true,prefix=,suffix=
type=semver,pattern={{major}}.{{minor}},value=,enable=true,priority=900,prefix=,suffix=
type=ref,event=branch,enable=true,priority=600,prefix=,suffix=
type=ref,event=pr,prefix=pr-,enable=true,priority=600,suffix=
type=sha,prefix=sha-,enable=true,priority=100,suffix=
Processing flavor input
latest=auto
prefix=
suffix=
Warning: p1-v1.1.2 is not a valid semver. More info: https://semver.org/
Docker image version
1.1.2
Docker tags
zero88/p1:1.1.2
zero88/p1:sha-7bd3423
zero88/p1:latest
@zero88
/will be escaped to-in prepare step then you do regex matching? So iffeature/a/b-cthenfeature-a-b-c? So it doesn't clear to identify which one is/or-
Yes that's it, I think we should check matches before escaping.
Priorityproperty: it seems not correct usage, or not yet join a processing party as my expectation in above comment.
priority only allows to manage tags sorting.
- So, my solution is
matchis first pattern with highest priority then its output will be input of other follow patterns. Do you consider to include this trick in future? I can contribute if you want, but not today, might be next month :)
We can think about that. Maybe smth like that:
type=match,asref=foo,pattern=p1-v(\d.\d.\d),group=1
type=semver,pattern={{version}},use=foo
Just to help out GitHub issue search: hyphen, dash, slash, path separator.