Skip to content

Commit fe20dc5

Browse files
deniaksvgeesus
authored andcommitted
helper to generate auto publication workflows
1 parent ced9212 commit fe20dc5

File tree

2 files changed

+128
-0
lines changed

2 files changed

+128
-0
lines changed

.github/auto-publish-template.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
######################################################################
2+
# This is the template used to generate auto-publication workflows for
3+
# the different documents in the repository. Check generate script for
4+
# details. Edit this file and run the script again to update the
5+
# workflows.
6+
######################################################################
7+
8+
name: Publish {{shortname}} on /TR
9+
10+
on:
11+
pull_request:
12+
push:
13+
branches: [main]
14+
paths:
15+
- "{{shortname}}/**"
16+
workflow_dispatch:
17+
18+
jobs:
19+
publish-TR-{{shortname}}:
20+
name: Publish {{shortname}}
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v6
24+
- uses: w3c/spec-prod@v2
25+
with:
26+
TOOLCHAIN: bikeshed
27+
SOURCE: {{shortname}}/Overview.bs
28+
DESTINATION: {{shortname}}/index.html
29+
BUILD_FAIL_ON: warning
30+
VALIDATE_MARKUP: false
31+
W3C_ECHIDNA_TOKEN: ${{ secrets.{{tokenName}} }}
32+
W3C_WG_DECISION_URL: https://www.w3.org/2025/08/21-css-minutes.html#fc30
33+
W3C_BUILD_OVERRIDE: |
34+
status: {{publicationStatus}}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Script to generate auto publication workflows for given specs
4+
"""
5+
6+
import re
7+
from pathlib import Path
8+
9+
# -----------------------------------------------------------------------------
10+
# List of properties that can appear to describe a spec.
11+
# -----------------------------------------------------------------------------
12+
13+
PROPERTIES = [
14+
"shortname",
15+
"publicationStatus",
16+
"tokenName",
17+
]
18+
19+
# -----------------------------------------------------------------------------
20+
# List of specs for which an auto-publish script needs to be created.
21+
# -----------------------------------------------------------------------------
22+
23+
SPECS = [
24+
{
25+
"shortname": "css-color-4",
26+
"publicationStatus": "CRD",
27+
},
28+
{
29+
"shortname": "css-color-5",
30+
"publicationStatus": "WD",
31+
},
32+
{
33+
"shortname": "css-fonts-4",
34+
"publicationStatus": "WD",
35+
},
36+
]
37+
38+
# -----------------------------------------------------------------------------
39+
# Main
40+
# -----------------------------------------------------------------------------
41+
42+
def main():
43+
script_path = Path(__file__).parent
44+
template_path = script_path / "auto-publish-template.yml"
45+
workflows_dir = script_path / "workflows"
46+
47+
workflows_dir.mkdir(parents=True, exist_ok=True)
48+
49+
template = template_path.read_text(encoding="utf-8")
50+
51+
# Replace the large comment header block (#####...#####)
52+
template = re.sub(
53+
r"#{5,}.*?#{5,}",
54+
"""######################################################################
55+
# IMPORTANT: Do not edit this file directly!
56+
#
57+
# This workflow was automatically generated through the
58+
# generate-auto-publish-workflows.py script. To update the workflow,
59+
# make changes to the template file and run the script again.
60+
######################################################################""",
61+
template,
62+
flags=re.S,
63+
)
64+
65+
for spec in SPECS:
66+
spec = spec.copy()
67+
68+
# Derive shortname from source if not provided
69+
if "shortname" not in spec or not spec["shortname"]:
70+
spec["shortname"] = spec["source"].split(".")[0].replace("_", "-")
71+
72+
# Derive tokenName if not provided
73+
if "tokenName" not in spec or not spec["tokenName"]:
74+
token = (
75+
spec["shortname"]
76+
.upper()
77+
.replace("-", "_")
78+
)
79+
spec["tokenName"] = f"TR_TOKEN_{token}"
80+
81+
# Apply template substitutions
82+
content = template
83+
for prop in PROPERTIES:
84+
value = spec.get(prop, "")
85+
content = content.replace(f"{{{{{prop}}}}}", value)
86+
87+
# Write workflow file
88+
filename = workflows_dir / f"{spec['shortname']}.yml"
89+
filename.write_text(content, encoding="utf-8")
90+
print(f"Generated {filename}")
91+
92+
93+
if __name__ == "__main__":
94+
main()

0 commit comments

Comments
 (0)