-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rebuild axosyslog image with auto patch version increment #411
base: main
Are you sure you want to change the base?
Conversation
2762970
to
c6c4a45
Compare
I would like to provide a test job run (from my fork) here (AxoSyslog stable image), but until now it fails every time on image build. update: |
c6c4a45
to
ab1ede8
Compare
9ec7b0c
to
ff36c55
Compare
- this is for automatically update python libraries Signed-off-by: Andras Mitzki <[email protected]>
- after this change next docker tag will automatically calculated in a following way: - if actual git tag version is greater than previous docker tag example: current git tag: 4.10.0 last docker tag: 4.9.0-2 next docker tag: 4.10.0-1 - if actual git tag version is equals with previous docker tag example: current git tag: 4.9.0 last docker tag: 4.9.0-2 next docker tag: 4.9.0-3 - if actual git tag version is less than previous docker tag, than compare script will display a warning and will exit Signed-off-by: Andras Mitzki <[email protected]>
b78243d
to
4391192
Compare
The PR is ready for the review.
for example:
for example:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This must have been really difficult to test properly, thank you for going through everything.
tags: type=match,pattern=axosyslog-([0-9].*),group=1 | ||
sep-tags: ',' | ||
run: | | ||
previous_docker_tag=$(skopeo inspect docker://ghcr.io/axoflow/axosyslog:latest | jq '.RepoTags' | sed 's/ \|"\|,//g' | grep "^[0-9]*.[0-9]*.[0-9]*$\|^[0-9]*.[0-9]*.[0-9]*-[0-9]*$" | tail -n 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jq --raw-output '.RepoTags.[]'
produces the desired output, so the sed can be removed.
tags: type=match,pattern=axosyslog-([0-9].*),group=1 | ||
sep-tags: ',' | ||
run: | | ||
previous_docker_tag=$(skopeo inspect docker://ghcr.io/axoflow/axosyslog:latest | jq '.RepoTags' | sed 's/ \|"\|,//g' | grep "^[0-9]*.[0-9]*.[0-9]*$\|^[0-9]*.[0-9]*.[0-9]*-[0-9]*$" | tail -n 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a problem with the skopeo
query: it returns all tags, not the corresponding version for latest
.
I think I have an idea how to query the exact version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very verbose, but it works. Let me know what you think:
- name: "Query previous container image version"
uses: actions/github-script@v7
with:
script: |
const versionPattern = /^[0-9]+\.[0-9]+\.[0-9]+-[0-9]+$/;
const package_name = "axosyslog", org = "axoflow";
const allPackageVersions = await github.paginate(
github.rest.packages.getAllPackageVersionsForPackageOwnedByOrg,
{ package_type: "container", package_name, org }
);
const latest = allPackageVersions.find(p =>
p.metadata.container?.tags.includes("latest")
);
const { data: { metadata: { container: { tags } } } } =
await github.rest.packages.getPackageVersionForOrganization({
package_type: "container", package_name, org, package_version_id: latest.id
});
previousDockerTag = tags.find(t => versionPattern.test(t));
core.exportVariable('previous_docker_tag', previousDockerTag);
After this step, you will get 4.9.0-2
in the $previous_docker_tag
variable, and you can use in your script.
previous_docker_tag=$(skopeo inspect docker://ghcr.io/axoflow/axosyslog:latest | jq '.RepoTags' | sed 's/ \|"\|,//g' | grep "^[0-9]*.[0-9]*.[0-9]*$\|^[0-9]*.[0-9]*.[0-9]*-[0-9]*$" | tail -n 1) | ||
previous_docker_tag_short=$(echo $previous_docker_tag | cut -d"-" -f1) | ||
previous_docker_tag_patch=$(echo $previous_docker_tag | cut -d"-" -f2) | ||
current_git_tag=$(echo ${{ github.ref }} | cut -d"-" -f2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to make sure everything below this line is skipped when github.ref is not a version tag.
We use this job to produce nightly and snapshot builds as well.
current_git_tag=$(echo ${{ github.ref }} | cut -d"-" -f2) | ||
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d\n", $1,$2,$3); }'; } | ||
if [ $(version $current_git_tag) -gt $(version $previous_docker_tag_short) ]; then | ||
echo "Given git tag version is greater than previous docker tag version: $current_git_tag > $previous_docker_tag_short" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we have debugged everything, we could replace this echo with something like this:
New AxoSyslog release detected (new version: , previous docker version: )
next_docker_tag=$current_git_tag | ||
echo "Next docker version tag: $next_docker_tag_with_patch" | ||
elif [ $(version $current_git_tag) -eq $(version $previous_docker_tag_short) ]; then | ||
echo "Given git tag version is equals with previous docker tag version: $current_git_tag == $previous_docker_tag_short" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AxoSyslog image rebuild detected (version: )
echo "Next docker version tag: $next_docker_tag_with_patch" | ||
else | ||
echo "Given git tag version is less than previous docker tag version: $current_git_tag < $previous_docker_tag_short" | ||
echo "This is not allowed. Please provide a valid git tag version." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebuilding an older AxoSyslog version is not allowed
run: | | ||
previous_docker_tag=$(skopeo inspect docker://ghcr.io/axoflow/axosyslog:latest | jq '.RepoTags' | sed 's/ \|"\|,//g' | grep "^[0-9]*.[0-9]*.[0-9]*$\|^[0-9]*.[0-9]*.[0-9]*-[0-9]*$" | tail -n 1) | ||
previous_docker_tag_short=$(echo $previous_docker_tag | cut -d"-" -f1) | ||
previous_docker_tag_patch=$(echo $previous_docker_tag | cut -d"-" -f2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: this is the rebuild number, not the patch part.
After this PR when we request a new stable image job the axosyslog patch version will increment automatically