Skip to content

Commit

Permalink
Update deploy and build scripts
Browse files Browse the repository at this point in the history
Matches ttml1 build scripts as closely as possible. Doesn't include the deploy key so won't actually work yet.
  • Loading branch information
nigelmegitt committed Dec 15, 2017
1 parent 94ecc51 commit f537742
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 81 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
ttml2.xml filter=rcs-keywords
8 changes: 0 additions & 8 deletions .gitfilters/rcs-keywords.clean

This file was deleted.

30 changes: 0 additions & 30 deletions .gitfilters/rcs-keywords.smudge

This file was deleted.

9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: java

script:
- bash ./deploy.sh

env:
global:
- ENCRYPTION_LABEL: "72662b420eda"
- COMMIT_AUTHOR_EMAIL: "[email protected]"
112 changes: 112 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/bin/bash
set -e # Exit with nonzero exit code if anything fails

# From https://gist.github.com/domenic/ec8b0fc8ab45f39403dd

echo "[TRACE] TRAVIS_BRANCH: $TRAVIS_BRANCH"
echo "[TRACE] TRAVIS_PULL_REQUEST_BRANCH: $TRAVIS_PULL_REQUEST_BRANCH"
echo "[TRACE] TRAVIS_PULL_REQUEST: $TRAVIS_PULL_REQUEST"

SOURCE_BRANCH="$TRAVIS_PULL_REQUEST_BRANCH"
TARGET_BRANCH="$TRAVIS_PULL_REQUEST_BRANCH-build"

if [ "$TRAVIS_PULL_REQUEST" != "false" -a "$TRAVIS_PULL_REQUEST_BRANCH" = "master" ]; then
echo "[ERROR] We're in a pull request but we're in the master branch?!?!"
echo " This shouldn't happen..."
exit 1
fi

if [ "$TRAVIS_PULL_REQUEST" = "false" -a "$TRAVIS_BRANCH" = "master" ]; then
SOURCE_BRANCH="master"
TARGET_BRANCH="gh-pages"
fi

if [ "$TRAVIS_PULL_REQUEST" = "false" -a "$TRAVIS_BRANCH" != "master" ]; then
echo "[ABORT] We're in a push build (not in master nor in a pull request), so exiting. "
exit 0
fi

echo "[TRACE] SOURCE_BRANCH: $SOURCE_BRANCH"
echo "[TRACE] TARGET_BRANCH: $TARGET_BRANCH"

# Save some useful information
REPO=`git config remote.origin.url`
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
SHA=`git rev-parse --verify HEAD`

#define repo paths

TTML2_BUILD_DIR="$TRAVIS_BUILD_DIR/spec/build"
TTML2_SPEC_DIR="$TRAVIS_BUILD_DIR/spec"

# build the specification

echo -e "\n[TRACE] Building the specification"
cd $TTML2_SPEC_DIR
ant build

# create the build directory, and checkout or create the target branch

cd $TTML2_BUILD_DIR

git init
git remote add origin $REPO
git symbolic-ref HEAD refs/heads/$TARGET_BRANCH
git fetch origin $TARGET_BRANCH && git reset origin/$TARGET_BRANCH

# setup the user information for the repo

git config user.name "Travis CI"
git config user.email "$COMMIT_AUTHOR_EMAIL"

# Useful additional information for PR branches

echo -e "\n[TRACE] Adding build information"


if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo "[![Build Status](https://travis-ci.org/w3c/ttml2.svg?branch=$SOURCE_BRANCH)](https://travis-ci.org/w3c/ttml2)" >README.md
echo -e "\n\n# Specification TTML 2\n" >>README.md
echo -e "\nNote:\n" >>README.md
echo -e "\nThis branch was automatically built by Travis CI. <b>DO NOT EDIT</b>.\n" >>README.md

echo -e "\n Branch [$SOURCE_BRANCH](https://github.com/w3c/ttml2/tree/$SOURCE_BRANCH)\n" >>README.md

if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo -e "\n Pull request: [#$TRAVIS_PULL_REQUEST](https://github.com/w3c/ttml2/pull/$TRAVIS_PULL_REQUEST)\n" >>README.md
fi

if [ "$TRAVIS_PULL_REQUEST_SHA" != "" ]; then
echo -e "\n Commit: [$TRAVIS_PULL_REQUEST_SHA](https://github.com/w3c/ttml2/commit/$TRAVIS_PULL_REQUEST_SHA)" >>README.md
fi

echo -e "\nPull request specification can be previewed at https://rawgit.com/w3c/ttml2/$TARGET_BRANCH/index.html" >>README.md

echo -e "\n\n" >>README.md
fi


# If there are no changes to the compiled out (e.g. this is a README update) then just bail.
#if git diff --quiet; then
# echo "No changes to the output on this push; exiting."
# exit 0
#fi

# Commit the "changes", i.e. the new version.
# The delta will show diffs between new and old versions.
git add -A .
git commit -m "Deploy to $TARGET_BRANCH: ${SHA}"

# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in $TRAVIS_BUILD_DIR/deploy_key.enc -out $TRAVIS_BUILD_DIR/deploy_key -d
chmod 600 $TRAVIS_BUILD_DIR/deploy_key
eval `ssh-agent -s`
ssh-add $TRAVIS_BUILD_DIR/deploy_key

