-
Notifications
You must be signed in to change notification settings - Fork 779
helper to generate auto publication workflows #13581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| 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}} | ||
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
| 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() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.