Skip to content
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

Enable auto-publication #553

Merged
merged 3 commits into from
Aug 1, 2024
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
47 changes: 47 additions & 0 deletions .github/auto-publish-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
######################################################################
# 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:
paths:
- '{{source}}'{{additionalPaths}}
push:
branches: [main]
paths:
- '{{source}}'{{additionalPaths}}
workflow_dispatch:

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}}
135 changes: 135 additions & 0 deletions .github/generate-auto-publish-workflows.mjs
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 => `\n - '${path}'`).join('');
}

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');
}
48 changes: 48 additions & 0 deletions .github/workflows/auto-publish-eme-hdcp-version-registry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
######################################################################
# 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:
paths:
- 'hdcp-version-registry-respec.html'
push:
branches: [main]
paths:
- 'hdcp-version-registry-respec.html'
workflow_dispatch:

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
48 changes: 48 additions & 0 deletions .github/workflows/auto-publish-eme-initdata-cenc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
######################################################################
# 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:
paths:
- 'format-registry/initdata/cenc-respec.html'
push:
branches: [main]
paths:
- 'format-registry/initdata/cenc-respec.html'
workflow_dispatch:

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
48 changes: 48 additions & 0 deletions .github/workflows/auto-publish-eme-initdata-keyids.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
######################################################################
# 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:
paths:
- 'format-registry/initdata/keyids-respec.html'
push:
branches: [main]
paths:
- 'format-registry/initdata/keyids-respec.html'
workflow_dispatch:

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
48 changes: 48 additions & 0 deletions .github/workflows/auto-publish-eme-initdata-registry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
######################################################################
# 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:
paths:
- 'format-registry/initdata/index-respec.html'
push:
branches: [main]
paths:
- 'format-registry/initdata/index-respec.html'
workflow_dispatch:

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
Loading