Skip to content

Commit 9fe2f44

Browse files
authored
Merge pull request #741 from cambridge-cares/dev-dtvf-patch-notes
dev-dtvf-patch-notes
2 parents 80bca4a + 25f959e commit 9fe2f44

File tree

13 files changed

+564
-0
lines changed

13 files changed

+564
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
3+
# This script checks that the version of the Digital Twin Visualisation Framework
4+
# (DTVF) is as expected, the example visualisations have been updated to use that
5+
# version, and that the CHANGELOG has been updated acorrdingly.
6+
#
7+
# Author: Michael Hillman (mdhillman<@>cmclinnovations.com)
8+
9+
10+
# Read (what should be) the correct version
11+
VERSION=`cat -s "./web/digital-twin-vis-framework/VERSION" 2>/dev/null`
12+
if [ "$VERSION" == "" ]; then
13+
echo "The VERSION file of the DTVF has no content!"
14+
exit -1
15+
fi
16+
echo "DTVF defined in file as: $VERSION"
17+
18+
# Get the VERSION file from the main branch of the repo, check that this new version does not match
19+
MAIN_VERSION=$(curl -s "https://raw.githubusercontent.com/cambridge-cares/TheWorldAvatar/main/web/digital-twin-vis-framework/VERSION")
20+
if [ "$VERSION" == "$MAIN_VERSION" ]; then
21+
echo "Contents of VERSION file on this branch match that on the main branch!"
22+
exit -1
23+
fi
24+
25+
# Check that there's no -SNAPSHOT in the version
26+
TOKEN="-SNAPSHOT"
27+
if grep -q "$TOKEN" <<< "$VERSION"; then
28+
echo "Version still contains the -SNAPSHOT qualifier!"
29+
exit -1
30+
fi
31+
echo "Version does not contain -SNAPSHOT qualifier."
32+
33+
# Check that the README has been updated
34+
README="./web/digital-twin-vis-framework/README.md"
35+
TOKEN="$VERSION"
36+
37+
echo "Looking in README for '$VERSION'"
38+
if ! grep -q "$TOKEN" "$README"; then
39+
echo "Main README does not list the correct version of DTVF!"
40+
exit -1
41+
fi
42+
echo "Main README has been updated."
43+
44+
45+
# Check that the change log contains an entry for that version
46+
CHANGELOG="./web/digital-twin-vis-framework/CHANGELOG.md"
47+
TOKEN="# $VERSION"
48+
if ! grep -q "$TOKEN" "$CHANGELOG"; then
49+
echo "Could not find corresponding node in CHANGELOG.md file!"
50+
exit -1
51+
fi
52+
echo "CHANGELOG has node for the current version."
53+
54+
55+
# Check that the example visualisations have been updated
56+
TOKEN="dtvf/$VERSION/dtvf.min.js"
57+
58+
MAPBOX_VIS="./web/digital-twin-vis-framework/example-mapbox-vis/webspace/index.html"
59+
if ! grep -q "$TOKEN" "$MAPBOX_VIS"; then
60+
echo "Example Mapbox visualisation does not use new version of DTVF!"
61+
exit -1
62+
fi
63+
echo "Example Mapbox visualisation has been updated."
64+
65+
CESIUM_VIS="./web/digital-twin-vis-framework/example-cesium-vis/webspace/index.html"
66+
if ! grep -q "$TOKEN" "$CESIUM_VIS"; then
67+
echo "Example Cesium visualisation does not use new version of DTVF!"
68+
exit -1
69+
fi
70+
echo "Example Cesium visualisation has been updated."
71+
72+
73+
exit 0
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
# This script generates the body text for releases of the
4+
# Digital Twin Visualisation Framework (DTVF).
5+
#
6+
# Author: Michael Hillman (mdhillman<@>cmclinnovations.com)
7+
8+
CHANGELOG="./web/digital-twin-vis-framework/CHANGELOG.md"
9+
regexp="^#\s.*"
10+
SECTION=0
11+
12+
BODY="This release package marks a release of the Digital Twin Visualisation Framework (DTVF), a framework for customisable visualisations using The World Avatar project. Release notes for this version of the DTVF can be found below, for more details, see the \`CHANGELOG.md\` and \`README.md\` files within the \`/web/digital-twin-vis-framework/\` directory.\n\n"
13+
14+
# Read changelog line by line
15+
# Only store notes within the first header
16+
while IFS= read -r line
17+
do
18+
if [[ $line =~ $regexp ]]; then
19+
SECTION=$((SECTION + 1))
20+
fi
21+
22+
if [[ $SECTION == 1 ]]; then
23+
BODY="$BODY\n$line"
24+
fi
25+
26+
done < "$CHANGELOG"
27+
28+
# Output final notes
29+
echo -e "$BODY"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
# This script generates the HTML text for the email notification
4+
# generated with a new version of the Digital Twin Visualisation Framework
5+
# (DTVF) is released.
6+
#
7+
# Author: Michael Hillman (mdhillman<@>cmclinnovations.com)
8+
9+
# Read version from file
10+
VERSION="$(cat ./web/digital-twin-vis-framework/VERSION)"
11+
12+
# Read changelog from file
13+
CHANGELOG="./web/digital-twin-vis-framework/CHANGELOG.md"
14+
regexp="^#\s.*"
15+
SECTION=0
16+
17+
# Read changelog line by line
18+
# Only store notes within the first header
19+
NOTES = ""
20+
while IFS= read -r line
21+
do
22+
if [[ $line =~ $regexp ]]; then
23+
SECTION=$((SECTION + 1))
24+
fi
25+
26+
if [[ $SECTION == 1 ]]; then
27+
NOTES="$NOTES<br/>$line"
28+
fi
29+
30+
done < "$CHANGELOG"
31+
32+
# Replace [VERSION] with version
33+
TOKEN="\[VERSION\]"
34+
sed -i "s/$TOKEN/$VERSION/g" "$HOME/email.html"
35+
36+
# Replace [NOTES] with notes
37+
TOKEN="\[NOTES\]"
38+
sed -i "s|$TOKEN|$NOTES|g" "$HOME/email.html"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#
2+
# Checks that the version of the DTVF has been updated.
3+
#
4+
# Author: Michael Hillman (mdhillman<@>cmclinnovations.com)
5+
#
6+
name: Check DTVF Version
7+
8+
9+
# Trigger this workflow during pull requests to the 'main' branch,
10+
# but ONLY when files within the DTVF source code are changed.
11+
on:
12+
pull_request:
13+
branches:
14+
- main
15+
paths:
16+
- web/digital-twin-vis-framework/library/**
17+
18+
19+
# Job definitions
20+
jobs:
21+
22+
# Single job to run script
23+
check-version:
24+
25+
# Run on latest version of Ubuntu
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
# Checkout the repository
30+
- name: Checkout repository
31+
uses: actions/checkout@v2
32+
33+
# Run bash script that checks the version
34+
- name: Run version check script
35+
working-directory: ./
36+
run: |
37+
chmod +x ./.github/scripts/dtvf/check-version.sh
38+
./.github/scripts/dtvf/check-version.sh
39+

.github/workflows/dtvf_release.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#
2+
# Runs actions related to a new release (i.e. merged PR to main) of the
3+
# Digital Twin Visualisation Framework (DTVF).
4+
#
5+
# Author: Michael Hillman (mdhillman<@>cmclinnovations.com)
6+
#
7+
name: Release the DTVF
8+
9+
10+
# Trigger this workflow during pushes to the 'main' branch, and
11+
# ONLY when files within the DTVF source code are changed.
12+
on:
13+
push:
14+
branches:
15+
- main
16+
paths:
17+
- web/digital-twin-vis-framework/library/**
18+
19+
20+
# Job definitions
21+
jobs:
22+
23+
# Make a release on the repo
24+
make-release:
25+
26+
# Run on latest version of Ubuntu
27+
runs-on: ubuntu-latest
28+
29+
# Action steps
30+
steps:
31+
32+
# Checkout the repository
33+
- name: Checkout repository
34+
uses: actions/checkout@v3
35+
36+
# Compile the DTVF and ZIP results
37+
- name: Compile the DTVF
38+
id: compiler
39+
working-directory: ./web/digital-twin-vis-framework/library
40+
run: |
41+
docker-compose -f docker/docker-compose.yml up compile
42+
zip -r $HOME/dtvf.zip output/
43+
echo zip=$HOME/dtvf.zip >> $GITHUB_ENV
44+
45+
# Get the version of the DTVF
46+
- name: Get DTVF version
47+
id: versioner
48+
run: |
49+
echo version=$(cat web/digital-twin-vis-framework/VERSION) >> $GITHUB_ENV
50+
51+
# Generate the release body text
52+
- name: Generate release text
53+
id: generate-text
54+
working-directory: ./
55+
run: |
56+
chmod +x ./.github/scripts/dtvf/make-release-body.sh
57+
./.github/scripts/dtvf/make-release-body.sh > $HOME/body.md
58+
echo body=$HOME/body.md >> $GITHUB_ENV
59+
60+
# Make a release on the main branch
61+
- name: Make release
62+
uses: ncipollo/release-action@v1
63+
with:
64+
name: "dtvf-${{ env.version }}"
65+
tag: "dtvf-${{ env.version }}"
66+
commit: "main"
67+
bodyFile: "${{ env.body }}"
68+
artifacts: "${{ env.zip }}"
69+
70+
# Generate the release email content
71+
- name: Generate release email
72+
id: generate-email
73+
working-directory: ./
74+
run: |
75+
chmod +x ./.github/scripts/dtvf/make-release-email.sh
76+
cp ./web/digital-twin-vis-framework/library/release.html $HOME/email.html
77+
./.github/scripts/dtvf/make-release-email.sh
78+
echo email=$HOME/email.html >> $GITHUB_ENV
79+
80+
# Send a notification email
81+
- name: Send email
82+
uses: dawidd6/action-send-mail@v3
83+
with:
84+
server_address: mail.cmclinnovations.com
85+
server_port: 465
86+
secure: true
87+
username: ${{secrets.CMCL_MAIL_USERNAME}}
88+
password: ${{secrets.CMCL_MAIL_PASSWORD}}
89+
subject: "New TWA release: DTVF ${{ env.version }}"
90+
to: cares-twa@lists.cam.ac.uk,all@cmclinnovations.com
91+
from: Automated TWA action
92+
html_body: "file://${{ env.email }}"
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)