# Now that we're all set up, we can push.
echo "Ready to push"
git push $SSH_REPO $TARGET_BRANCH
99 changes: 58 additions & 41 deletions spec/build.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Apache Ant script to build spec.
Philippe Le Hegaret, W3C -->
<!-- Apache Ant script to build spec. Philippe Le Hegaret, W3C -->

<project name="TimedText" default="generate" basedir="." xmlns:if="ant:if" xmlns:unless="ant:unless">
<path id="saxon8.classpath">
Expand Down Expand Up @@ -225,54 +224,72 @@
</java>
</target>

<target name="kwexpand">
<echo message="Expanding keywords."/>
<exec executable="git" resultproperty="ttml2.diff" failonerror="false">
<arg value="diff"/>
<arg value="--quiet"/>
<arg value="ttml1.xml"/>
</exec>
<condition property="ttml2.dirty">
<equals arg1="${ttml1.diff}" arg2="1"/>
</condition>
<echo message="Warning ttml2.xml has uncommitted modifications." if:set="ttml2.dirty"/>
<tstamp>
<format property="today.mm" pattern="MM"/>
</tstamp>
<tstamp>
<format property="today.month" pattern="MMMM"/>
</tstamp>
<tstamp>
<format property="today.dd" pattern="dd"/>
</tstamp>
<tstamp>
<format property="today.day" pattern="EEEE"/>
</tstamp>
<tstamp>
<format property="today.year" pattern="yyyy"/>
</tstamp>
<exec executable="git" outputproperty="dateHash" failonerror="false">
<arg value="log"/>
<arg value="--quiet"/>
<arg value="-1"/>
<arg value="--oneline"/>
</exec>
<replace file="${html.dir}/${html.name}" token="$Date$" value="${dateHash}"/>
<replace file="${html.dir}/${html.name}" token="$dateMM$" value="${today.mm}"/>
<replace file="${html.dir}/${html.name}" token="$dateMonth$" value="${today.month}"/>
<replace file="${html.dir}/${html.name}" token="$dateDD$" value="${today.dd}"/>
<replace file="${html.dir}/${html.name}" token="$dateDay$" value="${today.dd}"/>
<replace file="${html.dir}/${html.name}" token="$dateYear$" value="${today.year}"/>
</target>

<target name="generate" description="Generate the specification without updating escaped entities."
depends="generate-schema-archives,validate-tt-specs,html">
depends="generate-schema-archives,validate-tt-specs,html,kwexpand">
</target>

<target name="sg" description="Shortened generation of the specification without updating changelog and acknowledgments sections, but without rebuilding escapes."
depends="generate-schema-archives,validate-tt-specs-dont-build-escapes,html">
</target>

<target name="kwexpand">
<exec executable="git" resultproperty="ttml2.diff" failonerror="false">
<arg value="diff"/>
<arg value="--quiet"/>
<arg value="ttml2.xml"/>
</exec>
<condition property="ttml2.dirty">
<equals arg1="${ttml2.diff}" arg2="1"/>
</condition>
<fail message="Unable to expand keywords, ttml2.xml has uncommitted modifications." if:set="ttml2.dirty"/>
<delete file="ttml2.xml"/>
<echo message="Checkout fresh copy while expanding keywords."/>
<exec executable="git">
<arg value="checkout"/>
<arg value="--"/>
<arg value="ttml2.xml"/>
</exec>
</target>

<target name="kwshrink">
<target name="rg" description="Regenerate using shortened generation and expands keywords."
depends="sg, kwexpand,">
</target>

<target name="rg" description="Regenerate using shortened generation, while expanding keywords."
depends="kwexpand,sg,kwshrink">
</target>

<target name="commit">
<exec executable="git">
<arg value="add"/>
<arg value="ttml2.html"/>
</exec>
<exec executable="git">
<arg value="commit"/>
<arg value="-m"/>
<arg value="Regenerate ED."/>
</exec>
</target>

<target name="rgc" description="Regenerate and commit."
depends="rg,commit">
<target name="build" description="Build the specification for publication" depends="generate">
<delete includeemptydirs="true" quiet="true">
<fileset dir="${build.dir}"/>
</delete>
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.dir}/images"/>
<mkdir dir="${build.dir}/rnc"/>
<mkdir dir="${build.dir}/xsd"/>
<copy file="${html.dir}/${html.name}" tofile="${build.dir}/index.html"/>
<copy todir="${build.dir}/images">
<fileset dir="${basedir}/images" includes="*.png"/>
</copy>
<copy file="${rnc.dir}/schema.zip" todir="${build.dir}/rnc"/>
<copy file="${xsd.dir}/schema.zip" todir="${build.dir}/xsd"/>
</target>

</project>
2 changes: 1 addition & 1 deletion spec/ttml2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!ENTITY % entities SYSTEM "entities.dtd">
%entities;
<!ENTITY status SYSTEM "status.xml">
<!ENTITY document.status "Editors' copy $Date$">
<!ENTITY document.status "Editors' Draft">
<!ENTITY title "&title;">
<!ENTITY prevloc "https://www.w3.org/TR/2017/WD-ttml2-20170106/">
<!ENTITY latestedloc "https://w3c.github.io/ttml2/spec/ttml2.html">
Expand Down

0 comments on commit f537742

Please sign in to comment.