Skip to content

Commit

Permalink
replaced version code with central version action (redhat-cop#567)
Browse files Browse the repository at this point in the history
  • Loading branch information
garethahealy authored Feb 16, 2022
1 parent 742f72f commit e3f3002
Show file tree
Hide file tree
Showing 27 changed files with 189 additions and 195 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/build-s2i-python-kopf-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Check and verify version.json
id: check_version
uses: redhat-cop/github-actions/get-image-version@master
with:
IMAGE_CONTEXT_DIR: ${{ env.CONTEXT_DIR }}

- name: Update Dockerfile version
run: |
# version.json must have semantic version: vMAJOR.MINOR.PATCH
VERSION=$(jq -r '.version' ${CONTEXT_DIR}/version.json)
if [[ ! $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "${CONTEXT_DIR}/version.json does not contain semantic version, vMAJOR.MINOR.PATCH"
exit 1
fi
echo ::set-output name=VERSION::$VERSION
echo ::set-output name=MINOR_VERSION::${VERSION%.*}
sed -i -e "s/^FROM .*/FROM ${IMAGE_NAME}:${VERSION}/" ${CONTEXT_DIR}/examples/kopf-simple/Dockerfile
sed -i -e "s/^FROM .*/FROM ${IMAGE_NAME}:${{ steps.check_version.outputs.VERSION }}/" ${CONTEXT_DIR}/examples/kopf-simple/Dockerfile
- name: Build s2i image
uses: redhat-actions/buildah-build@v2
with:
Expand All @@ -34,6 +33,7 @@ jobs:
image: ${{ env.IMAGE_NAME }}
oci: true
tags: ${{ steps.check_version.outputs.VERSION }}

- name: Build kopf-simple example from s2i image
uses: redhat-actions/buildah-build@v2
with:
Expand All @@ -43,6 +43,7 @@ jobs:
image: ${{ env.IMAGE_NAME }}-example
oci: true
tags: ${{ steps.check_version.outputs.VERSION }}

- name: Test image
run: |
EXAMPLE_IMAGE="${IMAGE_NAME}-example:${{ steps.check_version.outputs.VERSION }}"
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/build-s2i-python-kopf-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Get image tags
id: image_tags
run: |
# version.json should have semantic version: vMAJOR.MINOR.PATCH
VERSION=$(jq -r '.version' ${CONTEXT_DIR}/version.json)
# Publish to latest, minor, and patch tags
TAGS=('latest' "${VERSION}" "${VERSION%.*}")
# Set IMAGE_TAGS output for use in next step
echo "::set-output name=IMAGE_TAGS::${TAGS[*]}"
uses: redhat-cop/github-actions/get-image-version@master
with:
IMAGE_CONTEXT_DIR: ${{ env.CONTEXT_DIR }}

- name: Build image
id: build_image
uses: redhat-actions/buildah-build@v2
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/jenkins-agent-image-mgmt-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: Check and verify version.json
id: check_version
run: |
echo -n ::set-output name=IMAGE_TAGS::
echo $(jq -r '.version' ${context}/version.json)
uses: redhat-cop/github-actions/get-image-version@master
with:
IMAGE_CONTEXT_DIR: ${{ env.context }}

- name: Build image
uses: redhat-actions/buildah-build@v2
with:
Expand All @@ -26,7 +28,8 @@ jobs:
image: ${{ env.image_name }}
oci: true
tags: ${{ steps.check_version.outputs.IMAGE_TAGS }}

- name: Test image
run: |
echo "Running: podman run --entrypoint bash ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} -c \"skopeo --version\""
podman run --entrypoint bash ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} -c "skopeo --version"
echo "Running: podman run --entrypoint bash ${image_name}:${{ steps.check_version.outputs.VERSION }} -c \"skopeo --version\""
podman run --entrypoint bash ${image_name}:${{ steps.check_version.outputs.VERSION }} -c "skopeo --version"
16 changes: 5 additions & 11 deletions .github/workflows/jenkins-agent-image-mgmt-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Get image tags
id: image_tags
run: |
echo -n ::set-output name=IMAGE_TAGS::
VERSION=$(jq -r '.version' ${context}/version.json)
TAGS=('latest')
if [ "${VERSION}" ] && [ "${VERSION}" != "latest" ]; then
TAGS+=("${VERSION}")
fi
if [[ "${GITHUB_REF}" =~ refs/tags/(.*) ]]; then
TAGS+=("git-${BASH_REMATCH[1]}")
fi
echo "${TAGS[*]}"
uses: redhat-cop/github-actions/get-image-version@master
with:
IMAGE_CONTEXT_DIR: ${{ env.context }}

- name: Build image
id: build_image
uses: redhat-actions/buildah-build@v2
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/jenkins-agent-python-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: Check and verify version.json
id: check_version
run: |
echo -n ::set-output name=IMAGE_TAGS::
echo $(jq -r '.version' ${context}/version.json)
uses: redhat-cop/github-actions/get-image-version@master
with:
IMAGE_CONTEXT_DIR: ${{ env.context }}

- name: Build image
uses: redhat-actions/buildah-build@v2
with:
Expand All @@ -26,6 +28,7 @@ jobs:
image: ${{ env.image_name }}
oci: true
tags: ${{ steps.check_version.outputs.IMAGE_TAGS }}

- name: Test image
run: |
echo "Running: podman run ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} python --version"
Expand Down
16 changes: 5 additions & 11 deletions .github/workflows/jenkins-agent-python-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Get image tags
id: image_tags
run: |
echo -n ::set-output name=IMAGE_TAGS::
VERSION=$(jq -r '.version' ${context}/version.json)
TAGS=('latest')
if [ "${VERSION}" ] && [ "${VERSION}" != "latest" ]; then
TAGS+=("${VERSION}")
fi
if [[ "${GITHUB_REF}" =~ refs/tags/(.*) ]]; then
TAGS+=("git-${BASH_REMATCH[1]}")
fi
echo "${TAGS[*]}"
uses: redhat-cop/github-actions/get-image-version@master
with:
IMAGE_CONTEXT_DIR: ${{ env.context }}

- name: Build image
id: build_image
uses: redhat-actions/buildah-build@v2
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/rabbitmq-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: Check and verify version.json
id: check_version
run: |
echo -n ::set-output name=IMAGE_TAGS::
echo $(jq -r '.version' ${context}/version.json)
uses: redhat-cop/github-actions/get-image-version@master
with:
IMAGE_CONTEXT_DIR: ${{ env.context }}

- name: Build image
uses: redhat-actions/buildah-build@v2
with:
Expand All @@ -26,7 +28,8 @@ jobs:
image: ${{ env.image_name }}
oci: true
tags: ${{ steps.check_version.outputs.IMAGE_TAGS }}

- name: Test image
run: |
echo "Running: podman run --entrypoint 'rabbitmqctl' ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} 'version'"
podman run --entrypoint 'rabbitmqctl' ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} 'version'
echo "Running: podman run --entrypoint 'rabbitmqctl' ${image_name}:${{ steps.check_version.outputs.VERSION }} 'version'"
podman run --entrypoint 'rabbitmqctl' ${image_name}:${{ steps.check_version.outputs.VERSION }} 'version'
16 changes: 5 additions & 11 deletions .github/workflows/rabbitmq-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Get image tags
id: image_tags
run: |
echo -n ::set-output name=IMAGE_TAGS::
VERSION=$(jq -r '.version' ${context}/version.json)
TAGS=('latest')
if [ "${VERSION}" ] && [ "${VERSION}" != "latest" ]; then
TAGS+=("${VERSION}")
fi
if [[ "${GITHUB_REF}" =~ refs/tags/(.*) ]]; then
TAGS+=("git-${BASH_REMATCH[1]}")
fi
echo "${TAGS[*]}"
uses: redhat-cop/github-actions/get-image-version@master
with:
IMAGE_CONTEXT_DIR: ${{ env.context }}

- name: Build image
id: build_image
uses: redhat-actions/buildah-build@v2
Expand Down
21 changes: 13 additions & 8 deletions .github/workflows/tekton-task-images-conftest-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Get image tags
id: check_version

- name: Convert VERSION to version.json
run: |
echo -n ::set-output name=IMAGE_TAGS::
# exposes variable CONFTEST_VERSION
source ${context}/VERSION
echo ${CONFTEST_VERSION}
version=$(cat ${{ env.context }}/VERSION | cut -d"=" -f2)
jq -c --null-input --arg version "v$version" '{ "version": $version }' > ${{ env.context }}/version.json
- name: Check and verify version.json
id: check_version
uses: redhat-cop/github-actions/get-image-version@master
with:
IMAGE_CONTEXT_DIR: ${{ env.context }}

- name: Build image
uses: redhat-actions/buildah-build@v2
with:
Expand All @@ -30,5 +35,5 @@ jobs:
tags: ${{ steps.check_version.outputs.IMAGE_TAGS }}
- name: Test image
run: |
echo "Running: podman run ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} conftest version"
podman run ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} conftest --version | grep ${{ steps.check_version.outputs.IMAGE_TAGS }}
echo "Running: podman run ${image_name}:${{ steps.check_version.outputs.VERSION }} conftest version"
podman run ${image_name}:${{ steps.check_version.outputs.VERSION }} conftest --version | grep $(echo ${{ steps.check_version.outputs.VERSION }} | cut -c 2-)
19 changes: 10 additions & 9 deletions .github/workflows/tekton-task-images-conftest-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Convert VERSION to version.json
run: |
version=$(cat ${{ env.context }}/VERSION | cut -d"=" -f2)
jq -c --null-input --arg version "v$version" '{ "version": $version }' > ${{ env.context }}/version.json
- name: Get image tags
id: image_tags
run: |
echo -n ::set-output name=IMAGE_TAGS::
# exposes variable CONFTEST_VERSION
source ${context}/VERSION
TAGS=('latest')
if [ "${CONFTEST_VERSION}" ] && [ "${CONFTEST_VERSION}" != "latest" ]; then
TAGS+=("${CONFTEST_VERSION}")
fi
echo "${TAGS[*]}"
uses: redhat-cop/github-actions/get-image-version@master
with:
IMAGE_CONTEXT_DIR: ${{ env.context }}

