Skip to content

Commit

Permalink
feat: Attempt to delete a sliding tag from GitHub Container Registry
Browse files Browse the repository at this point in the history
  • Loading branch information
fmarek-kindred committed May 27, 2024
1 parent cd957d8 commit 5edf6ea
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 16 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/ghcr_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: ghcr.io Publish
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]'
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-[a-zA-Z]+'
- 'v[0-9]+.[0-9]+.[0-9]+(-[a-zA-Z]+)+.[0-9]?'

Expand All @@ -33,7 +33,11 @@ jobs:
echo $RELEASE_VERSION
echo ${{ env.RELEASE_VERSION }}
- name: Build and publish "Lock Manager" image
run: bash bin/ghcr-publish.sh lock-manager $RELEASE_VERSION "y"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bash bin/ghcr-publish.sh lock-manager $RELEASE_VERSION "y" $GITHUB_TOKEN

- name: Build and publish "Brownie" image
run: bash bin/ghcr-publish.sh brownie $RELEASE_VERSION "y"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bash bin/ghcr-publish.sh brownie $RELEASE_VERSION "y" $GITHUB_TOKEN
45 changes: 41 additions & 4 deletions bin/ghcr-publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -e
application=$1
version=$2
makeAdditionalTag=$3
gitHubToken=$4

if [ "${makeAdditionalTag}" == "" ];
then
Expand All @@ -26,6 +27,7 @@ push_tag() {
echo "all args = $@"
application=$1
version=$2
isSlidingTag=$3

tagWithVersion=$application:$version
echo "tagWithVersion=${tagWithVersion}"
Expand All @@ -41,6 +43,26 @@ push_tag() {

echo "docker build --tag $tagRef ."
docker build --tag "${tagRef}" .

# # after we successfully build the image we can push the tag
# if [ "${isSlidingTag}" == "true" ];
# then
# echo "Fetching versions tag ${version}"
# curl -v -L \
# -X GET \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${gitHubToken}" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# "https://api.github.com/user/packages/container/kindredgroup/pit-toolkit/$application/versions"
# echo "Removing previous sliding tag ${version}"
# curl -L \
# -X DELETE \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${gitHubToken}" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# "https://api.github.com/user/packages/container/kindredgroup/pit-toolkit/$application/$version"
# fi

echo "docker push ${tagRef}"
docker push "${tagRef}"
echo ""
Expand All @@ -49,10 +71,9 @@ push_tag() {
home=$(pwd)
echo "cd $application"
cd $application
push_tag "${application}" "${version}"

if [ "${makeAdditionalTag}" == "n" ];
then
push_tag "${application}" "${version}"
exit 0
fi

Expand Down Expand Up @@ -92,9 +113,25 @@ fi
majorMinorVersion="${array[0]}.${array[1]}"
echo "Computed majorMinorVersion=${majorMinorVersion}"

push_tag "${application}" "${majorMinorVersion}"

cd $home

tagWithVersion=$application:$version
echo "tagWithVersion=${tagWithVersion}"
tagRef=ghcr.io/kindredgroup/pit-toolkit/$tagWithVersion
echo "tagRef=${tagRef}"
echo ""

echo "docker build --tag $tagRef ."
docker build --tag "${tagRef}" .
shortTagRef=ghcr.io/kindredgroup/pit-toolkit/$application:$majorMinorVersion
docker tag "${tagRef}" "${shortTagRef}"
docker images

echo "push -a ghcr.io/kindredgroup/pit-toolkit/$application"
echo "-- before pushing docker iamge --"
docker push -q -a "ghcr.io/kindredgroup/pit-toolkit/$application"
echo "-- after pushing docker iamge --"
cd $home
git tag -f "${majorMinorVersion}"
git push origin tag "${majorMinorVersion}"
echo ""
4 changes: 2 additions & 2 deletions brownie/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion brownie/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "brownie",
"version": "1.1.9-dev",
"version": "1.1.10-dev",
"description": "The resource cleanup application of PIT toolkit",
"type": "module",
"main": "dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions k8s-deployer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion k8s-deployer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kindredgroup/pit-k8s-deployer",
"version": "1.1.9-dev",
"version": "1.1.10-dev",
"description": "The deployment utility for apps designed to run in K8s clusters",
"type": "module",
"main": "dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions lock-manager/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lock-manager/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lock-manager",
"version": "1.1.9-dev",
"version": "1.1.10-dev",
"description": "The lock manager application of PIT toolkit",
"type": "module",
"main": "dist/index.js",
Expand Down

0 comments on commit 5edf6ea

Please sign in to comment.