Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semantic versioning #256

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 15 additions & 18 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
name:
description: 'Release name'
description: 'Release name ( e.g. "2.1.3" )'
default: ""
required: true

Expand All @@ -19,19 +19,18 @@ jobs:
with:
fetch-depth: 0

- name: Check tag
run: ./scripts/check_release_tag.sh ${{ github.event.inputs.name }}

- name: Check image
run: ./scripts/check_image.sh ${{ github.ref_name }}

- name: Verify
run: ./scripts/verify-status.sh ${{ github.ref_name }}
- name: Verify that the current branch has a name that starts with 'release-'
run: |
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ "$CURRENT_BRANCH" == release-* ]]; then
echo "Branch name starts with 'release-'."
else
echo "Branch name does not start with 'release-'."
exit 1
fi

# run-unit-tests:
# name: Unit tests
# needs: verify-head-status
# uses: "./.github/workflows/run-unit-tests.yaml"
- name: Check image Tag
run: ./scripts/check_tag_info.sh ${{ github.event.inputs.name }}

create-draft:
name: Create draft release
Expand Down Expand Up @@ -62,14 +61,12 @@ jobs:
git tag ${{ github.event.inputs.name }}
git push origin ${{ github.event.inputs.name }}

- name: Verify prow post jobs
run: ./scripts/verify-status.sh ${{ github.ref_name }}

outputs:
release_id: ${{ steps.create-draft.outputs.release_id }}

# devOps-Insights:
# name: DevOps Insights
# needs: [verify-head-status, create-draft, run-unit-tests]
# uses: "./.github/workflows/metrics.yaml"

publish-release:
name: Publish release
needs: [verify-head-status, create-draft]
Expand Down
16 changes: 0 additions & 16 deletions scripts/check_image.sh

This file was deleted.

15 changes: 0 additions & 15 deletions scripts/check_release_tag.sh

This file was deleted.

31 changes: 31 additions & 0 deletions scripts/check_tag_info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

##############################
# Check tags in security-scan-config.yaml
# Image Tag, rc-tag
##############################

# Get release version
DESIRED_TAG="${1:-"main"}"

# Get nats-manager tag from sec-scanners-config.yaml
SEC_SCAN_TO_CHECK="${2:-europe-docker.pkg.dev/kyma-project/prod/nats-manager}"
IMAGE_TAG=$(cat sec-scanners-config.yaml | grep "${SEC_SCAN_TO_CHECK}" | cut -d : -f 2)

# Get rc-tag
RC_TAG_TO_CHECK="${3:-rc-tag}"
RC_TAG=$(cat sec-scanners-config.yaml | grep "${RC_TAG_TO_CHECK}" | cut -d : -f 2 | xargs)

# Check IMAGE_TAG and required image tag
if [[ "$IMAGE_TAG" != "$DESIRED_TAG" ]] || [[ "$RC_TAG" != "$DESIRED_TAG" ]]; then
# ERROR: Tag issue
echo "Tags are not correct:
- wanted: $DESIRED_TAG
- security-scanner image tag: $IMAGE_TAG
- rc-tag: $RC_TAG"
exit 1
fi

# OK: Everything is fine
echo "Tags are correct"
exit 0
88 changes: 74 additions & 14 deletions scripts/verify-status.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,79 @@
#!/usr/bin/env bash

echo "Checking status of POST Jobs for Eventing-Manager"

REF_NAME="${1:-"main"}"
TIMEOUT_TIME="${2:-600}"
INTERVAL_TIME="${3:-3}"

echo "Checking status of POST Jobs for NATS-Manager"
# Generate job Status URL
STATUS_URL="https://api.github.com/repos/kyma-project/eventing-manager/commits/${REF_NAME}/status"

REF_NAME="${1:-"main"}"
STATUS_URL="https://api.github.com/repos/kyma-project/nats-manager/commits/${REF_NAME}/status"
fullstatus=`curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" ${STATUS_URL} | head -n 2 `

sleep 10
echo $fullstatus

if [[ "$fullstatus" == *"success"* ]]; then
echo "All jobs succeeded"
else
echo "Jobs failed or pending - Check Prow status"
exit 1
fi
# Dates
START_TIME=$(date +%s)
TODAY_DATE=$(date '+%Y-%m-%d')

# Retry function
function retry {
# The want_status will determine, when this script succeeds
local want_status="${1-success}"
# Get status result
local statusresult=$(curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" ${STATUS_URL})

# Get overall state
fullstatus=$(echo $statusresult | jq '.state' | tr -d '"')

# Collect latest run related data
local latestrun=$(echo $statusresult | jq '.statuses[-1]')
local latestrun_state=$(echo $latestrun | jq '.state' | tr -d '"')
local latestrun_createdat=$(echo $latestrun | jq '.created_at' | tr -d '"')
local latestrun_targeturl=$(echo $latestrun | jq '.target_url' | tr -d '"')

# Check Today's run data
if [[ $latestrun_createdat == *"$TODAY_DATE"* ]]; then
echo $latestrun_createdat
echo $latestrun_state
echo $latestrun_targeturl
fi

# Show all execution for Today
echo $statusresult | jq --arg t $TODAY_DATE '.statuses[]|select(.created_at | contains($t))'

# Date time for time-out
local CURRENT_TIME=$(date +%s)
local elapsed_time=$((CURRENT_TIME - START_TIME))

# Check time-out
if [ $elapsed_time -ge $TIMEOUT_TIME ]; then
echo "Timeout reached. Exiting."
exit 1
fi

if [ "$fullstatus" == "success" ]; then
echo "Success!"
elif [ "$fullstatus" == "failed" ]; then
# Show overall state to user
echo "$statusresult"
echo "Failure! Exiting with an error."
exit 1
elif [ "$fullstatus" == "pending" ]; then
echo "Status is '$fullstatus'. Retrying in $INTERVAL_TIME seconds..."
sleep $INTERVAL_TIME
else
echo "Invalid result: $result"
exit 1
fi
}

# First, we want the status to change from 'success' to 'pending',
# which means the release build job was triggered.
retry "pending"
while [ "$fullstatus" == "success" ]; do
retry "pending"
done

# Then we want the status to change from 'pending' to 'success',
# which means the release build job was finished successfuly.
while [ "$fullstatus" == "pending" ]; do
retry "success"
done
Loading