@@ -74,24 +74,46 @@ jobs:
74
74
ruby-version : ' 3.3'
75
75
bundler-cache : true
76
76
77
- - name : Check if version has changed
77
+ - name : Check if version needs publishing
78
78
id : check_version
79
79
run : |
80
- VERSION=$(ruby -r ./lib/ruby_llm/version.rb -e "puts RubyLLM::VERSION")
81
- echo "Current version: $ VERSION"
80
+ VERSION_FILE=" ./lib/ruby_llm/version.rb"
81
+ VERSION=$(ruby -r $VERSION_FILE -e "puts RubyLLM:: VERSION" 2>/dev/null)
82
82
83
- # Fetch all versions including prereleases
84
- ALL_VERSIONS=$(gem list ruby_llm -r --prerelease | grep -oE '[0-9a-zA-Z\.\-]+')
85
- echo "Available versions: $ALL_VERSIONS"
83
+ if [ -z "$VERSION" ]; then
84
+ echo "Error: Could not extract VERSION from $VERSION_FILE" >&2
85
+ exit 1
86
+ fi
87
+ echo "Local version: $VERSION"
88
+
89
+ GEM_NAME="ruby_llm"
90
+ echo "Fetching published versions for '$GEM_NAME'..."
91
+
92
+ # Combine results from --all and --prerelease, extract, clean, unique sort
93
+ ALL_PUBLISHED_VERSIONS=$(( \
94
+ gem list ^${GEM_NAME}$ -r --all 2>/dev/null || true; \
95
+ gem list ^${GEM_NAME}$ -r --prerelease 2>/dev/null || true; \
96
+ ) | sed -n 's/.*(\(.*\)).*/\1/p' \
97
+ | tr ',' '\n' \
98
+ | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' \
99
+ | grep . \
100
+ | sort -u )
101
+
102
+ echo "Checking against published versions:"
103
+ if [ -n "$ALL_PUBLISHED_VERSIONS" ]; then
104
+ echo "$ALL_PUBLISHED_VERSIONS" | sed 's/^/ /' # Log found versions nicely
105
+ else
106
+ echo " (none found)"
107
+ fi
86
108
87
- # Check if current version is among published versions
88
- if echo "$ALL_VERSIONS" | grep -Fxq "$VERSION"; then
89
- echo "Version $VERSION already published, skipping publish"
109
+ if echo "$ALL_PUBLISHED_VERSIONS" | grep -Fxq "$VERSION"; then
110
+ echo "Verdict: Version $VERSION already published."
90
111
echo "version_changed=false" >> $GITHUB_OUTPUT
91
112
else
92
- echo "Version $VERSION is new"
113
+ echo "Verdict: Version $VERSION is new. "
93
114
echo "version_changed=true" >> $GITHUB_OUTPUT
94
115
fi
116
+ shell : bash
95
117
96
118
- name : Test with real APIs before publishing
97
119
if : steps.check_version.outputs.version_changed == 'true'
0 commit comments