From 0761e453713eae0c4492b9f31840da0134f2dbeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nick=20J=C3=BCttner?= Date: Thu, 27 Jun 2024 11:30:32 +0200 Subject: [PATCH] Fix CAPZ workflows and CircleCi Jobs (#1295) * Fix CAPZ workflows and CircleCi Jobs * Fix CAPZ workflows and CircleCi Jobs * Indent * skip release.yaml when not found * undo --- .circleci/provider_config.yml | 2 +- .github/workflows/create-release.yaml | 68 +++++++++++++++++---------- 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/.circleci/provider_config.yml b/.circleci/provider_config.yml index 5920b80be..97e640d4f 100644 --- a/.circleci/provider_config.yml +++ b/.circleci/provider_config.yml @@ -102,7 +102,7 @@ workflows: name: push-releases-to-azure-app-collection app_catalog: releases app_name: releases-azure - app_collection_repo: azure-app-collection + app_collection_repo: capz-app-collection requires: - push-releases-azure-to-releases-catalog filters: diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 83d5cc356..ead9d757c 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -17,13 +17,19 @@ jobs: env: GITHUB_TOKEN: "${{ secrets.TAYLORBOT_GITHUB_ACTION }}" run: | - for aws_release_dir in capa/*; do - if [[ -f $aws_release_dir ]]; then - echo "Skipping file $aws_release_dir" + for provider_dir in capa/* azure/*; do + provider="" + if [[ $provider_dir == capa/* ]]; then + provider="aws" + elif [[ $provider_dir == azure/* ]]; then + provider="azure" + fi + if [[ -f $provider_dir || -z $provider ]]; then + echo "Skipping file or unknown provider $provider_dir" continue fi - aws_release_version="$(basename $aws_release_dir)" - draft_tag_name="draft/aws/$aws_release_version" + release_version="$(basename $provider_dir)" + draft_tag_name="draft/$provider/$release_version" draft_release=$(gh release --repo giantswarm/releases view "$draft_tag_name" --json "id,name,tagName,assets,isDraft,isPrerelease,url" 2>&1 || true) if [ "$draft_release" = "release not found" ]; then echo "Draft release not found for tag $draft_tag_name" @@ -49,19 +55,25 @@ jobs: - name: Create new release tag run: | git fetch --tags - for aws_release_dir in capa/*; do - if [[ -f $aws_release_dir ]]; then - echo "Skipping file $aws_release_dir" + for provider_dir in capa/* capz/*; do + provider="" + if [[ $provider_dir == capa/* ]]; then + provider="aws" + elif [[ $provider_dir == azure/* ]]; then + provider="azure" + fi + if [[ -f $provider_dir || -z $provider ]]; then + echo "Skipping file or unknown provider $provider_dir" continue fi - aws_release_version="$(basename $aws_release_dir)" - echo "Found AWS (CAPA) release $aws_release_version." - tag_name="aws/$aws_release_version" + release_version="$(basename $provider_dir)" + echo "Found $provider release $release_version." + tag_name="$provider/$release_version" if [ $(git tag -l "$tag_name") ]; then - echo "Found existing tag $tag_name for release version $aws_release_version, new tag is not needed." + echo "Found existing tag $tag_name for release version $release_version, new tag is not needed." else - echo "Tag $tag_name for release version $aws_release_version not found, will create it." - tag_message="Workload cluster release $aws_release_version for AWS" + echo "Tag $tag_name for release version $release_version not found, will create it." + tag_message="Workload cluster release $release_version for $provider" git tag -a "$tag_name" -m "$tag_message" git push origin "$tag_name" fi @@ -70,25 +82,31 @@ jobs: env: GITHUB_TOKEN: "${{ secrets.TAYLORBOT_GITHUB_ACTION }}" run: | - for aws_release_dir in capa/*; do - if [[ -f $aws_release_dir ]]; then - echo "Skipping file $aws_release_dir" + for provider_dir in capa/* azure/*; do + provider="" + if [[ $provider_dir == capa/* ]]; then + provider="aws" + elif [[ $provider_dir == azure/* ]]; then + provider="azure" + fi + if [[ -f $provider_dir || -z $provider ]]; then + echo "Skipping file or unknown provider $provider_dir" continue fi - aws_release_version="$(basename $aws_release_dir)" - tag_name="aws/$aws_release_version" + release_version="$(basename $provider_dir)" + tag_name="$provider/$release_version" github_release=$(gh release --repo giantswarm/releases view "$tag_name" --json "id,name,tagName,assets,isDraft,isPrerelease,url" 2>&1 || true) current_commit="$(git rev-parse HEAD)" - release_title="Workload cluster release $aws_release_version for AWS (CAPA)" + release_title="Workload cluster release $release_version for $provider" release_note="This release has been created automatically by GitHub action. CI will be updated to have better release notes here." if [ "$github_release" = "release not found" ]; then - echo "Didn't find a GitHub release for release version $aws_release_version and tag $tag_name. Creating a new release." - if [[ $aws_release_version == *-* ]]; then - gh release create --repo giantswarm/releases --target "$current_commit" --title "$release_title" --notes "$release_note" "$tag_name" "$aws_release_dir/release.yaml" --prerelease + echo "Didn't find a GitHub release for release version $release_version and tag $tag_name. Creating a new release." + if [[ $release_version == *-* ]]; then + gh release create --repo giantswarm/releases --target "$current_commit" --title "$release_title" --notes "$release_note" "$tag_name" "$provider_dir/release.yaml" --prerelease else - gh release create --repo giantswarm/releases --target "$current_commit" --title "$release_title" --notes "$release_note" "$tag_name" "$aws_release_dir/release.yaml" + gh release create --repo giantswarm/releases --target "$current_commit" --title "$release_title" --notes "$release_note" "$tag_name" "$provider_dir/release.yaml" fi else - echo "Found existing GitHub release for release version $aws_release_version and tag $tag_name." + echo "Found existing GitHub release for release version $release_version and tag $tag_name." fi done