makit 0.0.166 → 0.0.167
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/makit/azure-pipelines.rb +49 -0
- data/lib/makit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 981ebe579212bb1f5564fce546f684024510145881af327602af27d2e7203f81
|
|
4
|
+
data.tar.gz: 52404ee70c5a81b6f3feaa250b29cb992121d86d8728c1b318aea2a5c02c16f3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 16c11cbd1fd9090703402f5a43f1dad8d44c5f13e5ce5d75610fb866f096b8b5ab6392fb576f25b799912e3c849e7242849d7a10e02410708b3675f37da527d1
|
|
7
|
+
data.tar.gz: ee847b727077884e1d777f8286e2483e72c89644c3b726955536cf0ccca62fe805bc667efb500924a5d61560d78f0b5777af83ef00cb0af4410b3e4807efded6
|
|
@@ -134,6 +134,55 @@ module Makit
|
|
|
134
134
|
exit 1
|
|
135
135
|
end
|
|
136
136
|
end
|
|
137
|
+
# Publishes a NuGet package to an Azure DevOps feed
|
|
138
|
+
#
|
|
139
|
+
# @param package_name [String] The name of the NuGet package
|
|
140
|
+
# @param package_version [String] The version of the package
|
|
141
|
+
# @param package_file [String] Path to the .nupkg file
|
|
142
|
+
# @param feed_source [String] The name of the Azure DevOps feed
|
|
143
|
+
# @param api_key [String, nil] Optional API key (defaults to "az" for Azure CLI)
|
|
144
|
+
# @raise [RuntimeError] If the push fails and it's not a duplicate package error
|
|
145
|
+
def self.publish(package_name:, package_version:, package_file:, feed_source:, api_key: "az")
|
|
146
|
+
puts " Checking if package #{package_name} version #{package_version} already exists in feed..."
|
|
147
|
+
|
|
148
|
+
# Check if package version already exists
|
|
149
|
+
list_command = "dotnet nuget list \"#{package_name}\" --source \"#{feed_source}\" --api-key #{api_key}"
|
|
150
|
+
list_output = `#{list_command} 2>&1`
|
|
151
|
+
list_exit_code = $?.exitstatus
|
|
152
|
+
|
|
153
|
+
if list_exit_code == 0 && list_output.include?(package_version)
|
|
154
|
+
puts " Package #{package_name} version #{package_version} already exists in feed. Skipping push."
|
|
155
|
+
elsif list_exit_code != 0 && list_output =~ /401|Unauthorized|credential/i
|
|
156
|
+
puts " Authentication failed when checking feed. Will attempt to push anyway."
|
|
157
|
+
puts " (To check manually, run: #{list_command} --interactive)"
|
|
158
|
+
push_package(package_file: package_file, feed_source: feed_source, api_key: api_key, package_name: package_name, package_version: package_version)
|
|
159
|
+
else
|
|
160
|
+
puts " Package #{package_name} version #{package_version} not found in feed (or unable to verify). Attempting to push..."
|
|
161
|
+
push_package(package_file: package_file, feed_source: feed_source, api_key: api_key, package_name: package_name, package_version: package_version)
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
private
|
|
166
|
+
|
|
167
|
+
def self.push_package(package_file:, feed_source:, api_key:, package_name:, package_version:)
|
|
168
|
+
push_command = "dotnet nuget push \"#{package_file}\" --source \"#{feed_source}\" --api-key #{api_key} --skip-duplicate"
|
|
169
|
+
push_output = `#{push_command} 2>&1`
|
|
170
|
+
push_exit_code = $?.exitstatus
|
|
171
|
+
|
|
172
|
+
if push_exit_code == 0
|
|
173
|
+
puts " Package pushed successfully to #{feed_source} feed."
|
|
174
|
+
elsif push_output =~ /already exists|conflict|409/i
|
|
175
|
+
puts " Package #{package_name} version #{package_version} already exists in feed. This is expected."
|
|
176
|
+
else
|
|
177
|
+
puts " Error pushing package to #{feed_source} feed:"
|
|
178
|
+
puts push_output
|
|
179
|
+
puts ""
|
|
180
|
+
puts " To retry manually, run:"
|
|
181
|
+
puts " #{push_command} --interactive"
|
|
182
|
+
puts ""
|
|
183
|
+
raise "Failed to push package to #{feed_source} feed"
|
|
184
|
+
end
|
|
185
|
+
end
|
|
137
186
|
end
|
|
138
187
|
end
|
|
139
188
|
|
data/lib/makit/version.rb
CHANGED