Skip to content
Merged
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
36 changes: 36 additions & 0 deletions .github/auto-publish-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
######################################################################
# This is the template used to generate auto-publication workflows for
# the different documents in the repository. Check generate script for
# details. Edit this file and run the script again to update the
# workflows.
######################################################################

name: Publish {{shortname}} on /TR

on:
pull_request:
paths:
- "{{shortname}}/**"
push:
branches: [main]
paths:
- "{{shortname}}/**"
workflow_dispatch:

jobs:
publish-TR-{{shortname}}:
name: Publish {{shortname}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: w3c/spec-prod@v2
with:
TOOLCHAIN: bikeshed
SOURCE: {{shortname}}/Overview.bs
DESTINATION: {{shortname}}/index.html
BUILD_FAIL_ON: warning
VALIDATE_MARKUP: false
W3C_ECHIDNA_TOKEN: ${{ secrets.{{tokenName}} }}
W3C_WG_DECISION_URL: https://www.w3.org/2025/08/21-css-minutes.html#fc30
W3C_BUILD_OVERRIDE: |
status: {{publicationStatus}}
94 changes: 94 additions & 0 deletions .github/generate-auto-publish-workflows.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/usr/bin/env python3
"""
Script to generate auto publication workflows for given specs
"""

import re
from pathlib import Path

# -----------------------------------------------------------------------------
# List of properties that can appear to describe a spec.
# -----------------------------------------------------------------------------

PROPERTIES = [
"shortname",
"publicationStatus",
"tokenName",
]

# -----------------------------------------------------------------------------
# List of specs for which an auto-publish script needs to be created.
# -----------------------------------------------------------------------------

SPECS = [
{
"shortname": "css-color-4",
"publicationStatus": "CRD",
},
{
"shortname": "css-color-5",
"publicationStatus": "WD",
},
{
"shortname": "css-fonts-5",
"publicationStatus": "WD",
},
]

# -----------------------------------------------------------------------------
# Main
# -----------------------------------------------------------------------------

def main():
script_path = Path(__file__).parent
template_path = script_path / "auto-publish-template.yml"
workflows_dir = script_path / "workflows"

workflows_dir.mkdir(parents=True, exist_ok=True)

template = template_path.read_text(encoding="utf-8")

# Replace the large comment header block (#####...#####)
template = re.sub(
r"#{5,}.*?#{5,}",
"""######################################################################
# IMPORTANT: Do not edit this file directly!
#
# This workflow was automatically generated through the
# generate-auto-publish-workflows.py script. To update the workflow,
# make changes to the template file and run the script again.
######################################################################""",
template,
flags=re.S,
)

for spec in SPECS:
spec = spec.copy()

# Derive shortname from source if not provided
if "shortname" not in spec or not spec["shortname"]:
spec["shortname"] = spec["source"].split(".")[0].replace("_", "-")

# Derive tokenName if not provided
if "tokenName" not in spec or not spec["tokenName"]:
token = (
spec["shortname"]
.upper()
.replace("-", "_")
)
spec["tokenName"] = f"TR_TOKEN_{token}"

# Apply template substitutions
content = template
for prop in PROPERTIES:
value = spec.get(prop, "")
content = content.replace(f"{{{{{prop}}}}}", value)

# Write workflow file
filename = workflows_dir / f"{spec['shortname']}.yml"
filename.write_text(content, encoding="utf-8")
print(f"Generated {filename}")


if __name__ == "__main__":
main()
Loading