Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Commit

Permalink
compute BASE_VERSION from makefile declaration of 'VERSION ?= 0.0.1' …
Browse files Browse the repository at this point in the history
…and use that in pr and next tags, so we have separation between releases; this will require that we update the Makefile after every release (eg., 0.0.1, 0.0.2, 0.0.3)

Signed-off-by: RHDH Build (rhdh-bot) <rhdh-bot@redhat.com>

tweak comment: also pushing a :next tag

Signed-off-by: RHDH Build (rhdh-bot) <rhdh-bot@redhat.com>
  • Loading branch information
rhdh-bot committed Jan 9, 2024
1 parent 660e169 commit 81de4ea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 26 deletions.
22 changes: 9 additions & 13 deletions .github/workflows/next-container-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ name: Next Docker Build operator, bundle, and catalog images

on:
push:
branches:
- main
branches: [ main ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -49,6 +48,8 @@ jobs:
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV
BASE_VERSION=$(grep -E "^VERSION \?=" Makefile | sed -r -e "s/.+= //") # 0.0.1
echo "BASE_VERSION=$BASE_VERSION" >> $GITHUB_ENV
- name: Login to quay.io
uses: docker/login-action@v2
Expand All @@ -66,7 +67,7 @@ jobs:
sudo apt-get -y update; sudo apt-get -y install skopeo podman
export CONTAINER_ENGINE=podman
export VERSION=next-${{ env.SHORT_SHA }}
export VERSION=${{ env.BASE_VERSION }}-next-${{ env.SHORT_SHA }}
set -ex
Expand All @@ -75,16 +76,11 @@ jobs:
curl -sSLo /tmp/opm https://github.com/operator-framework/operator-registry/releases/download/v1.33.0/${OS}-${ARCH}-opm && chmod +x /tmp/opm
# build 3 container images with a 14d expiry
CONTAINER_ENGINE=${CONTAINER_ENGINE} VERSION=0.0.1-${VERSION} make release-build
CONTAINER_ENGINE=${CONTAINER_ENGINE} VERSION=${VERSION} make release-build
# now copy images from local cache to quay, using pr-123-f00cafe and pr-123 tags
# now copy images from local cache to quay, using 0.0.1-next-f00cafe, 0.0.1-next, and next tags
for image in operator operator-bundle operator-catalog; do
skopeo --insecure-policy copy --all docker://quay.io/janus/${image}:0.0.1-${VERSION} docker://quay.io/janus/${image}:${VERSION}
skopeo --insecure-policy copy --all docker://quay.io/janus/${image}:0.0.1-${VERSION} docker://quay.io/janus/${image}:${VERSION%-*}
skopeo --insecure-policy copy --all docker://quay.io/janus/${image}:${VERSION} docker://quay.io/janus/${image}:${VERSION}
skopeo --insecure-policy copy --all docker://quay.io/janus/${image}:${VERSION} docker://quay.io/janus/${image}:${VERSION%-*}
skopeo --insecure-policy copy --all docker://quay.io/janus/${image}:${VERSION} docker://quay.io/janus/${image}:next
done
# TODO do we still need this step? verify we can install from the catalog source and if so, this can be deleted
# - name: Adjust operator image and tag in CSV
# run: |
# sed -r -e "s#(image: +)quay.io/.+operator.+#\1quay.io/janus/operator:next-${{ env.SHORT_SHA }}#g" -i bundle/manifests/backstage-operator.clusterserviceversion.yaml
# echo "Operator in CSV changed to: quay.io/janus/operator:next-${{ env.SHORT_SHA }}"
21 changes: 8 additions & 13 deletions .github/workflows/pr-container-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ jobs:
run: |
SHORT_SHA=$(git rev-parse --short ${{ github.event.pull_request.head.sha }})
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV
BASE_VERSION=$(grep -E "^VERSION \?=" Makefile | sed -r -e "s/.+= //") # 0.0.1
echo "BASE_VERSION=$BASE_VERSION" >> $GITHUB_ENV
- name: Login to quay.io
uses: docker/login-action@v2
Expand All @@ -88,7 +90,7 @@ jobs:
sudo apt-get -y update; sudo apt-get -y install skopeo podman
export CONTAINER_ENGINE=podman
export VERSION=pr-${{ github.event.number }}-${{ env.SHORT_SHA }}
export VERSION=${{ env.BASE_VERSION }}-pr-${{ github.event.number }}-${{ env.SHORT_SHA }}
set -ex
Expand All @@ -97,20 +99,13 @@ jobs:
curl -sSLo /tmp/opm https://github.com/operator-framework/operator-registry/releases/download/v1.33.0/${OS}-${ARCH}-opm && chmod +x /tmp/opm
# build 3 container images with a 14d expiry
CONTAINER_ENGINE=${CONTAINER_ENGINE} VERSION=0.0.1-${VERSION} make lint release-build
CONTAINER_ENGINE=${CONTAINER_ENGINE} VERSION=${VERSION} make lint release-build
# now copy images from local cache to quay, using pr-123-f00cafe and pr-123 tags
# now copy images from local cache to quay, using 0.0.1-pr-123-f00cafe and 0.0.1-pr-123 tags
for image in operator operator-bundle operator-catalog; do
skopeo --insecure-policy copy --all docker://quay.io/janus/${image}:0.0.1-${VERSION} docker://quay.io/janus/${image}:${VERSION}
skopeo --insecure-policy copy --all docker://quay.io/janus/${image}:0.0.1-${VERSION} docker://quay.io/janus/${image}:${VERSION%-*}
skopeo --insecure-policy copy --all docker://quay.io/janus/${image}:${VERSION} docker://quay.io/janus/${image}:${VERSION}
skopeo --insecure-policy copy --all docker://quay.io/janus/${image}:${VERSION} docker://quay.io/janus/${image}:${VERSION%-*}
done
# TODO do we still need this step? verify we can install from the catalog source and if so, this can be deleted
# - name: Adjust operator image and tag in CSV
# run: |
# sed -r -e "s#(image: +)quay.io/.+operator.+#\1quay.io/janus/operator:pr-${{ github.event.number }}-${{ env.SHORT_SHA }}#g" -i bundle/manifests/backstage-operator.clusterserviceversion.yaml
# echo "Operator in CSV changed to: quay.io/janus/operator:pr-${{ github.event.number }}-${{ env.SHORT_SHA }}"

- name: Comment image links in PR
uses: actions/github-script@v6
with:
Expand All @@ -120,5 +115,5 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'PR images are available:<br/><ol><li>https://quay.io/janus/operator:pr-${{ github.event.number }}-${{ env.SHORT_SHA }}</li><li>https://quay.io/janus/operator-bundle:pr-${{ github.event.number }}-${{ env.SHORT_SHA }}</li><li>https://quay.io/janus/operator-catalog:pr-${{ github.event.number }}-${{ env.SHORT_SHA }}</li></ol>'
body: 'PR images are available:<br/><ol><li>https://quay.io/janus/operator:${{ env.BASE_VERSION }}-pr-${{ github.event.number }}-${{ env.SHORT_SHA }}</li><li>https://quay.io/janus/operator-bundle:${{ env.BASE_VERSION }}-pr-${{ github.event.number }}-${{ env.SHORT_SHA }}</li><li>https://quay.io/janus/operator-catalog:${{ env.BASE_VERSION }}-pr-${{ github.event.number }}-${{ env.SHORT_SHA }}</li></ol>'
})

0 comments on commit 81de4ea

Please sign in to comment.