Skip to content

chore(ci): update to handle release tags#26166

Merged
jdstrand merged 2 commits intomainfrom
jdstrand/release-updates
Mar 19, 2025
Merged

chore(ci): update to handle release tags#26166
jdstrand merged 2 commits intomainfrom
jdstrand/release-updates

Conversation

@jdstrand
Copy link
Copy Markdown
Contributor

This updates:

  • .circleci/packages/config.yaml to add a stricter regex for release images that conforms to https://github.com/influxdata/influxdb_pro/pull/606#issuecomment-2734361619 with documentation
  • .circleci/config.yml to use the latest ci-support images (to fix an issue with v3.0.0 and deb packages observed in preparing this PR)
  • .circleci/config.yml to update release_filter (a looser regex than .circleci/packages/config.yaml for easier maintenance; .circleci/packages/config.yaml needs to be the most precise version so it can create packages correctly) and add some documentation on how to set tags (based on and referring to .circleci/packages/config.yaml)

The .circleci/packages/config.yaml updates were verified by running the updated ci-support locally. The regexes were verified by creating a test script and running it.

Details
#!/bin/bash
set -e

# copy from .circleci/packages/config.yaml
packager_regex="^v[0-9]+\.[0-9]+\.[0-9]+(-([2-9]|[1-9][0-9]+|0\.(alpha|beta|rc)\.[1-9][0-9]*(\.[1-9][0-9]*)?))?$"
# copy from .circleci/config.yml
circleci_regex="/^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+(\.(alpha|beta|rc)\.[0-9]+(\.[0-9]+)?)?)?$/"

valid_tags="v3.0.0-0.alpha.1 v3.0.0-0.alpha.1.1 v3.0.0-0.alpha.1.2 v3.0.0-0.alpha.2 v3.0.0-0.beta.1 v3.0.0-0.beta.1.1 v3.0.0-0.beta.2 v3.0.0-0.rc.1 v3.0.0 v3.0.0-2 v3.0.1 v3.1.0"
invalid_tags="3.0.0 3.0.0-0.beta.1 v3 v3.0 v3.0. v3.0.0-0 v3.0.0-1 v3.0.0-0.foo.1 v3.0.0-1.alpha.1 v3.0.0-0.alpha.0 v3.0.0-0.alpha.1.0"

echo "# Valid tags (packager)"
for tag in $valid_tags ; do
    printf "%s is valid tag: " "$tag"
    python3 -c "import re, sys; print(bool(re.match(r'$packager_regex', sys.argv[1])))" "$tag"
done

echo
echo "# Invalid tags (packager)"
for badtag in $invalid_tags ; do
    printf "%s is valid tag: " "$badtag"
    python3 -c "import re, sys; print(bool(re.match(r'$packager_regex', sys.argv[1])))" "$badtag"
done

echo
echo "# Valid tags (java.util.regex.Pattern (CircleCI))"
tmpdir=$(mktemp -d)
cd "$tmpdir"

# convert to string that java expects
java_regex=$(echo "${circleci_regex}" | sed -e 's#^/\(.*\)/$#\1#' -e 's/\\/\\\\/g')

cat > RegexMatcher.java <<EOM
public class RegexMatcher {
    public static void main(String[] args) {
        if (args.length < 1) {
            System.out.println("Please provide an argument to match.");
            System.exit(1);
        }

        String r = "$java_regex";
        boolean b = java.util.regex.Pattern.matches(r, args[0]);
        System.out.println(b);
    }
}
EOM
javac RegexMatcher.java
for tag in $valid_tags ; do
    printf "%s is valid tag: " "$tag"
    java RegexMatcher "$tag"
done

cd - >/dev/null
rm -rf "$tmpdir"

echo
echo "# Valid versions (deb)"
last=
for tag in $valid_tags ; do
    v=$(echo "$tag" | sed 's/^v//')
    # note, 3.0.0-1 is generated by packager for the v3.0.0 tag
    if echo "$v" | grep -vq '\-' ; then
        v="${v}-1"
    fi

    if [ -z "$last" ]; then
        last="$v"
	continue
    fi

    printf "dpkg --compare-versions %s lt %s: " "$last" "$v"
    if dpkg --compare-versions "$last" lt "$v" ; then
        echo yes
    else
        echo NO
    fi

    last="$v"