- name: Build image
id: build_image
uses: redhat-actions/buildah-build@v2
Expand Down
21 changes: 13 additions & 8 deletions .github/workflows/tekton-task-images-helm-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Get image tags
id: check_version

- name: Convert VERSION to version.json
run: |
echo -n ::set-output name=IMAGE_TAGS::
# exposes variable HELM_VERSION
source ${context}/VERSION
echo ${HELM_VERSION}
version=$(cat ${{ env.context }}/VERSION | cut -d"=" -f2)
jq -c --null-input --arg version "v$version" '{ "version": $version }' > ${{ env.context }}/version.json
- name: Check and verify version.json
id: check_version
uses: redhat-cop/github-actions/get-image-version@master
with:
IMAGE_CONTEXT_DIR: ${{ env.context }}

- name: Build image
uses: redhat-actions/buildah-build@v2
with:
Expand All @@ -30,5 +35,5 @@ jobs:
tags: ${{ steps.check_version.outputs.IMAGE_TAGS }}
- name: Test image contains the version of the binary
run: |
echo "Running: podman run ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} helm version"
podman run ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} helm version | grep ${{ steps.check_version.outputs.IMAGE_TAGS }}
echo "Running: podman run ${image_name}:${{ steps.check_version.outputs.VERSION }} helm version"
podman run ${image_name}:${{ steps.check_version.outputs.VERSION }} helm version | grep ${{ steps.check_version.outputs.VERSION }}
19 changes: 10 additions & 9 deletions .github/workflows/tekton-task-images-helm-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Convert VERSION to version.json
run: |
version=$(cat ${{ env.context }}/VERSION | cut -d"=" -f2)
jq -c --null-input --arg version "v$version" '{ "version": $version }' > ${{ env.context }}/version.json
- name: Get image tags
id: image_tags
run: |
echo -n ::set-output name=IMAGE_TAGS::
# exposes variable HELM_VERSION
source ${context}/VERSION
TAGS=('latest')
if [ "${HELM_VERSION}" ] && [ "${HELM_VERSION}" != "latest" ]; then
TAGS+=("${HELM_VERSION}")
fi
echo "${TAGS[*]}"
uses: redhat-cop/github-actions/get-image-version@master
with:
IMAGE_CONTEXT_DIR: ${{ env.context }}

- name: Build image
id: build_image
uses: redhat-actions/buildah-build@v2
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/ubi7-gitlab-runner-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: Check and verify version.json
id: check_version
run: |
echo -n ::set-output name=IMAGE_TAGS::
echo $(jq -r '.version' ${context}/version.json)
uses: redhat-cop/github-actions/get-image-version@master
with:
IMAGE_CONTEXT_DIR: ${{ env.context }}

- name: Build image
uses: redhat-actions/buildah-build@v2
with:
Expand All @@ -26,9 +28,11 @@ jobs:
image: ${{ env.image_name }}
oci: true
tags: ${{ steps.check_version.outputs.IMAGE_TAGS }}

- name: Test image
run: |
echo "Running: podman run --entrypoint '/bin/sh' ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} -c 'wget --version'"
podman run --entrypoint '/bin/sh' ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} -c 'wget --version'
echo "Running: podman run --entrypoint '/bin/sh' ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} -c 'gitlab-runner --version'"
podman run --entrypoint '/bin/sh' ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} -c 'gitlab-runner --version'
echo "Running: podman run --entrypoint '/bin/sh' ${image_name}:${{ steps.check_version.outputs.VERSION }} -c 'wget --version'"
podman run --entrypoint '/bin/sh' ${image_name}:${{ steps.check_version.outputs.VERSION }} -c 'wget --version'
echo "Running: podman run --entrypoint '/bin/sh' ${image_name}:${{ steps.check_version.outputs.VERSION }} -c 'gitlab-runner --version'"
podman run --entrypoint '/bin/sh' ${image_name}:${{ steps.check_version.outputs.VERSION }} -c 'gitlab-runner --version'
16 changes: 5 additions & 11 deletions .github/workflows/ubi7-gitlab-runner-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Get image tags
id: image_tags
run: |
echo -n ::set-output name=IMAGE_TAGS::
VERSION=$(jq -r '.version' ${context}/version.json)
TAGS=('latest')
if [ "${VERSION}" ] && [ "${VERSION}" != "latest" ]; then
TAGS+=("${VERSION}")
fi
if [[ "${GITHUB_REF}" =~ refs/tags/(.*) ]]; then
TAGS+=("git-${BASH_REMATCH[1]}")
fi
echo "${TAGS[*]}"
uses: redhat-cop/github-actions/get-image-version@master
with:
IMAGE_CONTEXT_DIR: ${{ env.context }}

- name: Build image
id: build_image
uses: redhat-actions/buildah-build@v2
Expand Down
Loading

0 comments on commit e3f3002

Please sign in to comment.