Skip to content

Commit

Permalink
Build release artfiacts
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed Aug 21, 2024
1 parent 37ed272 commit d80b07c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .github/workflows/cd-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "[CD] Create release"
on:
push:
tags:
- "*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Build
run: scripts/release_schemas/create_cfn_schema_rule.py
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
build/schemas-cfnlint.zip
build/schemas-draft7.zip
27 changes: 26 additions & 1 deletion scripts/release_schemas/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
SPDX-License-Identifier: MIT-0
"""
import logging
import tarfile
from collections import deque
from pathlib import Path

Expand Down Expand Up @@ -136,16 +137,40 @@ def _build_patch(path, patch):
logger.info(f"Patch {rule.id} for {resource_type} in {schemas[resource_type]}")


build_dir = Path("build")
schemas_dir = build_dir / "schemas"
schemas_cfnlint_dir = schemas_dir / "cfnlint"
schemas_cfnlint_dir.mkdir(parents=True, exist_ok=True)

schemas_draft7_dir = schemas_dir / "draft7"
schemas_draft7_dir.mkdir(parents=True, exist_ok=True)

for resource_type, region in schemas.items():
rt_py = ToPy(resource_type)

with open(schemas_cfnlint_dir / f"{rt_py.py}.json", "w") as f:
f.write(
format_json_string(
PROVIDER_SCHEMA_MANAGER.get_resource_schema(
region, resource_type
).schema
)
)

_translator.translator(resource_type, region)

with open(f"local/release_schemas/{rt_py.py}.json", "w") as f:
with open(schemas_draft7_dir / f"{rt_py.py}.json", "w") as f:
f.write(
format_json_string(
PROVIDER_SCHEMA_MANAGER.get_resource_schema(
region, resource_type
).schema
)
)

logger.info("Create schema package")
with tarfile.open(build_dir / "schemas-cfnlint.zip", "w:gz") as tar:
tar.add(schemas_cfnlint_dir, arcname="schemas")

with tarfile.open(build_dir / "schemas-draft7.zip", "w:gz") as tar:
tar.add(schemas_draft7_dir, arcname="schemas")

0 comments on commit d80b07c

Please sign in to comment.