From 483baebe7a6b9f0a7d4285d1541c0f95749dbfa6 Mon Sep 17 00:00:00 2001 From: Rick Henry Date: Thu, 13 Jun 2024 16:14:23 +0100 Subject: [PATCH 1/5] refactor: use true tag name for BOOKSTACK_VERSION This allows the latest tag to be fetched from GitHub's API and used directly, instead of requiring parsing. --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 05168b4..fe60b0c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ FROM alpine:3 AS bookstack -ENV BOOKSTACK_VERSION=24.10.2 +ENV BOOKSTACK_VERSION=v24.10.2 RUN apk add --no-cache curl tar RUN set -x; \ - curl -SL -o bookstack.tar.gz https://github.com/BookStackApp/BookStack/archive/v${BOOKSTACK_VERSION}.tar.gz \ + curl -SL -o bookstack.tar.gz https://github.com/BookStackApp/BookStack/archive/${BOOKSTACK_VERSION}.tar.gz \ && mkdir -p /bookstack \ && tar xvf bookstack.tar.gz -C /bookstack --strip-components=1 \ && rm bookstack.tar.gz From c37d6b8a87b13c23473d39e9485b1366d070d0ba Mon Sep 17 00:00:00 2001 From: Rick Henry Date: Thu, 13 Jun 2024 16:16:44 +0100 Subject: [PATCH 2/5] feat: create script to update Dockerfile --- scripts/update_dockerfile.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 scripts/update_dockerfile.sh diff --git a/scripts/update_dockerfile.sh b/scripts/update_dockerfile.sh new file mode 100755 index 0000000..32c93b6 --- /dev/null +++ b/scripts/update_dockerfile.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +BOOKSTACK_VERSION=$(curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/BookstackApp/Bookstack/releases/latest | \ + jq -r .tag_name +) + +echo "Latest: ${BOOKSTACK_VERSION}. Updating.." + +sed \ + -i '' \ + -e "s/^ENV BOOKSTACK_VERSION=.*/ENV BOOKSTACK_VERSION=${BOOKSTACK_VERSION}/" \ + Dockerfile From 31d55d7f9960de66ff0356e4b581384aac139ccb Mon Sep 17 00:00:00 2001 From: Rick Henry Date: Thu, 13 Jun 2024 16:58:12 +0100 Subject: [PATCH 3/5] feat: start adding tags with new versions --- scripts/update_dockerfile.sh | 13 +++++++++++-- scripts/update_tags_and_docs.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100755 scripts/update_tags_and_docs.sh diff --git a/scripts/update_dockerfile.sh b/scripts/update_dockerfile.sh index 32c93b6..e203e0f 100755 --- a/scripts/update_dockerfile.sh +++ b/scripts/update_dockerfile.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +echo "Fetching latest Bookstack release from GitHub API" + BOOKSTACK_VERSION=$(curl -L \ -H "Accept: application/vnd.github+json" \ -H "X-GitHub-Api-Version: 2022-11-28" \ @@ -7,9 +9,16 @@ BOOKSTACK_VERSION=$(curl -L \ jq -r .tag_name ) -echo "Latest: ${BOOKSTACK_VERSION}. Updating.." +echo "Found latest version: ${BOOKSTACK_VERSION}" + +# Get the root of the Git repository in order to correctly path e.g. Dockerfile +GIT_ROOT=$(git rev-parse --show-toplevel) +echo "Updating Dockerfile.." sed \ -i '' \ -e "s/^ENV BOOKSTACK_VERSION=.*/ENV BOOKSTACK_VERSION=${BOOKSTACK_VERSION}/" \ - Dockerfile + "${GIT_ROOT}/Dockerfile" + +git add "${GIT_ROOT}/Dockerfile" +git commit -S -m "feat: update Dockerfile to use Bookstack ${BOOKSTACK_VERSION}" diff --git a/scripts/update_tags_and_docs.sh b/scripts/update_tags_and_docs.sh new file mode 100755 index 0000000..a090452 --- /dev/null +++ b/scripts/update_tags_and_docs.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +# Get the root of the Git repository in order to correctly path e.g. Dockerfile +GIT_ROOT=$(git rev-parse --show-toplevel) + +# Extract the version from the Dockerfile, as there could have been a new +# release since the last run. + +BOOKSTACK_VERSION=$(awk \ + '/ENV BOOKSTACK_VERSION/{split($2,b,"="); print b[2]}' \ + "${GIT_ROOT}/Dockerfile" +) + +echo "Extracted version: ${BOOKSTACK_VERSION}" + +# Remove the 'v' for our tags +BOOKSTACK_VERSION="${BOOKSTACK_VERSION/#v/}" +# Remove leading zeros to make the version fit a SemVer-shaped hole +BOOKSTACK_VERSION="${BOOKSTACK_VERSION/.0/.}" +# And again for patch version, just in case +BOOKSTACK_VERSION="${BOOKSTACK_VERSION/.0/.}" + +echo "Tag name: ${BOOKSTACK_VERSION}" + +git tag -s -a "${BOOKSTACK_VERSION}" -m "Release version ${BOOKSTACK_VERSION}" +git push --tags + +# TODO: Sort VERSION file +# TODO: Update README version +# TODO: Update docker-compose From 9a4aa4533921f2acf05e8b4b838c3ee225483a6b Mon Sep 17 00:00:00 2001 From: Rick Henry Date: Fri, 8 Nov 2024 14:34:30 +0000 Subject: [PATCH 4/5] doc: use update script in release doc --- RELEASE.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/RELEASE.md b/RELEASE.md index 9b5e98d..0db7ced 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -4,6 +4,20 @@ When the version changes, a new release should be cut. To do this, push a tag with the [valid SemVer][semver-checker] version number as the tag. It may also be useful to update documentation references at the same time. +## Scripts + +Update the Dockerfile with: + +```shell +$ scripts/update_dockerfile.sh +Fetching latest Bookstack release from GitHub API + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed +100 3467 100 3467 0 0 18743 0 --:--:-- --:--:-- --:--:-- 18842 +Found latest version: v24.10.1 +Updating Dockerfile.. +``` + ## Example For Bookstack version 23.01: From e64ed8397e04aa2fee023f198e64ef21d765d9f1 Mon Sep 17 00:00:00 2001 From: Rick Henry Date: Wed, 13 Nov 2024 13:29:05 +0000 Subject: [PATCH 5/5] feat: update documentation in release scripts --- scripts/update_tags_and_docs.sh | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/scripts/update_tags_and_docs.sh b/scripts/update_tags_and_docs.sh index a090452..1d4afcc 100755 --- a/scripts/update_tags_and_docs.sh +++ b/scripts/update_tags_and_docs.sh @@ -25,6 +25,23 @@ echo "Tag name: ${BOOKSTACK_VERSION}" git tag -s -a "${BOOKSTACK_VERSION}" -m "Release version ${BOOKSTACK_VERSION}" git push --tags -# TODO: Sort VERSION file -# TODO: Update README version -# TODO: Update docker-compose +echo "Extracting old version info.." +OLD_BS_VERSION="$(cat VERSION)" + +echo "Updating README and reference docker-compose.yml.." +sed \ + -i '' \ + -e "s/${OLD_BS_VERSION}/${BOOKSTACK_VERSION}/g" \ + "${GIT_ROOT}/README.md" \ + "${GIT_ROOT}/docker-compose.yml" + +echo "Updating VERSION file.." +echo "${BOOKSTACK_VERSION}" > "${GIT_ROOT}/VERSION" + +git add \ + "${GIT_ROOT}/README.md" \ + "${GIT_ROOT}/docker-compose.yml" \ + "${GIT_ROOT}/VERSION" + +git commit -S -m "doc: update documentation to reference ${BOOKSTACK_VERSION}" +git push