-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automate all the things! 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.
- Loading branch information
Showing
12 changed files
with
605 additions
and
89 deletions.
There are no files selected for viewing
This file contains 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,46 @@ | ||
###################################################################### | ||
# 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: Auto publish {{shortname}} | ||
|
||
on: | ||
# Worflow runs on pull requests where it makes sure that the spec can still be | ||
# generated, that markup is valid and that there are no broken links, as | ||
# well as on pushes to the default branch where it also deploys the generated | ||
# spec to the gh-pages branch and publishes the result to /TR. | ||
# The "workflow_dispatch" hook allows admins to also trigger the workflow | ||
# manually from GitHub's UI. | ||
pull_request: {} | ||
push: | ||
branches: [main] | ||
workflow_dispatch: | ||
paths: | ||
- '{{source}}' | ||
{{additionalPaths}} | ||
|
||
jobs: | ||
main: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# See doc at https://github.com/actions/checkout#checkout-v2 | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
# See doc at https://w3c.github.io/spec-prod/ | ||
# The action only deploys the generated spec to the gh-pages branch when | ||
# the workflow was triggered by a push to the default branch. | ||
- name: Build and validate spec, push to gh-pages branch and deploy to /TR if needed | ||
uses: w3c/spec-prod@v2 | ||
with: | ||
TOOLCHAIN: respec | ||
SOURCE: {{source}} | ||
DESTINATION: {{destination}} | ||
GH_PAGES_BRANCH: gh-pages | ||
W3C_ECHIDNA_TOKEN: ${{ secrets.{{tokenName}} }} | ||
W3C_WG_DECISION_URL: https://github.com/w3c/media-wg/issues/27 | ||
W3C_BUILD_OVERRIDE: | | ||
specStatus: {{publicationStatus}} |
This file contains 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,135 @@ | ||
/********************************************************************** | ||
* Companion script to create individual auto publication workflows for | ||
* specifications contained in the repository. Run the script any time | ||
* the auto-publish-template.yml is updated or when the list of specs | ||
* changes below. | ||
**********************************************************************/ | ||
|
||
/** | ||
* List of properties that can appear to describe a spec. | ||
*/ | ||
const properties = [ | ||
// Spec shortname (without level), e.g., 'encrypted-media' | ||
'shortname', | ||
|
||
// Spec status on /TR, e.g., 'WD' | ||
'publicationStatus', | ||
|
||
// Relative path to source file | ||
'source', | ||
|
||
// Relative path to destination file in gh-pages branch (Optional) | ||
// If not provided, the destination file is computed from the source by | ||
// removing `-respec`. | ||
'destination', | ||
|
||
// Name of the repository secret that contains the publication token for | ||
// Echidna (Optional). | ||
// If not provided, the name is computed from the shortname, e.g., | ||
// `ECHIDNA_TOKEN_ENCRYPTED_MEDIA` for `encrypted-media-2` (note the level | ||
// is stripped) | ||
'tokenName', | ||
|
||
// Additional paths that should trigger the auto-publish script if changed | ||
// on top of the actual source. Glob patterns may be used. | ||
'additionalPaths' | ||
]; | ||
|
||
|
||
/** | ||
* List of specs for which an auto-publish script needs to be created. | ||
*/ | ||
const specs = [ | ||
{ | ||
shortname: 'encrypted-media', | ||
source: 'encrypted-media-respec.html', | ||
destination: 'index.html', | ||
publicationStatus: 'WD', | ||
additionalPaths: [ | ||
'*.css', | ||
'*.svg' | ||
] | ||
}, | ||
{ | ||
shortname: 'eme-hdcp-version-registry', | ||
source: 'hdcp-version-registry-respec.html', | ||
publicationStatus: 'DRY' | ||
}, | ||
{ | ||
shortname: 'eme-initdata-registry', | ||
source: 'format-registry/initdata/index-respec.html', | ||
publicationStatus: 'DRY' | ||
}, | ||
{ | ||
shortname: 'eme-initdata-cenc', | ||
source: 'format-registry/initdata/cenc-respec.html', | ||
publicationStatus: 'NOTE' | ||
}, | ||
{ | ||
shortname: 'eme-initdata-keyids', | ||
source: 'format-registry/initdata/keyids-respec.html', | ||
publicationStatus: 'NOTE' | ||
}, | ||
{ | ||
shortname: 'eme-initdata-webm', | ||
source: 'format-registry/initdata/webm-respec.html', | ||
publicationStatus: 'NOTE' | ||
}, | ||
|
||
{ | ||
shortname: 'eme-stream-registry', | ||
source: 'format-registry/stream/index-respec.html', | ||
publicationStatus: 'DRY' | ||
}, | ||
{ | ||
shortname: 'eme-stream-mp4', | ||
source: 'format-registry/stream/mp4-respec.html', | ||
publicationStatus: 'NOTE' | ||
}, | ||
{ | ||
shortname: 'eme-stream-webm', | ||
source: 'format-registry/stream/webm-respec.html', | ||
publicationStatus: 'NOTE' | ||
} | ||
]; | ||
|
||
|
||
/** | ||
* Main loop, create a workflow per spec | ||
*/ | ||
import assert from 'node:assert'; | ||
import { readFile, writeFile } from 'node:fs/promises'; | ||
import { dirname, join } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
|
||
const scriptPath = dirname(fileURLToPath(import.meta.url)); | ||
let template = await readFile(join(scriptPath, 'auto-publish-template.yml'), 'utf8'); | ||
template = template.replace(/#{5,}.*#{5,}/s, | ||
`###################################################################### | ||
# IMPORTANT: Do not edit this file directly! | ||
# | ||
# This workflow was automatically generated through the | ||
# generate-auto-publish-workflows.mjs script. To update the workflow, | ||
# make changes to the template file and run the script again. | ||
######################################################################`); | ||
|
||
for (const spec of specs) { | ||
if (!spec.destination) { | ||
spec.destination = spec.source.replace(/-respec/, ''); | ||
} | ||
if (!spec.tokenName) { | ||
spec.tokenName = 'ECHIDNA_TOKEN_' + | ||
spec.shortname.toUpperCase().replace(/-/g, '_'); | ||
} | ||
if (spec.additionalPaths) { | ||
spec.additionalPaths = spec.additionalPaths.map(path => `- '${path}'`).join('\n '); | ||
} | ||
|
||
let content = template; | ||
for (const prop of properties) { | ||
content = content.replace(new RegExp('{{' + prop + '}}', 'g'), spec[prop] ?? ''); | ||
} | ||
|
||
const filename = join(scriptPath, 'workflows', `auto-publish-${spec.shortname}.yml`); | ||
await writeFile(filename, content, 'utf8'); | ||
} |
47 changes: 47 additions & 0 deletions
47
.github/workflows/auto-publish-eme-hdcp-version-registry.yml
This file contains 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,47 @@ | ||
###################################################################### | ||
# IMPORTANT: Do not edit this file directly! | ||
# | ||
# This workflow was automatically generated through the | ||
# generate-auto-publish-workflows.mjs script. To update the workflow, | ||
# make changes to the template file and run the script again. | ||
###################################################################### | ||
|
||
name: Auto publish eme-hdcp-version-registry | ||
|
||
on: | ||
# Worflow runs on pull requests where it makes sure that the spec can still be | ||
# generated, that markup is valid and that there are no broken links, as | ||
# well as on pushes to the default branch where it also deploys the generated | ||
# spec to the gh-pages branch and publishes the result to /TR. | ||
# The "workflow_dispatch" hook allows admins to also trigger the workflow | ||
# manually from GitHub's UI. | ||
pull_request: {} | ||
push: | ||
branches: [main] | ||
workflow_dispatch: | ||
paths: | ||
- 'hdcp-version-registry-respec.html' | ||
|
||
|
||
jobs: | ||
main: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# See doc at https://github.com/actions/checkout#checkout-v2 | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
# See doc at https://w3c.github.io/spec-prod/ | ||
# The action only deploys the generated spec to the gh-pages branch when | ||
# the workflow was triggered by a push to the default branch. | ||
- name: Build and validate spec, push to gh-pages branch and deploy to /TR if needed | ||
uses: w3c/spec-prod@v2 | ||
with: | ||
TOOLCHAIN: respec | ||
SOURCE: hdcp-version-registry-respec.html | ||
DESTINATION: hdcp-version-registry.html | ||
GH_PAGES_BRANCH: gh-pages | ||
W3C_ECHIDNA_TOKEN: ${{ secrets.ECHIDNA_TOKEN_EME_HDCP_VERSION_REGISTRY }} | ||
W3C_WG_DECISION_URL: https://github.com/w3c/media-wg/issues/27 | ||
W3C_BUILD_OVERRIDE: | | ||
specStatus: DRY |
This file contains 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,47 @@ | ||
###################################################################### | ||
# IMPORTANT: Do not edit this file directly! | ||
# | ||
# This workflow was automatically generated through the | ||
# generate-auto-publish-workflows.mjs script. To update the workflow, | ||
# make changes to the template file and run the script again. | ||
###################################################################### | ||
|
||
name: Auto publish eme-initdata-cenc | ||
|
||
on: | ||
# Worflow runs on pull requests where it makes sure that the spec can still be | ||
# generated, that markup is valid and that there are no broken links, as | ||
# well as on pushes to the default branch where it also deploys the generated | ||
# spec to the gh-pages branch and publishes the result to /TR. | ||
# The "workflow_dispatch" hook allows admins to also trigger the workflow | ||
# manually from GitHub's UI. | ||
pull_request: {} | ||
push: | ||
branches: [main] | ||
workflow_dispatch: | ||
paths: | ||
- 'format-registry/initdata/cenc-respec.html' | ||
|
||
|
||
jobs: | ||
main: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# See doc at https://github.com/actions/checkout#checkout-v2 | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
# See doc at https://w3c.github.io/spec-prod/ | ||
# The action only deploys the generated spec to the gh-pages branch when | ||
# the workflow was triggered by a push to the default branch. | ||
- name: Build and validate spec, push to gh-pages branch and deploy to /TR if needed | ||
uses: w3c/spec-prod@v2 | ||
with: | ||
TOOLCHAIN: respec | ||
SOURCE: format-registry/initdata/cenc-respec.html | ||
DESTINATION: format-registry/initdata/cenc.html | ||
GH_PAGES_BRANCH: gh-pages | ||
W3C_ECHIDNA_TOKEN: ${{ secrets.ECHIDNA_TOKEN_EME_INITDATA_CENC }} | ||
W3C_WG_DECISION_URL: https://github.com/w3c/media-wg/issues/27 | ||
W3C_BUILD_OVERRIDE: | | ||
specStatus: NOTE |
This file contains 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,47 @@ | ||
###################################################################### | ||
# IMPORTANT: Do not edit this file directly! | ||
# | ||
# This workflow was automatically generated through the | ||
# generate-auto-publish-workflows.mjs script. To update the workflow, | ||
# make changes to the template file and run the script again. | ||
###################################################################### | ||
|
||
name: Auto publish eme-initdata-keyids | ||
|
||
on: | ||
# Worflow runs on pull requests where it makes sure that the spec can still be | ||
# generated, that markup is valid and that there are no broken links, as | ||
# well as on pushes to the default branch where it also deploys the generated | ||
# spec to the gh-pages branch and publishes the result to /TR. | ||
# The "workflow_dispatch" hook allows admins to also trigger the workflow | ||
# manually from GitHub's UI. | ||
pull_request: {} | ||
push: | ||
branches: [main] | ||
workflow_dispatch: | ||
paths: | ||
- 'format-registry/initdata/keyids-respec.html' | ||
|
||
|
||
jobs: | ||
main: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# See doc at https://github.com/actions/checkout#checkout-v2 | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
# See doc at https://w3c.github.io/spec-prod/ | ||
# The action only deploys the generated spec to the gh-pages branch when | ||
# the workflow was triggered by a push to the default branch. | ||
- name: Build and validate spec, push to gh-pages branch and deploy to /TR if needed | ||
uses: w3c/spec-prod@v2 | ||
with: | ||
TOOLCHAIN: respec | ||
SOURCE: format-registry/initdata/keyids-respec.html | ||
DESTINATION: format-registry/initdata/keyids.html | ||
GH_PAGES_BRANCH: gh-pages | ||
W3C_ECHIDNA_TOKEN: ${{ secrets.ECHIDNA_TOKEN_EME_INITDATA_KEYIDS }} | ||
W3C_WG_DECISION_URL: https://github.com/w3c/media-wg/issues/27 | ||
W3C_BUILD_OVERRIDE: | | ||
specStatus: NOTE |
This file contains 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,47 @@ | ||
###################################################################### | ||
# IMPORTANT: Do not edit this file directly! | ||
# | ||
# This workflow was automatically generated through the | ||
# generate-auto-publish-workflows.mjs script. To update the workflow, | ||
# make changes to the template file and run the script again. | ||
###################################################################### | ||
|
||
name: Auto publish eme-initdata-registry | ||
|
||
on: | ||
# Worflow runs on pull requests where it makes sure that the spec can still be | ||
# generated, that markup is valid and that there are no broken links, as | ||
# well as on pushes to the default branch where it also deploys the generated | ||
# spec to the gh-pages branch and publishes the result to /TR. | ||
# The "workflow_dispatch" hook allows admins to also trigger the workflow | ||
# manually from GitHub's UI. | ||
pull_request: {} | ||
push: | ||
branches: [main] | ||
workflow_dispatch: | ||
paths: | ||
- 'format-registry/initdata/index-respec.html' | ||
|
||
|
||
jobs: | ||
main: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# See doc at https://github.com/actions/checkout#checkout-v2 | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
# See doc at https://w3c.github.io/spec-prod/ | ||
# The action only deploys the generated spec to the gh-pages branch when | ||
# the workflow was triggered by a push to the default branch. | ||
- name: Build and validate spec, push to gh-pages branch and deploy to /TR if needed | ||
uses: w3c/spec-prod@v2 | ||
with: | ||
TOOLCHAIN: respec | ||
SOURCE: format-registry/initdata/index-respec.html | ||
DESTINATION: format-registry/initdata/index.html | ||
GH_PAGES_BRANCH: gh-pages | ||
W3C_ECHIDNA_TOKEN: ${{ secrets.ECHIDNA_TOKEN_EME_INITDATA_REGISTRY }} | ||
W3C_WG_DECISION_URL: https://github.com/w3c/media-wg/issues/27 | ||
W3C_BUILD_OVERRIDE: | | ||
specStatus: DRY |
Oops, something went wrong.