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

Update the buildkite pipeline to build a release on v* tags #3295

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
41 changes: 32 additions & 9 deletions .buildkite/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
x-yaml-aliases:
commands:
- &hugo_build_environment_setup |
# Install package dependencies
apk add nodejs npm git hugo
# Install the node dependencies necessary to build the spec
npm i
# Pull all git submodules, required for the hugo theme
git submodule update --init --recursive
# Pull current proposal information
npm run get-proposals
Comment on lines +10 to +11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it right that this is part of the release?


steps:
- label: ":snake: Build swagger definitions for matrix.org"
command:
Expand All @@ -19,14 +31,7 @@ steps:

- label: ":books: Build the spec"
command:
# Install package dependencies
- apk add nodejs npm git hugo
# Install the node dependencies necessary to build the spec
- npm i
# Pull all git submodules, required for the hugo theme
- git submodule update --init --recursive
# Pull current proposal information
- npm run get-proposals
- *hugo_build_environment_setup
# Build the spec, will build to './spec'
# Set the baseURL as we're deploying to https://spec.matrix.org/unstable
- hugo --baseURL "/unstable" -d "spec"
Expand All @@ -36,4 +41,22 @@ steps:
- spec.tar.gz
plugins:
- docker#v3.7.0:
image: alpine
image: alpine

- label: ":rocket: Release the spec"
# Only execute this step on tags matching "vX.Y"
if: build.tag =~ /^v\d+\.\d+$$/
command:
- *hugo_build_environment_setup
# Generate a stable version of the spec
- scripts/prepare-spec-release.sh "$BUILDKITE_TAG" spec
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved
# Package the build as an artefact, which will be downloaded by:
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved
# https://github.com/matrix-org/buildkite-webhook-listener
- tar -czf spec-release.tar.gz spec
artifact_paths:
- spec-release.tar.gz
plugins:
- docker#v3.7.0:
image: alpine
mount-buildkite-agent: false
propogate-environment: true
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, if this is required, you better spell propagate correctly. I suspect it's not required?

40 changes: 40 additions & 0 deletions scripts/prepare-spec-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh
#
# This script will generate a stable release build of the spec.
# It assumes you have `hugo` set up and configured properly.
#
# Usage:
#
# ./scripts/prepare-spec-release.sh v<Matrix global version number> <output directory>
#
# Example:
#
# ./scripts/prepare-spec-release.sh v1.2.3 release/
#
# The released spec files will be available at <output directory>/<Matrix global version number>,
# i.e ./release/v1.2.3/.
#
# This script is used by .buildkite/pipeline as part of building and releasing the spec.

if [ $# -lt 2 ]; then
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved
echo 1>&2 "$0: not enough arguments"
exit 2
fi

# Modify the build config to specify a stable release
sed -i.bak -e 's/status = "unstable"/status = "stable"/' config.toml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than overwrite config.toml (and have to replace it later, with the possible danger of not doing so if the script exits early, could you write the modified config to a temp file and give hugo a --config option?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, given hugo lets you specify multiple config files, maybe you don't need to copy the whole thing, and can just generate a second config file which overrides/sets the options you need?


# Create a release.yaml file which is used to build the changelog entry
tee changelogs/release.yaml <<EOF
tag: $1
date: $(date +"%B %d, %Y")
EOF

# Build the spec, and set the baseURL and output directory to the new release version,
# which should match the tag name.
hugo --baseURL "/$1" -d "$2/$1"

# Restore the original config file state
mv config.toml.bak config.toml

echo "Spec release files are available in: $2/$1"
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved