Merge pull request #26 from LerianStudio/fix/elasticache-secret-string #38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'templates/**' | |
| - 'products/**' | |
| - 'infrastructure/**' | |
| env: | |
| AWS_REGION: sa-east-1 | |
| S3_BUCKET: lerian-cloudformation-templates | |
| permissions: | |
| contents: write | |
| id-token: write | |
| pull-requests: write | |
| jobs: | |
| # ============================================================================ | |
| # Check Skip Conditions | |
| # ============================================================================ | |
| check-skip: | |
| name: Check Skip | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| outputs: | |
| should_skip: ${{ steps.check.outputs.should_skip }} | |
| steps: | |
| - name: Check if should skip | |
| id: check | |
| env: | |
| COMMIT_MSG: ${{ github.event.head_commit.message }} | |
| run: | | |
| if echo "$COMMIT_MSG" | grep -qiE '\[skip ci\]|chore\(release\)|chore: update template versions'; then | |
| echo "should_skip=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "should_skip=false" >> $GITHUB_OUTPUT | |
| fi | |
| # ============================================================================ | |
| # Detect Changes in templates/ and products/ | |
| # ============================================================================ | |
| detect-changes: | |
| name: Detect Changes | |
| needs: check-skip | |
| if: needs.check-skip.outputs.should_skip != 'true' | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| outputs: | |
| changed_core_templates: ${{ steps.process.outputs.changed_core_templates }} | |
| changed_products: ${{ steps.process.outputs.changed_products }} | |
| has_core_changes: ${{ steps.process.outputs.has_core_changes }} | |
| has_product_changes: ${{ steps.process.outputs.has_product_changes }} | |
| has_changes: ${{ steps.process.outputs.has_changes }} | |
| bump_type: ${{ steps.process.outputs.bump_type }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Process detected changes | |
| id: process | |
| run: | | |
| # Detect changed core templates | |
| CHANGED_CORE=$(git diff --name-only HEAD~1 HEAD -- templates/*.yaml 2>/dev/null || echo "") | |
| # Detect changed product templates | |
| CHANGED_PRODUCTS=$(git diff --name-only HEAD~1 HEAD -- products/ 2>/dev/null || echo "") | |
| HAS_CORE="false" | |
| HAS_PRODUCTS="false" | |
| # Process core templates | |
| if [ -n "$CHANGED_CORE" ]; then | |
| HAS_CORE="true" | |
| CORE_TEMPLATES=$(echo "$CHANGED_CORE" | sed 's|templates/||g' | sed 's|\.yaml||g' | sort -u | jq -R -s -c 'split("\n") | map(select(length > 0))') | |
| echo "Changed core templates: $CORE_TEMPLATES" | |
| echo "changed_core_templates=$CORE_TEMPLATES" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed_core_templates=[]" >> $GITHUB_OUTPUT | |
| fi | |
| # Process product templates - output format: [{"product":"midaz","template":"helm"}, ...] | |
| if [ -n "$CHANGED_PRODUCTS" ]; then | |
| HAS_PRODUCTS="true" | |
| PRODUCT_CHANGES=$(echo "$CHANGED_PRODUCTS" | grep '\.yaml$' | while read -r file; do | |
| product=$(echo "$file" | cut -d'/' -f2) | |
| template=$(basename "$file" .yaml) | |
| echo "{\"product\":\"$product\",\"template\":\"$template\"}" | |
| done | jq -s -c '.') | |
| echo "Changed products: $PRODUCT_CHANGES" | |
| echo "changed_products=$PRODUCT_CHANGES" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed_products=[]" >> $GITHUB_OUTPUT | |
| fi | |
| echo "has_core_changes=$HAS_CORE" >> $GITHUB_OUTPUT | |
| echo "has_product_changes=$HAS_PRODUCTS" >> $GITHUB_OUTPUT | |
| if [ "$HAS_CORE" = "true" ] || [ "$HAS_PRODUCTS" = "true" ]; then | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| fi | |
| # Determine bump type from commit message | |
| COMMIT_MSG=$(git log -1 --pretty=%B) | |
| if echo "$COMMIT_MSG" | grep -qiE "^BREAKING CHANGE:|^[a-z]+(\(.+\))?!:"; then | |
| BUMP_TYPE="major" | |
| elif echo "$COMMIT_MSG" | grep -qiE "^feat(\(.+\))?:"; then | |
| BUMP_TYPE="minor" | |
| else | |
| BUMP_TYPE="patch" | |
| fi | |
| echo "Bump type: $BUMP_TYPE" | |
| echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT | |
| # ============================================================================ | |
| # Release Templates | |
| # ============================================================================ | |
| release-templates: | |
| name: Release Templates | |
| needs: [check-skip, detect-changes] | |
| if: needs.detect-changes.outputs.has_changes == 'true' && needs.check-skip.outputs.should_skip != 'true' | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| outputs: | |
| released_templates: ${{ steps.release.outputs.released_templates }} | |
| template_tags: ${{ steps.release.outputs.template_tags }} | |
| bundle_version: ${{ steps.bundle.outputs.version }} | |
| bundle_tag: ${{ steps.bundle.outputs.tag }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install dependencies | |
| run: pip install cfn-lint pyyaml | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: ${{ secrets.AWS_ROLE_ARN }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Release core templates | |
| id: release-core | |
| if: needs.detect-changes.outputs.has_core_changes == 'true' | |
| env: | |
| CHANGED_TEMPLATES: ${{ needs.detect-changes.outputs.changed_core_templates }} | |
| BUMP_TYPE: ${{ needs.detect-changes.outputs.bump_type }} | |
| run: | | |
| set -e | |
| VERSIONS_FILE="template-versions.json" | |
| TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | |
| RELEASED="" | |
| TAGS="" | |
| for TEMPLATE in $(echo "$CHANGED_TEMPLATES" | jq -r '.[]'); do | |
| echo "" | |
| echo "========================================" | |
| echo "Processing core template: $TEMPLATE" | |
| echo "========================================" | |
| if ! cfn-lint "templates/${TEMPLATE}.yaml" --regions us-east-1 --ignore-checks W; then | |
| echo "Validation failed, skipping" | |
| continue | |
| fi | |
| CURRENT_VERSION=$(jq -r ".templates[\"$TEMPLATE\"] // \"0.0.0\"" "$VERSIONS_FILE") | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION" | |
| case $BUMP_TYPE in | |
| major) NEW_VERSION="$((MAJOR + 1)).0.0" ;; | |
| minor) NEW_VERSION="${MAJOR}.$((MINOR + 1)).0" ;; | |
| patch) NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))" ;; | |
| esac | |
| TAG_NAME="${TEMPLATE}-v${NEW_VERSION}" | |
| if git tag -l "$TAG_NAME" | grep -q "$TAG_NAME"; then | |
| echo "Tag $TAG_NAME exists, skipping" | |
| continue | |
| fi | |
| echo "Releasing $TEMPLATE v$NEW_VERSION" | |
| # Upload to S3 - versioned | |
| aws s3 cp "templates/${TEMPLATE}.yaml" \ | |
| "s3://${{ env.S3_BUCKET }}/templates/${TEMPLATE}/v${NEW_VERSION}/${TEMPLATE}.yaml" \ | |
| --cache-control "max-age=86400" \ | |
| --content-type "application/x-yaml" | |
| # Upload to S3 - latest | |
| aws s3 cp "templates/${TEMPLATE}.yaml" \ | |
| "s3://${{ env.S3_BUCKET }}/templates/${TEMPLATE}/latest/${TEMPLATE}.yaml" \ | |
| --cache-control "max-age=300" \ | |
| --content-type "application/x-yaml" | |
| # Update versions.json in S3 | |
| aws s3 cp "s3://${{ env.S3_BUCKET }}/templates/${TEMPLATE}/versions.json" /tmp/tpl-versions.json 2>/dev/null || \ | |
| echo "{\"template\":\"$TEMPLATE\",\"versions\":[],\"latest\":\"\"}" > /tmp/tpl-versions.json | |
| python3 << PYEOF | |
| import json | |
| with open('/tmp/tpl-versions.json', 'r') as f: | |
| data = json.load(f) | |
| data.get('versions', []).insert(0, {'version': '$NEW_VERSION', 'released_at': '$TIMESTAMP'}) | |
| data['latest'] = '$NEW_VERSION' | |
| with open('/tmp/tpl-versions.json', 'w') as f: | |
| json.dump(data, f, indent=2) | |
| PYEOF | |
| aws s3 cp /tmp/tpl-versions.json "s3://${{ env.S3_BUCKET }}/templates/${TEMPLATE}/versions.json" | |
| # Update local versions file | |
| jq ".templates[\"$TEMPLATE\"] = \"$NEW_VERSION\"" "$VERSIONS_FILE" > /tmp/updated.json | |
| mv /tmp/updated.json "$VERSIONS_FILE" | |
| RELEASED="$RELEASED $TEMPLATE:v$NEW_VERSION" | |
| TAGS="$TAGS $TAG_NAME" | |
| done | |
| echo "released_core=$RELEASED" >> $GITHUB_OUTPUT | |
| echo "core_tags=$TAGS" >> $GITHUB_OUTPUT | |
| - name: Release product templates | |
| id: release-products | |
| if: needs.detect-changes.outputs.has_product_changes == 'true' | |
| env: | |
| CHANGED_PRODUCTS: ${{ needs.detect-changes.outputs.changed_products }} | |
| BUMP_TYPE: ${{ needs.detect-changes.outputs.bump_type }} | |
| run: | | |
| set -e | |
| VERSIONS_FILE="template-versions.json" | |
| TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | |
| RELEASED="" | |
| TAGS="" | |
| for ITEM in $(echo "$CHANGED_PRODUCTS" | jq -r '.[] | @base64'); do | |
| PRODUCT=$(echo "$ITEM" | base64 --decode | jq -r '.product') | |
| TEMPLATE=$(echo "$ITEM" | base64 --decode | jq -r '.template') | |
| echo "" | |
| echo "========================================" | |
| echo "Processing product: $PRODUCT / $TEMPLATE" | |
| echo "========================================" | |
| TEMPLATE_FILE="products/${PRODUCT}/${TEMPLATE}.yaml" | |
| if [ ! -f "$TEMPLATE_FILE" ]; then | |
| echo "File not found: $TEMPLATE_FILE, skipping" | |
| continue | |
| fi | |
| if ! cfn-lint "$TEMPLATE_FILE" --regions us-east-1 --ignore-checks W; then | |
| echo "Validation failed, skipping" | |
| continue | |
| fi | |
| # Ensure product entry exists in versions file | |
| if ! jq -e ".products[\"$PRODUCT\"]" "$VERSIONS_FILE" > /dev/null 2>&1; then | |
| jq ".products[\"$PRODUCT\"] = {}" "$VERSIONS_FILE" > /tmp/updated.json | |
| mv /tmp/updated.json "$VERSIONS_FILE" | |
| fi | |
| CURRENT_VERSION=$(jq -r ".products[\"$PRODUCT\"][\"$TEMPLATE\"] // \"0.0.0\"" "$VERSIONS_FILE") | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION" | |
| case $BUMP_TYPE in | |
| major) NEW_VERSION="$((MAJOR + 1)).0.0" ;; | |
| minor) NEW_VERSION="${MAJOR}.$((MINOR + 1)).0" ;; | |
| patch) NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))" ;; | |
| esac | |
| TAG_NAME="${PRODUCT}-${TEMPLATE}-v${NEW_VERSION}" | |
| if git tag -l "$TAG_NAME" | grep -q "$TAG_NAME"; then | |
| echo "Tag $TAG_NAME exists, skipping" | |
| continue | |
| fi | |
| echo "Releasing $PRODUCT/$TEMPLATE v$NEW_VERSION" | |
| # Upload to S3 - versioned | |
| aws s3 cp "$TEMPLATE_FILE" \ | |
| "s3://${{ env.S3_BUCKET }}/products/${PRODUCT}/${TEMPLATE}/v${NEW_VERSION}/${TEMPLATE}.yaml" \ | |
| --cache-control "max-age=86400" \ | |
| --content-type "application/x-yaml" | |
| # Upload to S3 - latest | |
| aws s3 cp "$TEMPLATE_FILE" \ | |
| "s3://${{ env.S3_BUCKET }}/products/${PRODUCT}/${TEMPLATE}/latest/${TEMPLATE}.yaml" \ | |
| --cache-control "max-age=300" \ | |
| --content-type "application/x-yaml" | |
| # Update versions.json in S3 | |
| aws s3 cp "s3://${{ env.S3_BUCKET }}/products/${PRODUCT}/${TEMPLATE}/versions.json" /tmp/tpl-versions.json 2>/dev/null || \ | |
| echo "{\"product\":\"$PRODUCT\",\"template\":\"$TEMPLATE\",\"versions\":[],\"latest\":\"\"}" > /tmp/tpl-versions.json | |
| python3 << PYEOF | |
| import json | |
| with open('/tmp/tpl-versions.json', 'r') as f: | |
| data = json.load(f) | |
| data.get('versions', []).insert(0, {'version': '$NEW_VERSION', 'released_at': '$TIMESTAMP'}) | |
| data['latest'] = '$NEW_VERSION' | |
| with open('/tmp/tpl-versions.json', 'w') as f: | |
| json.dump(data, f, indent=2) | |
| PYEOF | |
| aws s3 cp /tmp/tpl-versions.json "s3://${{ env.S3_BUCKET }}/products/${PRODUCT}/${TEMPLATE}/versions.json" | |
| # Update local versions file | |
| jq ".products[\"$PRODUCT\"][\"$TEMPLATE\"] = \"$NEW_VERSION\"" "$VERSIONS_FILE" > /tmp/updated.json | |
| mv /tmp/updated.json "$VERSIONS_FILE" | |
| RELEASED="$RELEASED ${PRODUCT}/${TEMPLATE}:v$NEW_VERSION" | |
| TAGS="$TAGS $TAG_NAME" | |
| done | |
| echo "released_products=$RELEASED" >> $GITHUB_OUTPUT | |
| echo "product_tags=$TAGS" >> $GITHUB_OUTPUT | |
| - name: Combine release outputs | |
| id: release | |
| run: | | |
| RELEASED="${{ steps.release-core.outputs.released_core }} ${{ steps.release-products.outputs.released_products }}" | |
| TAGS="${{ steps.release-core.outputs.core_tags }} ${{ steps.release-products.outputs.product_tags }}" | |
| echo "released_templates=$RELEASED" >> $GITHUB_OUTPUT | |
| echo "template_tags=$TAGS" >> $GITHUB_OUTPUT | |
| - name: Calculate bundle version | |
| id: bundle | |
| env: | |
| BUMP_TYPE: ${{ needs.detect-changes.outputs.bump_type }} | |
| run: | | |
| LATEST_TAG=$(git tag -l "release-v*" --sort=-v:refname | head -1) | |
| if [ -z "$LATEST_TAG" ]; then | |
| CURRENT="0.0.0" | |
| else | |
| CURRENT=$(echo "$LATEST_TAG" | sed 's/release-v//') | |
| fi | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT" | |
| case $BUMP_TYPE in | |
| major) NEW_VERSION="$((MAJOR + 1)).0.0" ;; | |
| minor) NEW_VERSION="${MAJOR}.$((MINOR + 1)).0" ;; | |
| patch) NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))" ;; | |
| esac | |
| echo "New bundle: v$NEW_VERSION" | |
| echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| echo "tag=release-v$NEW_VERSION" >> $GITHUB_OUTPUT | |
| - name: Release bundle | |
| env: | |
| BUNDLE_VERSION: ${{ steps.bundle.outputs.version }} | |
| run: | | |
| TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | |
| echo "" | |
| echo "========================================" | |
| echo "Releasing Bundle v$BUNDLE_VERSION" | |
| echo "========================================" | |
| # Upload core templates to bundle | |
| for TEMPLATE_FILE in templates/*.yaml; do | |
| TEMPLATE=$(basename "$TEMPLATE_FILE" .yaml) | |
| echo " -> core/$TEMPLATE" | |
| aws s3 cp "$TEMPLATE_FILE" \ | |
| "s3://${{ env.S3_BUCKET }}/releases/v${BUNDLE_VERSION}/${TEMPLATE}.yaml" \ | |
| --cache-control "max-age=86400" \ | |
| --content-type "application/x-yaml" | |
| done | |
| # Upload product templates to bundle | |
| for PRODUCT_DIR in products/*/; do | |
| PRODUCT=$(basename "$PRODUCT_DIR") | |
| for TEMPLATE_FILE in "$PRODUCT_DIR"*.yaml; do | |
| TEMPLATE=$(basename "$TEMPLATE_FILE" .yaml) | |
| echo " -> ${PRODUCT}/${TEMPLATE}" | |
| aws s3 cp "$TEMPLATE_FILE" \ | |
| "s3://${{ env.S3_BUCKET }}/releases/v${BUNDLE_VERSION}/products/${PRODUCT}/${TEMPLATE}.yaml" \ | |
| --cache-control "max-age=86400" \ | |
| --content-type "application/x-yaml" | |
| done | |
| done | |
| # Upload to latest | |
| aws s3 sync "templates/" "s3://${{ env.S3_BUCKET }}/releases/latest/" \ | |
| --exclude "*.md" --exclude ".*" \ | |
| --cache-control "max-age=300" \ | |
| --content-type "application/x-yaml" | |
| for PRODUCT_DIR in products/*/; do | |
| PRODUCT=$(basename "$PRODUCT_DIR") | |
| aws s3 sync "$PRODUCT_DIR" "s3://${{ env.S3_BUCKET }}/releases/latest/products/${PRODUCT}/" \ | |
| --exclude "*.md" --exclude ".*" \ | |
| --cache-control "max-age=300" \ | |
| --content-type "application/x-yaml" | |
| done | |
| # Create bundle manifest | |
| python3 << PYEOF | |
| import json | |
| with open('template-versions.json', 'r') as f: | |
| versions = json.load(f) | |
| manifest = { | |
| 'bundle_version': '$BUNDLE_VERSION', | |
| 'released_at': '$TIMESTAMP', | |
| 'commit': '${{ github.sha }}', | |
| 'templates': {}, | |
| 'products': {} | |
| } | |
| for tpl, ver in versions.get('templates', {}).items(): | |
| manifest['templates'][tpl] = { | |
| 'version': ver if ver != '0.0.0' else 'initial', | |
| 'url': f"https://${{ env.S3_BUCKET }}.s3.${{ env.AWS_REGION }}.amazonaws.com/releases/v$BUNDLE_VERSION/{tpl}.yaml" | |
| } | |
| for product, templates in versions.get('products', {}).items(): | |
| manifest['products'][product] = {} | |
| for tpl, ver in templates.items(): | |
| manifest['products'][product][tpl] = { | |
| 'version': ver if ver != '0.0.0' else 'initial', | |
| 'url': f"https://${{ env.S3_BUCKET }}.s3.${{ env.AWS_REGION }}.amazonaws.com/releases/v$BUNDLE_VERSION/products/{product}/{tpl}.yaml" | |
| } | |
| with open('/tmp/bundle-manifest.json', 'w') as f: | |
| json.dump(manifest, f, indent=2) | |
| print("\nBundle contents:") | |
| print(" Core templates:") | |
| for tpl, info in manifest['templates'].items(): | |
| print(f" {tpl}: {info['version']}") | |
| for product, templates in manifest['products'].items(): | |
| print(f" Product: {product}") | |
| for tpl, info in templates.items(): | |
| print(f" {tpl}: {info['version']}") | |
| PYEOF | |
| aws s3 cp /tmp/bundle-manifest.json "s3://${{ env.S3_BUCKET }}/releases/v${BUNDLE_VERSION}/manifest.json" | |
| aws s3 cp /tmp/bundle-manifest.json "s3://${{ env.S3_BUCKET }}/releases/latest/manifest.json" | |
| # Update releases index | |
| aws s3 cp "s3://${{ env.S3_BUCKET }}/releases/index.json" /tmp/releases-index.json 2>/dev/null || \ | |
| echo '{"releases":[],"latest":""}' > /tmp/releases-index.json | |
| python3 << PYEOF | |
| import json | |
| with open('/tmp/releases-index.json', 'r') as f: | |
| idx = json.load(f) | |
| idx.get('releases', []).insert(0, { | |
| 'version': '$BUNDLE_VERSION', | |
| 'released_at': '$TIMESTAMP', | |
| 'commit': '${{ github.sha }}' | |
| }) | |
| idx['latest'] = '$BUNDLE_VERSION' | |
| with open('/tmp/releases-index.json', 'w') as f: | |
| json.dump(idx, f, indent=2) | |
| PYEOF | |
| aws s3 cp /tmp/releases-index.json "s3://${{ env.S3_BUCKET }}/releases/index.json" | |
| echo "Bundle v$BUNDLE_VERSION released" | |
| - name: Commit version updates | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add template-versions.json | |
| if ! git diff --staged --quiet; then | |
| git commit -m "chore: update template versions [skip ci]" | |
| git push | |
| fi | |
| - name: Create tags and releases | |
| env: | |
| TEMPLATE_TAGS: ${{ steps.release.outputs.template_tags }} | |
| BUNDLE_TAG: ${{ steps.bundle.outputs.tag }} | |
| BUNDLE_VERSION: ${{ steps.bundle.outputs.version }} | |
| RELEASED_TEMPLATES: ${{ steps.release.outputs.released_templates }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Create template tags | |
| for TAG in $TEMPLATE_TAGS; do | |
| echo "Creating tag: $TAG" | |
| git tag -a "$TAG" -m "Release $TAG" | |
| git push origin "$TAG" | |
| gh release create "$TAG" \ | |
| --title "$TAG" \ | |
| --notes "## $TAG | |
| Released as part of bundle v$BUNDLE_VERSION." | |
| echo "Created $TAG" | |
| done | |
| # Create bundle tag and release | |
| git tag -a "$BUNDLE_TAG" -m "Release Bundle v$BUNDLE_VERSION" | |
| git push origin "$BUNDLE_TAG" | |
| # Generate template table for release notes | |
| TEMPLATE_TABLE=$(python3 << 'PYEOF' | |
| import json | |
| with open('/tmp/bundle-manifest.json', 'r') as f: | |
| m = json.load(f) | |
| for t, i in sorted(m.get('templates', {}).items()): | |
| print(f"| {t} | {i['version']} | core |") | |
| for product, templates in sorted(m.get('products', {}).items()): | |
| for t, i in sorted(templates.items()): | |
| print(f"| {t} | {i['version']} | {product} |") | |
| PYEOF | |
| ) | |
| gh release create "$BUNDLE_TAG" \ | |
| --title "Release v$BUNDLE_VERSION" \ | |
| --notes "## CloudFormation Foundation v$BUNDLE_VERSION | |
| ### What's Changed | |
| $RELEASED_TEMPLATES | |
| ### Template Versions | |
| | Template | Version | Product | | |
| |----------|---------|---------| | |
| $TEMPLATE_TABLE | |
| ### AWS Marketplace Parameters | |
| \`\`\`yaml | |
| MPS3BucketName: ${{ env.S3_BUCKET }} | |
| MPS3BucketRegion: ${{ env.AWS_REGION }} | |
| MPS3KeyPrefix: releases/v$BUNDLE_VERSION/products/midaz/ | |
| \`\`\` | |
| ### Quick Launch (Midaz) | |
| [](https://console.aws.amazon.com/cloudformation/home?region=${{ env.AWS_REGION }}#/stacks/quickcreate?stackName=midaz&templateURL=https://${{ env.S3_BUCKET }}.s3.${{ env.AWS_REGION }}.amazonaws.com/releases/v$BUNDLE_VERSION/products/midaz/full-stack.yaml) | |
| ### Documentation | |
| - [README](https://github.com/${{ github.repository }}/blob/main/README.md) | |
| - [Architecture](https://github.com/${{ github.repository }}/blob/main/docs/ARCHITECTURE.md) | |
| - [Troubleshooting](https://github.com/${{ github.repository }}/blob/main/docs/TROUBLESHOOTING.md) | |
| - [Cost Estimation](https://github.com/${{ github.repository }}/blob/main/docs/COST_ESTIMATION.md) | |
| " | |
| echo "Created $BUNDLE_TAG" | |
| # ============================================================================ | |
| # Release Summary | |
| # ============================================================================ | |
| release-summary: | |
| name: Release Summary | |
| needs: [detect-changes, release-templates] | |
| if: always() && needs.detect-changes.outputs.has_changes == 'true' | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| steps: | |
| - name: Summary | |
| env: | |
| RELEASED_TEMPLATES: ${{ needs.release-templates.outputs.released_templates }} | |
| BUNDLE_VERSION: ${{ needs.release-templates.outputs.bundle_version }} | |
| run: | | |
| echo "## Release Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Released Templates" >> $GITHUB_STEP_SUMMARY | |
| for item in $RELEASED_TEMPLATES; do | |
| echo "- $item" >> $GITHUB_STEP_SUMMARY | |
| done | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Bundle Version" >> $GITHUB_STEP_SUMMARY | |
| echo "**v$BUNDLE_VERSION**" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Marketplace Parameters" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| echo "MPS3KeyPrefix=releases/v$BUNDLE_VERSION/products/midaz/" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| # ============================================================================ | |
| # Shared Workflow: Slack Notification | |
| # ============================================================================ | |
| notify: | |
| name: Notify | |
| needs: [release-templates, release-summary] | |
| if: always() && needs.release-templates.result != 'skipped' | |
| uses: LerianStudio/github-actions-shared-workflows/.github/workflows/slack-notify.yml@v1.10.2 | |
| with: | |
| status: ${{ needs.release-templates.result }} | |
| workflow_name: "CloudFormation Release" | |
| custom_message: "Bundle v${{ needs.release-templates.outputs.bundle_version }} released" | |
| failed_jobs: ${{ needs.release-templates.result == 'failure' && 'Release Templates' || '' }} | |
| secrets: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |