mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 04:31:08 +00:00
Changelogs local generation (#1411)
This PR introduces a script and some templates to use the prdoc involved in a release and build: - the changelog - a simple draft of audience documentation Since the prdoc presence was enforced in the middle of the version 1.5.0, not all PRs did come with a `prdoc` file. This PR creates all the missing `prdoc` files with some minimum content allowing to properly generate the changelog. The generated content is **not** suitable for the audience documentation. The audience documentation will be possible with the next version, when all PR come with a proper `prdoc`. ## Assumptions - the prdoc files for release `vX.Y.Z` have been moved under `prdoc/X.Y.Z` - the changelog requires for now for the prdoc files to contain author + topic. Thos fields are optional. The build script can be called as: ``` VERSION=X.Y.Z ./scripts/release/build-changelogs.sh ``` Related: - #1408 --------- Co-authored-by: EgorPopelyaev <egor@parity.io>
This commit is contained in:
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export PRODUCT=polkadot
|
||||
export VERSION=${VERSION:-1.5.0}
|
||||
|
||||
PROJECT_ROOT=`git rev-parse --show-toplevel`
|
||||
echo $PROJECT_ROOT
|
||||
|
||||
TMP=$(mktemp -d)
|
||||
TEMPLATE_AUDIENCE="${PROJECT_ROOT}/scripts/release/templates/audience.md.tera"
|
||||
TEMPLATE_CHANGELOG="${PROJECT_ROOT}/scripts/release/templates/changelog.md.tera"
|
||||
|
||||
DATA_JSON="${TMP}/data.json"
|
||||
CONTEXT_JSON="${TMP}/context.json"
|
||||
echo -e "TEMPLATE_AUDIENCE: \t$TEMPLATE_AUDIENCE"
|
||||
echo -e "DATA_JSON: \t\t$DATA_JSON"
|
||||
echo -e "CONTEXT_JSON: \t\t$CONTEXT_JSON"
|
||||
|
||||
# Create output folder
|
||||
OUTPUT="${TMP}/changelogs/$PRODUCT/$VERSION"
|
||||
echo -e "OUTPUT: \t\t$OUTPUT"
|
||||
mkdir -p $OUTPUT
|
||||
|
||||
prdoc load -d "$PROJECT_ROOT/prdoc/$VERSION" --json > $DATA_JSON
|
||||
# ls -al $DATA_JSON
|
||||
|
||||
cat $DATA_JSON | jq ' { "prdoc" : .}' > $CONTEXT_JSON
|
||||
# ls -al $CONTEXT_JSON
|
||||
|
||||
# Fetch the list of valid audiences
|
||||
SCHEMA_URL=https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json
|
||||
SCHEMA=$(curl -s $SCHEMA_URL | sed 's|^//.*||')
|
||||
AUDIENCE_ARRAY=$(echo -E $SCHEMA | jq -r '."$defs".audience.oneOf[] | .const')
|
||||
|
||||
readarray -t audiences < <(echo "$AUDIENCE_ARRAY")
|
||||
declare -p audiences
|
||||
|
||||
|
||||
# Generate a changelog
|
||||
echo "Generating changelog..."
|
||||
tera -t "${TEMPLATE_CHANGELOG}" --env --env-key env "${CONTEXT_JSON}" > "$OUTPUT/changelog.md"
|
||||
echo "Changelog ready in $OUTPUT/changelog.md"
|
||||
|
||||
# Generate a release notes doc per audience
|
||||
for audience in "${audiences[@]}"; do
|
||||
audience_id="$(tr [A-Z] [a-z] <<< "$audience")"
|
||||
audience_id="$(tr ' ' '_' <<< "$audience_id")"
|
||||
echo "Processing audience: $audience ($audience_id)"
|
||||
export TARGET_AUDIENCE=$audience
|
||||
tera -t "${TEMPLATE_AUDIENCE}" --env --env-key env "${CONTEXT_JSON}" > "$OUTPUT/relnote_${audience_id}.md"
|
||||
done
|
||||
|
||||
# Show the files
|
||||
tree -s -h -c $OUTPUT/
|
||||
@@ -0,0 +1,13 @@
|
||||
## Release {{ env.PRODUCT }} {{ env.VERSION }}
|
||||
|
||||
Changelog for `{{ env.TARGET_AUDIENCE }}`.
|
||||
|
||||
{% for file in prdoc -%}
|
||||
#### PR #{{file.doc_filename.number}}: {{ file.content.title }}
|
||||
{% for doc_item in file.content.doc %}
|
||||
{%- if doc_item.audience == env.TARGET_AUDIENCE %}
|
||||
{{ doc_item.description }}
|
||||
{% endif -%}
|
||||
|
||||
{%- endfor %}
|
||||
{%- endfor %}
|
||||
@@ -0,0 +1,7 @@
|
||||
## Changelog for `{{ env.PRODUCT | capitalize }} v{{ env.VERSION }}`
|
||||
|
||||
{% for file in prdoc | sort(attribute="doc_filename.number") -%}
|
||||
{%- set author= file.content.author | default(value="n/a") -%}
|
||||
{%- set topic= file.content.topic | default(value="n/a") -%}
|
||||
- #{{file.doc_filename.number}}: {{ file.content.title }} (@{{ author }}) [{{ topic | capitalize }}]
|
||||
{% endfor -%}
|
||||
Reference in New Issue
Block a user