done

Eg:

$ bash /tmp/test_versions
# Valid tags (packager)
v3.0.0-0.alpha.1 is valid tag: True
v3.0.0-0.alpha.1.1 is valid tag: True
v3.0.0-0.alpha.1.2 is valid tag: True
v3.0.0-0.alpha.2 is valid tag: True
v3.0.0-0.beta.1 is valid tag: True
v3.0.0-0.beta.1.1 is valid tag: True
v3.0.0-0.beta.2 is valid tag: True
v3.0.0-0.rc.1 is valid tag: True
v3.0.0 is valid tag: True
v3.0.0-2 is valid tag: True
v3.0.1 is valid tag: True
v3.1.0 is valid tag: True

# Invalid tags (packager)
3.0.0 is valid tag: False
3.0.0-0.beta.1 is valid tag: False
v3 is valid tag: False
v3.0 is valid tag: False
v3.0. is valid tag: False
v3.0.0-0 is valid tag: False
v3.0.0-1 is valid tag: False
v3.0.0-0.foo.1 is valid tag: False
v3.0.0-1.alpha.1 is valid tag: False
v3.0.0-0.alpha.0 is valid tag: False
v3.0.0-0.alpha.1.0 is valid tag: False

# Valid tags (java.util.regex.Pattern (CircleCI))
v3.0.0-0.alpha.1 is valid tag: true
v3.0.0-0.alpha.1.1 is valid tag: true
v3.0.0-0.alpha.1.2 is valid tag: true
v3.0.0-0.alpha.2 is valid tag: true
v3.0.0-0.beta.1 is valid tag: true
v3.0.0-0.beta.1.1 is valid tag: true
v3.0.0-0.beta.2 is valid tag: true
v3.0.0-0.rc.1 is valid tag: true
v3.0.0 is valid tag: true
v3.0.0-2 is valid tag: true
v3.0.1 is valid tag: true
v3.1.0 is valid tag: true

# Valid versions (deb)
dpkg --compare-versions 3.0.0-0.alpha.1 lt 3.0.0-0.alpha.1.1: yes
dpkg --compare-versions 3.0.0-0.alpha.1.1 lt 3.0.0-0.alpha.1.2: yes
dpkg --compare-versions 3.0.0-0.alpha.1.2 lt 3.0.0-0.alpha.2: yes
dpkg --compare-versions 3.0.0-0.alpha.2 lt 3.0.0-0.beta.1: yes
dpkg --compare-versions 3.0.0-0.beta.1 lt 3.0.0-0.beta.1.1: yes
dpkg --compare-versions 3.0.0-0.beta.1.1 lt 3.0.0-0.beta.2: yes
dpkg --compare-versions 3.0.0-0.beta.2 lt 3.0.0-0.rc.1: yes
dpkg --compare-versions 3.0.0-0.rc.1 lt 3.0.0-1: yes
dpkg --compare-versions 3.0.0-1 lt 3.0.0-2: yes
dpkg --compare-versions 3.0.0-2 lt 3.0.1-1: yes
dpkg --compare-versions 3.0.1-1 lt 3.1.0-1: yes

Note, I did NOT test this with by pushing a conforming tag.

@jdstrand jdstrand requested a review from praveen-influx March 19, 2025 14:58
@jdstrand jdstrand force-pushed the jdstrand/release-updates branch from bbf6d0a to 10075ee Compare March 19, 2025 15:00
Comment thread .circleci/config.yml
Copy link
Copy Markdown
Contributor

@praveen-influx praveen-influx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks for the detailed docs, this probably needs to be linked to README so that it's easier to find this info but I can do that.

@jdstrand jdstrand merged commit 8bb09e4 into main Mar 19, 2025
1 check passed
@jdstrand jdstrand deleted the jdstrand/release-updates branch August 15, 2025 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants