Files
releases/build/gen-release-patch.sh
T
Stephan Renatus 7f78653f9c build: run 'make generate' in release container (#4934)
This replaces the docker image so that we get one that has all of these
commands available: make, git, go, python2 and perl.

We can now run `make generate` in the steps used to generate the release patch,
so the release patch contains the builtin_metadata.json changes.

Before, we had been running `make generate` in the working directory, and
copied the file into the container's workdir; but that left the working
directory modified, and hindered patch application before cleaning up.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2022-07-26 12:43:59 +02:00

93 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
OPA_DIR=/go/src/github.com/open-policy-agent/opa
usage() {
echo "gen-release-patch.sh --source-url=<git-url>"
echo " --version=<mj.mn.pt>"
}
for i in "$@"; do
case $i in
--source-url=*)
SOURCE_URL="${i#*=}"
shift
;;
--version=*)
VERSION="${i#*=}"
shift
;;
*)
usage
exit 1
;;
esac
done
if [ -z "$SOURCE_URL" ]; then
usage
exit 1
elif [ -z "$VERSION" ]; then
usage
exit 1
fi
git clone $SOURCE_URL $OPA_DIR
cd $OPA_DIR
if [ -z "$LAST_VERSION" ]; then
LAST_VERSION=$(git describe --abbrev=0 --tags)
fi
update_version() {
./build/update-version.sh "$VERSION"
}
update_changelog() {
if $(grep -q '## Unreleased' CHANGELOG.md) ; then
cat >_CHANGELOG.md <<EOF
$(awk '1;/## Unreleased/{exit}' CHANGELOG.md | sed '$d')
## $VERSION
$(./build/changelog.py $LAST_VERSION HEAD)
$(sed '1,/## Unreleased/d' CHANGELOG.md)
EOF
else
cat >_CHANGELOG.md <<EOF
$(awk '{if ($1 == "##") {exit;} else {print $0}}' CHANGELOG.md)
## $VERSION
$(./build/changelog.py $LAST_VERSION HEAD)
$(awk '/^##/{f=1}f' CHANGELOG.md)
EOF
fi
mv _CHANGELOG.md CHANGELOG.md
}
update_capabilities() {
mkdir -p capabilities
cp capabilities.json capabilities/v$VERSION.json
# Use --intent-to-add so that new file shows up in git diff
git add --intent-to-add capabilities/v$VERSION.json
}
update_metadata() {
make generate
git add --intent-to-add builtin_metadata.json
}
main() {
update_version
update_changelog
update_capabilities
update_metadata
git --no-pager diff --no-color
}
main