Incorrect "Latest" tag on CodeArtifact Package version [pypi]

0

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

Naman
질문됨 일 년 전549회 조회
1개 답변
0

Hello

I investigated about this issue and I would like to inform you that you can get the current latest version in source account by checking defaultDisplayVersion in the list-package-versions command [1] output . Moreover you can also get the published time from the describe-package-version command output , for complete reference please check [2] .

As suggested, you need to update the logic accordingly to either sort the package versions by published time and then deploy or opt to deploy the version with latest tag at the end, after all other version are uploaded .

Reference link : [1]:https://docs.aws.amazon.com/cli/latest/reference/codeartifact/list-package-versions.html
 [2]: https://docs.aws.amazon.com/cli/latest/reference/codeartifact/describe-package-version.html

AWS
지원 엔지니어
답변함 일 년 전
  • Hello!

    Thanks for the information about the logic of getting the latest package version in order. I am already able to do this in my script. Also, I even tried publishing the specific package version (e.g. 1.0.8) manually in CodeArtifact but every time "latest" flag is getting marked on "1.0.9" version. In my opinion, I feel like this is a flag marking bug.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