123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- $asciiArt = @"
- _____ _____ ______ _____ ______ _ ______ _____ ______
- | __ \| __ \| ____| __ \| ____| | | ____| /\ / ____| ____|
- | |__) | |__) | |__ | |__) | |__ | | | |__ / \ | (___ | |__
- | ___/| _ /| __| | _ /| __| | | | __| / /\ \ \___ \| __|
- | | | | \ \| |____| | \ \| |____| |____| |____ / ____ \ ____) | |____
- |_| |_| \_\______|_| \_\______|______|______/_/ \_\_____/|______|
- "@
- Write-Host $asciiArt
- $registryname="evdevcontainerregistry"
- $fullregistryname="evdevcontainerregistry.azurecr.io"
- $imagerepositoryname="server"
- $default_dev_prefix = "Docker_test_"
- $target_tag="Docker_RC"
- $status = git status --porcelain
- if (-not $status) {
- Write-Output "All changes committed"
- } else {
- Write-Output "There are uncommitted changes"
- exit
- }
- git fetch --tags -f
- $status = git status --porcelain -b
- if (($status -match "ahead") -or ($status -match "behind") -or ($status -match "gone") )
- {
- Write-Output "git branch not synced"
- exit
- }
- else {
- Write-Output "git branch is synced"
- }
- Write-Host "ACR Login....."
- $token = az acr login --name $registryname --expose-token --output tsv --query accessToken
- $user = "00000000-0000-0000-0000-000000000000"
- podman login $fullregistryname -u $user -p $token
- $source_tag = Read-Host "Please type the source tag that you want to do RC."
- if (-not $source_tag) {
- $username = az account show --query user.name
- $username = $username.TrimStart("""").Split('@')[0]
- $source_tag=$default_dev_prefix+$username
- }
- $sourcetag_response = Read-Host "Do you want to do the RC tag with $source_tag ?(Y/N)"
- while($sourcetag_response -eq "N")
- {
- $source_tag = Read-Host "Please type the source tag that you want to do RC."
-
- if (-not $source_tag) {
- $source_tag=$default_dev_prefix+$username
- }
- $sourcetag_response = Read-Host "Do you want to do the RC tag with $source_tag ?(Y/N)"
- }
- $fulltag=$registryname+".azurecr.io/"+$imagerepositoryname+":"+$targettag
- $source_imagename = $imagerepositoryname+":"+$source_tag
- $target_imagename = $imagerepositoryname+":"+$target_tag
- $source_fulltag = $registryname+".azurecr.io/"+$imagerepositoryname+":"+$source_tag
- $target_fulltag = $registryname+".azurecr.io/"+$imagerepositoryname+":"+$target_tag
- $final_response = Read-Host "Final confirmation: Do you want to assign the RC tag name "$target_imagename" to the existing tag with "$source_imagename"?(Y/N)"
- if($final_response -eq "N")
- {
- write-host "Please restart the process."
- }
- else
- {
-
- $rc_message = git tag -l --format='%(contents)' $target_tag
- if (!$rc_message)
- {
- $rc_message = ""
- }
-
- $filePath = Join-Path -Path (Get-Location) -ChildPath "rc_message.txt"
- [System.IO.File]::WriteAllLines($filePath, $rc_message)
-
- git push --delete origin $target_tag
-
- git tag --delete $target_tag
-
- git tag -a $target_tag -F "rc_message.txt" --edit
-
- git push --follow-tags
-
- Remove-Item "rc_message.txt"
-
-
- az acr repository update --name $registryname --image $target_imagename --delete-enabled true --write-enabled true
- podman pull $source_fulltag
- podman image tag $source_fulltag $target_fulltag
- podman push $target_fulltag
-
- az acr repository update --name $registryname --image $target_imagename --delete-enabled false --write-enabled false
- }
|