Skip to content

Commit cefbd73

Browse files
authored
Enable auto-publication (#553)
This automates the publication of all 9 EME documents to the `gh-pages` branch and to /TR, using the w3c/spec-prod action. In particular, this adds an auto-publish workflow template and a companion script to generate auto-publish workflows for each and every spec in the repository that only run when needed, meaning only when the spec source did change. The script only needs to run once in a while when new specs get added or when the workflows need to change. Script and template are in the `.github` folder to avoid polluting the repo with build tools. The `W3CTRMANIFEST` files are no longer needed as a result and nothing needs to be Git-ignored anymore either. Also note the change of shortname for Encrypted Media Extensions to `encrypted-media-2`.
1 parent 576c0e1 commit cefbd73

23 files changed

+621
-74
lines changed

.github/auto-publish-template.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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: Auto publish {{shortname}}
9+
10+
on:
11+
# Worflow runs on pull requests where it makes sure that the spec can still be
12+
# generated, that markup is valid and that there are no broken links, as
13+
# well as on pushes to the default branch where it also deploys the generated
14+
# spec to the gh-pages branch and publishes the result to /TR.
15+
# The "workflow_dispatch" hook allows admins to also trigger the workflow
16+
# manually from GitHub's UI.
17+
pull_request:
18+
paths:
19+
- '{{source}}'{{additionalPaths}}
20+
push:
21+
branches: [main]
22+
paths:
23+
- '{{source}}'{{additionalPaths}}
24+
workflow_dispatch:
25+
26+
jobs:
27+
main:
28+
runs-on: ubuntu-latest
29+
steps:
30+
# See doc at https://github.com/actions/checkout#checkout-v2
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
34+
# See doc at https://w3c.github.io/spec-prod/
35+
# The action only deploys the generated spec to the gh-pages branch when
36+
# the workflow was triggered by a push to the default branch.
37+
- name: Build and validate spec, push to gh-pages branch and deploy to /TR if needed
38+
uses: w3c/spec-prod@v2
39+
with:
40+
TOOLCHAIN: respec
41+
SOURCE: {{source}}
42+
DESTINATION: {{destination}}
43+
GH_PAGES_BRANCH: gh-pages
44+
W3C_ECHIDNA_TOKEN: ${{ secrets.{{tokenName}} }}
45+
W3C_WG_DECISION_URL: https://github.com/w3c/media-wg/issues/27
46+
W3C_BUILD_OVERRIDE: |
47+
specStatus: {{publicationStatus}}
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/**********************************************************************
2+
* Companion script to create individual auto publication workflows for
3+
* specifications contained in the repository. Run the script any time
4+
* the auto-publish-template.yml is updated or when the list of specs
5+
* changes below.
6+
**********************************************************************/
7+
8+
/**
9+
* List of properties that can appear to describe a spec.
10+
*/
11+
const properties = [
12+
// Spec shortname (without level), e.g., 'encrypted-media'
13+
'shortname',
14+
15+
// Spec status on /TR, e.g., 'WD'
16+
'publicationStatus',
17+
18+
// Relative path to source file
19+
'source',
20+
21+
// Relative path to destination file in gh-pages branch (Optional)
22+
// If not provided, the destination file is computed from the source by
23+
// removing `-respec`.
24+
'destination',
25+
26+
// Name of the repository secret that contains the publication token for
27+
// Echidna (Optional).
28+
// If not provided, the name is computed from the shortname, e.g.,
29+
// `ECHIDNA_TOKEN_ENCRYPTED_MEDIA` for `encrypted-media-2` (note the level
30+
// is stripped)
31+
'tokenName',
32+
33+
// Additional paths that should trigger the auto-publish script if changed
34+
// on top of the actual source. Glob patterns may be used.
35+
'additionalPaths'
36+
];
37+
38+
39+
/**
40+
* List of specs for which an auto-publish script needs to be created.
41+
*/
42+
const specs = [
43+
{
44+
shortname: 'encrypted-media',
45+
source: 'encrypted-media-respec.html',
46+
destination: 'index.html',
47+
publicationStatus: 'WD',
48+
additionalPaths: [
49+
'*.css',
50+
'*.svg'
51+
]
52+
},
53+
{
54+
shortname: 'eme-hdcp-version-registry',
55+
source: 'hdcp-version-registry-respec.html',
56+
publicationStatus: 'DRY'
57+
},
58+
{
59+
shortname: 'eme-initdata-registry',
60+
source: 'format-registry/initdata/index-respec.html',
61+
publicationStatus: 'DRY'
62+
},
63+
{
64+
shortname: 'eme-initdata-cenc',
65+
source: 'format-registry/initdata/cenc-respec.html',
66+
publicationStatus: 'NOTE'
67+
},
68+
{
69+
shortname: 'eme-initdata-keyids',
70+
source: 'format-registry/initdata/keyids-respec.html',
71+
publicationStatus: 'NOTE'
72+
},
73+
{
74+
shortname: 'eme-initdata-webm',
75+
source: 'format-registry/initdata/webm-respec.html',
76+
publicationStatus: 'NOTE'
77+
},
78+
79+
{
80+
shortname: 'eme-stream-registry',
81+
source: 'format-registry/stream/index-respec.html',
82+
publicationStatus: 'DRY'
83+
},
84+
{
85+
shortname: 'eme-stream-mp4',
86+
source: 'format-registry/stream/mp4-respec.html',
87+
publicationStatus: 'NOTE'
88+
},
89+
{
90+
shortname: 'eme-stream-webm',
91+
source: 'format-registry/stream/webm-respec.html',
92+
publicationStatus: 'NOTE'
93+
}
94+
];
95+
96+
97+
/**
98+
* Main loop, create a workflow per spec
99+
*/
100+
import assert from 'node:assert';
101+
import { readFile, writeFile } from 'node:fs/promises';
102+
import { dirname, join } from 'node:path';
103+
import { fileURLToPath } from 'node:url';
104+
105+
const scriptPath = dirname(fileURLToPath(import.meta.url));
106+
let template = await readFile(join(scriptPath, 'auto-publish-template.yml'), 'utf8');
107+
template = template.replace(/#{5,}.*#{5,}/s,
108+
`######################################################################
109+
# IMPORTANT: Do not edit this file directly!
110+
#
111+
# This workflow was automatically generated through the
112+
# generate-auto-publish-workflows.mjs script. To update the workflow,
113+
# make changes to the template file and run the script again.
114+
######################################################################`);
115+
116+
for (const spec of specs) {
117+
if (!spec.destination) {
118+
spec.destination = spec.source.replace(/-respec/, '');
119+
}
120+
if (!spec.tokenName) {
121+
spec.tokenName = 'ECHIDNA_TOKEN_' +
122+
spec.shortname.toUpperCase().replace(/-/g, '_');
123+
}
124+
if (spec.additionalPaths) {
125+
spec.additionalPaths = spec.additionalPaths.map(path => `\n - '${path}'`).join('');
126+
}
127+
128+
let content = template;
129+
for (const prop of properties) {
130+
content = content.replace(new RegExp('{{' + prop + '}}', 'g'), spec[prop] ?? '');
131+
}
132+
133+
const filename = join(scriptPath, 'workflows', `auto-publish-${spec.shortname}.yml`);
134+
await writeFile(filename, content, 'utf8');
135+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
######################################################################
2+
# IMPORTANT: Do not edit this file directly!
3+
#
4+
# This workflow was automatically generated through the
5+
# generate-auto-publish-workflows.mjs script. To update the workflow,
6+
# make changes to the template file and run the script again.
7+
######################################################################
8+
9+
name: Auto publish eme-hdcp-version-registry
10+
11+
on:
12+
# Worflow runs on pull requests where it makes sure that the spec can still be
13+
# generated, that markup is valid and that there are no broken links, as
14+
# well as on pushes to the default branch where it also deploys the generated
15+
# spec to the gh-pages branch and publishes the result to /TR.
16+
# The "workflow_dispatch" hook allows admins to also trigger the workflow
17+
# manually from GitHub's UI.
18+
pull_request:
19+
paths:
20+
- 'hdcp-version-registry-respec.html'
21+
push:
22+
branches: [main]
23+
paths:
24+
- 'hdcp-version-registry-respec.html'
25+
workflow_dispatch:
26+
27+
jobs:
28+
main:
29+
runs-on: ubuntu-latest
30+
steps:
31+
# See doc at https://github.com/actions/checkout#checkout-v2
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
35+
# See doc at https://w3c.github.io/spec-prod/
36+
# The action only deploys the generated spec to the gh-pages branch when
37+
# the workflow was triggered by a push to the default branch.
38+
- name: Build and validate spec, push to gh-pages branch and deploy to /TR if needed
39+
uses: w3c/spec-prod@v2
40+
with:
41+
TOOLCHAIN: respec
42+
SOURCE: hdcp-version-registry-respec.html
43+
DESTINATION: hdcp-version-registry.html
44+
GH_PAGES_BRANCH: gh-pages
45+
W3C_ECHIDNA_TOKEN: ${{ secrets.ECHIDNA_TOKEN_EME_HDCP_VERSION_REGISTRY }}
46+
W3C_WG_DECISION_URL: https://github.com/w3c/media-wg/issues/27
47+
W3C_BUILD_OVERRIDE: |
48+
specStatus: DRY
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
######################################################################
2+
# IMPORTANT: Do not edit this file directly!
3+
#
4+
# This workflow was automatically generated through the
5+
# generate-auto-publish-workflows.mjs script. To update the workflow,
6+
# make changes to the template file and run the script again.
7+
######################################################################
8+
9+
name: Auto publish eme-initdata-cenc
10+
11+
on:
12+
# Worflow runs on pull requests where it makes sure that the spec can still be
13+
# generated, that markup is valid and that there are no broken links, as
14+
# well as on pushes to the default branch where it also deploys the generated
15+
# spec to the gh-pages branch and publishes the result to /TR.
16+
# The "workflow_dispatch" hook allows admins to also trigger the workflow
17+
# manually from GitHub's UI.
18+
pull_request:
19+
paths:
20+
- 'format-registry/initdata/cenc-respec.html'
21+
push:
22+
branches: [main]
23+
paths:
24+
- 'format-registry/initdata/cenc-respec.html'
25+
workflow_dispatch:
26+
27+
jobs:
28+
main:
29+
runs-on: ubuntu-latest
30+
steps:
31+
# See doc at https://github.com/actions/checkout#checkout-v2
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
35+
# See doc at https://w3c.github.io/spec-prod/
36+
# The action only deploys the generated spec to the gh-pages branch when
37+
# the workflow was triggered by a push to the default branch.
38+
- name: Build and validate spec, push to gh-pages branch and deploy to /TR if needed
39+
uses: w3c/spec-prod@v2
40+
with:
41+
TOOLCHAIN: respec
42+
SOURCE: format-registry/initdata/cenc-respec.html
43+
DESTINATION: format-registry/initdata/cenc.html
44+
GH_PAGES_BRANCH: gh-pages
45+
W3C_ECHIDNA_TOKEN: ${{ secrets.ECHIDNA_TOKEN_EME_INITDATA_CENC }}
46+
W3C_WG_DECISION_URL: https://github.com/w3c/media-wg/issues/27
47+
W3C_BUILD_OVERRIDE: |
48+
specStatus: NOTE
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
######################################################################
2+
# IMPORTANT: Do not edit this file directly!
3+
#
4+
# This workflow was automatically generated through the
5+
# generate-auto-publish-workflows.mjs script. To update the workflow,
6+
# make changes to the template file and run the script again.
7+
######################################################################
8+
9+
name: Auto publish eme-initdata-keyids
10+
11+
on:
12+
# Worflow runs on pull requests where it makes sure that the spec can still be
13+
# generated, that markup is valid and that there are no broken links, as
14+
# well as on pushes to the default branch where it also deploys the generated
15+
# spec to the gh-pages branch and publishes the result to /TR.
16+
# The "workflow_dispatch" hook allows admins to also trigger the workflow
17+
# manually from GitHub's UI.
18+
pull_request:
19+
paths:
20+
- 'format-registry/initdata/keyids-respec.html'
21+
push:
22+
branches: [main]
23+
paths:
24+
- 'format-registry/initdata/keyids-respec.html'
25+
workflow_dispatch:
26+
27+
jobs:
28+
main:
29+
runs-on: ubuntu-latest
30+
steps:
31+
# See doc at https://github.com/actions/checkout#checkout-v2
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
35+
# See doc at https://w3c.github.io/spec-prod/
36+
# The action only deploys the generated spec to the gh-pages branch when
37+
# the workflow was triggered by a push to the default branch.
38+
- name: Build and validate spec, push to gh-pages branch and deploy to /TR if needed
39+
uses: w3c/spec-prod@v2
40+
with:
41+
TOOLCHAIN: respec
42+
SOURCE: format-registry/initdata/keyids-respec.html
43+
DESTINATION: format-registry/initdata/keyids.html
44+
GH_PAGES_BRANCH: gh-pages
45+
W3C_ECHIDNA_TOKEN: ${{ secrets.ECHIDNA_TOKEN_EME_INITDATA_KEYIDS }}
46+
W3C_WG_DECISION_URL: https://github.com/w3c/media-wg/issues/27
47+
W3C_BUILD_OVERRIDE: |
48+
specStatus: NOTE
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
######################################################################
2+
# IMPORTANT: Do not edit this file directly!
3+
#
4+
# This workflow was automatically generated through the
5+
# generate-auto-publish-workflows.mjs script. To update the workflow,
6+
# make changes to the template file and run the script again.
7+
######################################################################
8+
9+
name: Auto publish eme-initdata-registry
10+
11+
on:
12+
# Worflow runs on pull requests where it makes sure that the spec can still be
13+
# generated, that markup is valid and that there are no broken links, as
14+
# well as on pushes to the default branch where it also deploys the generated
15+
# spec to the gh-pages branch and publishes the result to /TR.
16+
# The "workflow_dispatch" hook allows admins to also trigger the workflow
17+
# manually from GitHub's UI.
18+
pull_request:
19+
paths:
20+
- 'format-registry/initdata/index-respec.html'
21+
push:
22+
branches: [main]
23+
paths:
24+
- 'format-registry/initdata/index-respec.html'
25+
workflow_dispatch:
26+
27+
jobs:
28+
main:
29+
runs-on: ubuntu-latest
30+
steps:
31+
# See doc at https://github.com/actions/checkout#checkout-v2
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
35+
# See doc at https://w3c.github.io/spec-prod/
36+
# The action only deploys the generated spec to the gh-pages branch when
37+
# the workflow was triggered by a push to the default branch.
38+
- name: Build and validate spec, push to gh-pages branch and deploy to /TR if needed
39+
uses: w3c/spec-prod@v2
40+
with:
41+
TOOLCHAIN: respec
42+
SOURCE: format-registry/initdata/index-respec.html
43+
DESTINATION: format-registry/initdata/index.html
44+
GH_PAGES_BRANCH: gh-pages
45+
W3C_ECHIDNA_TOKEN: ${{ secrets.ECHIDNA_TOKEN_EME_INITDATA_REGISTRY }}
46+
W3C_WG_DECISION_URL: https://github.com/w3c/media-wg/issues/27
47+
W3C_BUILD_OVERRIDE: |
48+
specStatus: DRY

0 commit comments

Comments
 (0)