Skip to content

Commit de4cad4

Browse files
authored
Merge pull request #1146 from bact/update-ci-for-new-branch-names
Update publication CI for "develop" branch
2 parents 234629e + 186c104 commit de4cad4

File tree

2 files changed

+127
-32
lines changed

2 files changed

+127
-32
lines changed

.github/workflows/publish_v3.yml

+126-30
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,120 @@
1+
# Publish SPDX specification to https://spdx.github.io/spdx-spec/
2+
#
3+
# There will be this workflow in "main", "develop", and "support" branches.
4+
# Each of them publish to a different URL.
5+
#
6+
# For example,
7+
# the workflow in "main" may publish to https://spdx.github.io/spdx-spec/3.0.1/,
8+
# the workflow in "develop" may publish to https://spdx.github.io/spdx-spec/3.1-dev/,
9+
# the workflow in "support/3.0" may publish to https://spdx.github.io/spdx-spec/3.0.0/.
10+
#
11+
# The workflow should be configured to have an URL without a version number
12+
# specified be redirected to an URL published from "main" branch.
13+
#
14+
# ## Workflow overview
15+
#
16+
# 1) Generate model documents and RDFs from model files in spdx-3-model repo
17+
# 2) Combine the model documents from (1) with the chapters in spdx-spec repo
18+
# 3) Generate a website using files from (2)
19+
# 4) Upload RDFs from (1) and a website from (3) to GitHub Pages
20+
# 5) Make URL redirections as needed
21+
#
22+
# See notes at:
23+
# https://github.com/spdx/spdx-spec/issues/1155
24+
# https://github.com/spdx/spdx-spec/pull/1146
25+
# See branch structure at:
26+
# https://github.com/spdx/spdx-spec/blob/develop/README.md#branch-structure
27+
128
on:
2-
# push:
3-
# branches:
4-
# - development/v3.0.1
5-
# repository_dispatch:
6-
# types:
7-
# - publish_v3_spec
29+
push:
30+
branches:
31+
- develop # This should match with REF_SPEC,
32+
# to automatically publish from a correct branch
33+
repository_dispatch:
34+
types:
35+
- publish_v3_spec
836
workflow_dispatch: {} # Manually trigger from https://github.com/spdx/spdx-spec/actions
937
jobs:
1038
build:
1139
runs-on: ubuntu-latest
1240
env:
13-
REF_SPEC: "development/v3.0.1" # spec branch/tag release
14-
REF_MODEL: "main" # model branch/tag release
15-
REF_PARSER: "main" # parser branch/tag release
16-
GH_PAGES_BRANCH: "gh-pages" # branch name to publish HTML to
17-
VERSION: "v3.0.1" # publishing version
18-
VERSION_DEFAULT: "v3.0.1" # default version (be redirected from https://spdx.github.io/spdx-spec/)
19-
VERSION_ALIASES: "latest v3.0 v3.0.1-draft v3-draft v3.0-RC1 v3.0-RC2" # aliases for VERSION
20-
GIT_USER_NAME: "ci-bot" # for gh-pages commit
21-
GIT_USER_EMAIL: "[email protected]" # for gh-pages commit
22-
PARSER_OUT_BASE_DIR: "__parser_out" # temp dir for output from spec-parser
23-
PARSER_OUT_RDF_DIR: "rdf" # contains RDFs and schema; relative to PARSER_OUT_BASE_DIR
24-
PARSER_OUT_MKDOCS_DIR: "mkdocs" # contains model Markdown files; relative to PARSER_OUT_BASE_DIR
25-
MKDOCS_MODEL_YML: "model-files.yml" # contains list of model Markdown files
26-
MKDOCS_BASE_YML: "mkdocs.yml" # initial MkDocs configuration
27-
MKDOCS_FULL_YML: "__mkdocs-full.yml" # MkDocs configuration combined with model list
28-
REDIRECT_MAP_PATH: "etc/redirect-map.csv" # redirect map
29-
REDIRECT_TEMPLATE_PATH: "etc/redirect-template.html" # redirect HTML template
41+
REF_SPEC: "develop" # spdx-spec branch: "main" or "develop" or "support/x.y"
42+
REF_MODEL: "main" # spdx-3-model branch: "main" or "develop" or "support/x.y"
43+
REF_PARSER: "main" # spdx-3-model branch: "main" or "develop" or "support/x.y"
44+
# (now we have only "main" for spdx-3-model and spec-parser)
45+
GH_PAGES_BRANCH: "gh-pages" # spdx-spec branch to publish HTML to
46+
VERSION_DEFAULT: "v3.0.1" # Default version:
47+
# - A version to be redirected to from the URL without
48+
# a version number specified
49+
# - Should be a latest stable version from "main" branch
50+
# - VERSION_DEFAULT should be the same in this workflow
51+
# across all branches/tags
52+
# - VERSION_DEFAULT should also match with the
53+
# mike's canonical_version in mkdocs.yml
54+
VERSION: "v3.0.1" # Publishing version, to be publish by this workflow:
55+
# - VERSION can be different from VERSION_DEFAULT;
56+
# For example, if VERSION is a draft/release candidate,
57+
# or if VERSION is a stable version that is behind the
58+
# default version (e.g. v3.0.2 vs v3.1)
59+
# - VERSION from "develop" branch should be indicated with
60+
# a suffix ("-dev", "-draft", etc.).
61+
# The content of this version will constantly change.
62+
# - VERSION should match with the version in the copyright
63+
# text defined in mkdocs.yml
64+
# e.g. "SPDX v3.x.x Copyright (c) 2010-2024, ..."
65+
# - A release candidate (with suffix "-RC") may be published
66+
# from a very short-lived "support" branch.
67+
# The content of this version should be kept unchanged,
68+
# so it can be properly referenced during the review period,
69+
# but the URL of the RC version may subjected to be
70+
# redirected to the release version later.
71+
# For example, v3.0-RC1 was redirected to v3.0 and
72+
# will be redirected to v3.0.1 later.
73+
VERSION_ALIASES: "latest v3.0 v3.0.1-dev v3.0.1-draft v3-draft v3.0-RC1 v3.0-RC2"
74+
# VERSION_ALIASES are names that will be redirected to VERSION
75+
# - Can be empty, can be multiple; separated by space
76+
# - "latest" should be reserved for the latest version
77+
# - Versions like "v3.0" will be expanded to "v3.0 3.0"
78+
GIT_USER_NAME: "ci-bot" # Username for gh-pages commit
79+
GIT_USER_EMAIL: "[email protected]" # E-mail for gh-pages commit
80+
PARSER_OUT_BASE_DIR: "__parser_out" # Temporary dir for output from spec-parser
81+
PARSER_OUT_RDF_DIR: "rdf" # Contains RDFs and schema; relative to PARSER_OUT_BASE_DIR
82+
PARSER_OUT_MKDOCS_DIR: "mkdocs" # Contains model Markdown files:
83+
# - relative to PARSER_OUT_BASE_DIR
84+
MKDOCS_MODEL_YML: "model-files.yml" # Contains list of model Markdown files:
85+
# - relative to PARSER_OUT_BASE_DIR
86+
MKDOCS_BASE_YML: "mkdocs.yml" # Initial MkDocs configuration; from spdx-spec repo
87+
MKDOCS_FULL_YML: "__mkdocs-full.yml" # MkDocs configuration combined with model list:
88+
# - to be generated from MKDOCS_BASE_YML and MKDOCS_MODEL_YML
89+
REDIRECT_MAP_PATH: "etc/redirect-map.csv" # URL redirect map
90+
REDIRECT_TEMPLATE_PATH: "etc/redirect-template.html" # URL redirect HTML template
3091
steps:
92+
- name: Expand version aliases to include a version without 'v' prefix
93+
# VERSION: "v3.0.1"
94+
# Original VERSION_ALIASES: "latest v3.0"
95+
# Expanded VERSION_ALIASES: "3.0.1 latest v3.0 3.0"
96+
run: |
97+
echo VERSION: $VERSION
98+
echo Original VERSION_ALIASES: $VERSION_ALIASES
99+
original_aliases="$VERSION_ALIASES"
100+
expanded_aliases=""
101+
102+
if [[ $VERSION =~ ^v[0-9] ]]; then
103+
expanded_aliases="$expanded_aliases ${VERSION#v}"
104+
fi
105+
106+
for version in $original_aliases; do
107+
expanded_aliases="$expanded_aliases $version"
108+
if [[ $version =~ ^v[0-9] ]]; then
109+
expanded_aliases="$expanded_aliases ${version#v}"
110+
fi
111+
done
112+
113+
expanded_aliases=$(echo $expanded_aliases | sed 's/^ *//g')
114+
echo "VERSION_ALIASES=$expanded_aliases" >> $GITHUB_ENV
115+
- name: Check expanded version aliases
116+
run: |
117+
echo Expanded VERSION_ALIASES: $VERSION_ALIASES
31118
- name: Checkout spdx-spec
32119
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
33120
with:
@@ -147,24 +234,32 @@ jobs:
147234
echo "===================="
148235
- name: Deploy and set aliases
149236
# mike is used here to manage multiple versions of MkDocs-powered documentation
150-
# This step does 3 things:
237+
# This step does 2 things:
151238
# 1) delete existing aliases (in VERSION_ALIASES), if exists
152239
# 2) deploy as VERSION, with aliases
153-
# 3) set default version to VERSION_DEFAULT
240+
# If the existing aliases were redirected to other versions,
241+
# it means this VERSION will "steal" the aliases from those versions.
154242
working-directory: spdx-spec
155243
run: |
156244
for alias in $VERSION_ALIASES; do
157245
mike delete --config-file "$MKDOCS_FULL_YML" --branch $GH_PAGES_BRANCH --push --allow-empty "$alias" || true
158246
done
159247
mike deploy --update-aliase --config-file "$MKDOCS_FULL_YML" --branch $GH_PAGES_BRANCH --push $VERSION $VERSION_ALIASES
248+
- name: Set default version
249+
# Set default version to VERSION_DEFAULT;
250+
# if not set, the default version will remain the same.
251+
# Should only be done from the "main" branch.
252+
if: github.ref == 'refs/heads/main'
253+
working-directory: spdx-spec
254+
run: |
160255
mike set-default --config-file "$MKDOCS_FULL_YML" --branch $GH_PAGES_BRANCH --push $VERSION_DEFAULT
161256
- name: Copy JSON annotations, JSON schema, JSON-LD context, and RDFs to alias directories
162257
# Fallback for backward compatibility with old URLs before v3.0.1
163258
# This step creates copies of annotations/schema/RDFs to all alias
164259
# directories, so they can be accessible from all old URLs.
165260
# For example,
166-
# - https://spdx.github.io/spdx-spec/v3.0/model/schema.json
167-
# - https://spdx.github.io/spdx-spec/v3.0.1/rdf/schema.json
261+
# - https://spdx.github.io/spdx-spec/v3.0/model/schema.json (old directory structure)
262+
# - https://spdx.github.io/spdx-spec/v3.0.1/rdf/schema.json (new directory structure)
168263
# will all accessible and have the same content.
169264
# Unlike HTML files, these files have to be a copy,
170265
# since it cannot use the HTML refresh mechanism.
@@ -187,15 +282,16 @@ jobs:
187282
# https://github.com/spdx/spdx-3-model/blob/main/CHANGELOG.md
188283
#
189284
# This step creates a HTML files to facilitate additional directions.
190-
# It reads a redirect map from etc/redirect-map.csv; in the CSV,
285+
# It reads a redirect map from /etc/redirect-map.csv; in the CSV,
191286
# first value is 'from' (source) and second value is 'to' (target).
192287
#
193288
# The 'from' and 'to' values will be inserted into a HTML template at
194-
# from etc/redirect-template.html, to create a redirect HTML
289+
# from /etc/redirect-template.html, to create a redirect HTML
195290
# page (index.html) under a subdirectory with the name of 'from'
196291
# that will refresh the browser to a URL of 'to'.
197292
#
198-
# For example, given
293+
# For example, given:
294+
#
199295
# VERSION = "v3.0.1"
200296
# VERSION_ALIASES = "latest v3.0"
201297
# from = "model/Core/Properties/imports"

requirements.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
json-schema-for-humans==1.0.2
21
mike==2.1.3
32
mkdocs==1.6.1
4-
mkdocs-pdf-export-plugin==0.5.10
3+
# mkdocs-pdf-export-plugin==0.5.10
54
PyYAML==6.0.2
65
shacl2code==0.0.15

0 commit comments

Comments
 (0)