From 2b2ec21c24ce9313ea9b5190c7a6d6b2e3f61502 Mon Sep 17 00:00:00 2001 From: "Dr. B. M. Riazul Islam" Date: Sat, 7 Mar 2026 00:17:09 +0600 Subject: [PATCH] Add debugging to workflow and bump to 0.2.4 --- .gitea/workflows/ci-cd.yaml | 185 +++++++++++++++--------------------- input/bd.fhir.core.xml | 2 +- input/package-list.json | 8 ++ package-list.json | 8 ++ sushi-config.yaml | 2 +- 5 files changed, 92 insertions(+), 113 deletions(-) diff --git a/.gitea/workflows/ci-cd.yaml b/.gitea/workflows/ci-cd.yaml index 6c1cea0..52be05c 100644 --- a/.gitea/workflows/ci-cd.yaml +++ b/.gitea/workflows/ci-cd.yaml @@ -53,81 +53,6 @@ jobs: echo "build_type=$BUILD_TYPE" >> $GITHUB_OUTPUT echo "Build type: $BUILD_TYPE" - # NEW STEP: Update package-list.json BEFORE build so IG Publisher can use it - - name: Pre-build package-list.json update - run: | - VERSION="${{ steps.version.outputs.version }}" - BUILD_TYPE="${{ steps.version.outputs.build_type }}" - DATE=$(date +%Y-%m-%d) - - # Only update for release builds - if [ "$BUILD_TYPE" != "release" ]; then - echo "â„šī¸ Dev build - skipping package-list.json pre-build update" - exit 0 - fi - - echo "📋 Updating package-list.json before build..." - - # Check if package-list.json exists - if [ ! -f "package-list.json" ]; then - echo "âš ī¸ package-list.json not found in repo - history.html won't be generated" - echo "Creating minimal package-list.json for this build..." - cat > package-list.json << EOF - { - "package-id": "bd.fhir.core", - "title": "Bangladesh Core FHIR Implementation Guide", - "canonical": "https://fhir.dghs.gov.bd/core", - "introduction": "Core FHIR profiles and extensions for Bangladesh healthcare", - "list": [ - { - "version": "current", - "desc": "Continuous Integration Build (latest in version control)", - "path": "https://fhir.dghs.gov.bd/core/", - "status": "ci-build", - "current": true - } - ] - } - EOF - fi - - # Update package-list.json with new version - python3 << 'PYEOF' - import json - import sys - - version = "$VERSION" - date = "$DATE" - - with open('package-list.json', 'r') as f: - pkg_list = json.load(f) - - # Check if this version already exists - version_exists = any(e['version'] == version for e in pkg_list['list']) - - if not version_exists: - new_entry = { - "version": version, - "date": date, - "desc": f"Release {version}", - "path": f"https://fhir.dghs.gov.bd/core/{version}/", - "status": "trial-use", - "sequence": "STU 1" - } - # Insert after 'current' entry - pkg_list['list'].insert(1, new_entry) - - with open('package-list.json', 'w') as f: - json.dump(pkg_list, f, indent=2) - - print(f"✅ Added version {version} to package-list.json") - else: - print(f"â„šī¸ Version {version} already exists in package-list.json") - PYEOF - - echo "📋 package-list.json is ready for IG Publisher" - cat package-list.json - - name: Install Docker CLI run: | apt-get update @@ -169,49 +94,91 @@ jobs: exit 1 fi - # Check if history.html was generated - if [ -f "output/history.html" ]; then - echo "✅ history.html generated successfully" - else - echo "âš ī¸ WARNING: history.html was not generated" - echo "This usually means package-list.json was missing or invalid" - fi - echo "✅ Build successful!" - - name: Update package-feed.xml for releases + - name: Update package-list.json and package-feed.xml for releases if: steps.version.outputs.build_type == 'release' run: | VERSION="${{ steps.version.outputs.version }}" + DATE=$(date +%Y-%m-%d) DATETIME=$(date -u +%Y-%m-%dT%H:%M:%SZ) - cat > update-feed.py << 'EOF' + # Update package-list.json and package-feed.xml + cat > update-registry-files.py << 'EOF' + import json import sys import xml.etree.ElementTree as ET + from datetime import datetime version = sys.argv[1] - datetime_iso = sys.argv[2] + date = sys.argv[2] + datetime_iso = sys.argv[3] + # ========== Update package-list.json ========== + with open('package-list.json', 'r') as f: + pkg_list = json.load(f) + + # Update current build path + for entry in pkg_list['list']: + if entry['version'] == 'current': + entry['path'] = 'https://fhir.dghs.gov.bd/core/' + break + + # Check if this version already exists + version_exists = any(e['version'] == version for e in pkg_list['list']) + + if not version_exists: + # Add new version entry + new_entry = { + "version": version, + "date": date, + "desc": f"Release {version}", + "path": f"https://fhir.dghs.gov.bd/core/{version}/", + "status": "trial-use", + "sequence": "STU 1" + } + # Insert after 'current' entry + pkg_list['list'].insert(1, new_entry) + else: + # Update existing entry + for entry in pkg_list['list']: + if entry['version'] == version: + entry['date'] = date + entry['path'] = f"https://fhir.dghs.gov.bd/core/{version}/" + break + + with open('output/package-list.json', 'w') as f: + json.dump(pkg_list, f, indent=2) + + print(f"✅ Updated package-list.json with version {version}") + + # ========== Update package-feed.xml ========== + # Register namespaces ET.register_namespace('', 'http://www.w3.org/2005/Atom') + # Parse existing feed tree = ET.parse('package-feed.xml') root = tree.getroot() ns = {'atom': 'http://www.w3.org/2005/Atom'} + # Update feed updated timestamp updated_elem = root.find('atom:updated', ns) if updated_elem is not None: updated_elem.text = datetime_iso + # Check if entry for this version already exists entry_exists = False for entry in root.findall('atom:entry', ns): title = entry.find('atom:title', ns) if title is not None and version in title.text: entry_exists = True + # Update existing entry timestamp entry_updated = entry.find('atom:updated', ns) if entry_updated is not None: entry_updated.text = datetime_iso break + # If entry doesn't exist, create new one if not entry_exists: new_entry = ET.Element('{http://www.w3.org/2005/Atom}entry') @@ -231,6 +198,8 @@ jobs: summary = ET.SubElement(new_entry, '{http://www.w3.org/2005/Atom}summary') summary.text = f"Release {version} of Bangladesh Core FHIR Implementation Guide" + # Insert new entry at the beginning (after feed metadata) + # Find the position after the last feed-level element insert_pos = 0 for i, child in enumerate(root): if child.tag.endswith('entry'): @@ -240,32 +209,36 @@ jobs: root.insert(insert_pos, new_entry) + # Write updated feed tree.write('output/package-feed.xml', encoding='utf-8', xml_declaration=True) - print(f"✅ Updated package-feed.xml") + print(f"✅ Updated package-feed.xml with version {version}") + EOF - python3 update-feed.py "$VERSION" "$DATETIME" + python3 update-registry-files.py "$VERSION" "$DATE" "$DATETIME" - # Also copy the updated package-list.json to output - cp package-list.json output/package-list.json + # Copy updated files + cp output/package-list.json package-list.json + cp output/package-feed.xml package-feed.xml - echo "📋 Updated registry files" + echo "📋 Updated registry files (package-list.json and package-feed.xml)" - name: Prepare deployment artifact run: | VERSION="${{ steps.version.outputs.version }}" BUILD_TYPE="${{ steps.version.outputs.build_type }}" - tar -czf ig-output.tar.gz -C output . + # Create a tarball of the output + if [ "$BUILD_TYPE" == "release" ]; then + tar -czf ig-output.tar.gz -C output . + else + tar -czf ig-output.tar.gz -C output . + fi echo "version=$VERSION" > deployment.env echo "build_type=$BUILD_TYPE" >> deployment.env echo "build_date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> deployment.env - # List what's in the output - echo "đŸ“Ļ Output contents:" - ls -lh output/ | grep -E "(history\.html|package-list\.json|package-feed\.xml|index\.html)" - ls -lh ig-output.tar.gz - name: Upload artifact @@ -342,9 +315,6 @@ jobs: else TARGET_DIR="$VERSIONS_DIR/dev" echo "🔧 Deploying dev build to: $TARGET_DIR" - - echo "Cleaning old dev files..." - rm -rf "$TARGET_DIR"/* fi # Create target directory @@ -354,13 +324,7 @@ jobs: echo "Extracting IG output..." tar -xzf /tmp/fhir-ig-deploy/ig-output.tar.gz -C "$TARGET_DIR" - # Verify history.html was deployed - if [ -f "$TARGET_DIR/history.html" ]; then - echo "✅ history.html deployed successfully" - else - echo "âš ī¸ WARNING: history.html not found in deployment" - fi - + # Copy package-list.json to root cp /tmp/fhir-ig-deploy/package-list.json "$VERSIONS_DIR/package-list.json" # Copy package-feed.xml to root @@ -383,9 +347,9 @@ jobs: exit 1 fi - # Force recreate container to ensure new config/mounts are applied - # This handles "stuck" states better than a simple restart - docker compose -f docker-compose.prod.yml up -d --force-recreate fhir-ig + # Restart nginx to pick up new content + docker compose -f docker-compose.prod.yml restart fhir-ig || \ + docker compose -f docker-compose.prod.yml up -d # Cleanup rm -rf /tmp/fhir-ig-deploy @@ -395,7 +359,6 @@ jobs: echo "Version $version is now available at:" if [ "$build_type" == "release" ]; then echo " - https://fhir.dghs.gov.bd/core/$version/" - echo " - https://fhir.dghs.gov.bd/core/$version/history.html" echo " - https://fhir.dghs.gov.bd/core/ (current)" else echo " - https://fhir.dghs.gov.bd/core/dev/" @@ -404,4 +367,4 @@ jobs: # List all versions echo "Available versions:" - ls -lh "$VERSIONS_DIR" | grep -v total + ls -lh "$VERSIONS_DIR" | grep -v total \ No newline at end of file diff --git a/input/bd.fhir.core.xml b/input/bd.fhir.core.xml index 6735707..2d979b4 100644 --- a/input/bd.fhir.core.xml +++ b/input/bd.fhir.core.xml @@ -13,7 +13,7 @@ --> - + <status value="active"/> diff --git a/input/package-list.json b/input/package-list.json index a4bc587..6eec752 100644 --- a/input/package-list.json +++ b/input/package-list.json @@ -11,6 +11,14 @@ "status": "ci-build", "current": true }, + { + "version": "0.2.3", + "date": "2025-10-06", + "desc": "Second draft release of the Bangladesh Core FHIR IG", + "path": "https://fhir.dghs.gov.bd/core/0.2.3/", + "status": "trial-use", + "sequence": "STU 1" + }, { "version": "0.2.2", "date": "2025-10-06", diff --git a/package-list.json b/package-list.json index a4bc587..6eec752 100644 --- a/package-list.json +++ b/package-list.json @@ -11,6 +11,14 @@ "status": "ci-build", "current": true }, + { + "version": "0.2.3", + "date": "2025-10-06", + "desc": "Second draft release of the Bangladesh Core FHIR IG", + "path": "https://fhir.dghs.gov.bd/core/0.2.3/", + "status": "trial-use", + "sequence": "STU 1" + }, { "version": "0.2.2", "date": "2025-10-06", diff --git a/sushi-config.yaml b/sushi-config.yaml index 1c470c1..965cd05 100644 --- a/sushi-config.yaml +++ b/sushi-config.yaml @@ -6,7 +6,7 @@ description: > This Implementation Guide defines the Bangladesh Core FHIR profiles, value sets, code systems, and implementation rules for national digital health systems. status: draft -version: 0.2.3 +version: 0.2.4 fhirVersion: 4.0.1 copyrightYear: 2025+ releaseLabel: CI Build