Commit 197fb15
authored
Fix --tag parameter to properly push tags and update latest (#168)
Fix --tag parameter to properly push tags and update latest
Motivation
----------
The --tag parameter was accepted by containertool but had no effect on
the
actual tags pushed to the registry. When running:
swift package build-container-image --repository ghcr.io/org/image --tag
v1.0.0
The image was only pushed to `ghcr.io/org/image:latest` (the default
reference
from --repository), while the output misleadingly reported
`ghcr.io/org/image:v1.0.0`.
This made it impossible to publish versioned releases using the --tag
flag.
Modifications
-------------
- Collect all tags to publish: the --tag value (if provided) plus the
default
reference from --repository (typically 'latest')
- Push the manifest and index to each tag in the collection
- Skip duplicate pushes when --tag matches the repository reference
- Return the --tag reference (if provided) as the primary result
Result
------
When --tag is provided, the image is pushed to both the specified tag
AND the
default reference:
--tag v1.0.0 → pushes to v1.0.0 and latest
--tag latest → pushes to latest (once, no duplicate)
(no --tag) → pushes to latest (existing behavior)
Test Plan
---------
1. Build with --tag flag: `swift package build-container-image
--repository ghcr.io/org/image --tag v1.0.0`
2. Verify both tags exist: `docker pull ghcr.io/org/image:v1.0.0` and
`docker pull ghcr.io/org/image:latest`
3. Build with --tag latest: verify no errors and single push
4. Build without --tag: verify existing behavior unchanged1 parent e10069f commit 197fb15
File tree
1 file changed
+43
-41
lines changed- Sources/containertool/Extensions
1 file changed
+43
-41
lines changedLines changed: 43 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
192 | 191 | | |
193 | 192 | | |
194 | | - | |
| 193 | + | |
195 | 194 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
208 | 201 | | |
209 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
210 | 205 | | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
216 | 218 | | |
217 | | - | |
218 | | - | |
219 | | - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
220 | 224 | | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
229 | 228 | | |
230 | 229 | | |
| 230 | + | |
231 | 231 | | |
232 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
233 | 235 | | |
234 | 236 | | |
0 commit comments