Hello All,
I am trying to download packages from my ABC(Source account) AWS Account's CodeArtifact and trying to upload those pypi packges into DEF AWS Account (Destination account).
Problem which I am facing here is, there is one package "me-test" in the ABC account's repository, this package has below verions.
1.0.8 [Latest]. <--- latest flag
1.0.9
1.0.10
1.0.11
but when I upload the packges into the destination repository I am getting "latest" flag on "1.0.9". the expected flag should be on "1.0.8", I have tried deleting and reuploading the complete package, but no luck!
1.0.9 [Latest]. <--- latest flag
1.0.8
1.0.10
1.0.11
I am trying the below method to do this
STEP: 0 (Configure pip and twine)
aws codeartifact login --tool pip --domain "$DST_DOMAIN" --domain-owner "$DST_DOMAIN_OWNER" --repository "$DST_REPOSITORY" --region "$DST_REGION" --profile "$DST_PROFILE"
aws codeartifact login --tool twine --domain "$DST_DOMAIN" --domain-owner "$DST_DOMAIN_OWNER" --repository "$DST_REPOSITORY" --region "$DST_REGION" --profile "$DST_PROFILE"
STEP : 1 (List all the packages from the source repository)
packages=$(aws codeartifact list-packages --domain "$DOMAIN" --repository "$REPOSITORY" --domain-owner "$DOMAIN_OWNER" --region "$REGION" --profile "$PROFILE" --output "$OUTPUT" --upstream BLOCK --publish ALLOW| jq -r '.packages[].package')
STEP:2 (Itterrate over all packages and get their respective versions)
versions=$(aws codeartifact list-package-versions --domain "$DOMAIN" --repository "$REPOSITORY" --format "$FORMAT" --package "$package" --domain-owner "$DOMAIN_OWNER" --region "$REGION" --profile "$PROFILE" --output "$OUTPUT" | jq -r '.versions[].version' | sort -V)
STEP: 3 (Iterate over each version to get the asset files name)
assets=$(aws codeartifact list-package-version-assets --domain "$DOMAIN" --repository "$REPOSITORY" --format "$FORMAT" --package "$package" --domain-owner "$DOMAIN_OWNER" --region "$REGION" --profile "$PROFILE" --output "$OUTPUT" --package-version "$version" | jq -r '.assets[].name')
STEP: 4 (Iterate over each version and download the asset files)
aws codeartifact get-package-version-asset --domain "$DOMAIN" --domain-owner "$DOMAIN_OWNER" --repository "$REPOSITORY" --format "$FORMAT" --package "$package" --package-version "$version" --asset "$asset_name" --profile "$PROFILE" --region "$REGION" "$output_file_name"
Step 5: (Upload the downloaded file to the destination repository)
twine upload --repository codeartifact "$output_file_name"
I think this is because you're using
sort -V
so the versions are now being published "in order", and 1.0.9 is the highest version. If you want to keep the version order in the source repository, drop the -V option to sort (and potentially also use the --sort-by PUBLISHED_TIME option to list-package-versions as well, not sure exactly)."1.0.9" is not the highest number, "1.0.11" is the highest number, and after dropping "sort -V" I tried listing down the all the package verions, I don't see any meta info to get the "PUBLISHED_TIME" field. refere below snippet for the same. https://we.tl/t-lDXL3fXk4B Also the real problem here is, even If I try to perform a manual upload of "1.0.8" version, the uploaded version is not getting "latest" flag. twine upload --repository codeartifact abc-1.0.8-py3-none-any.whl