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

Script release and documentation updates #502

Merged
merged 5 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 14 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
24 changes: 24 additions & 0 deletions scripts/update_dockerfile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/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" \
https://api.github.com/repos/BookstackApp/Bookstack/releases/latest | \
jq -r .tag_name
)

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}/" \
"${GIT_ROOT}/Dockerfile"

git add "${GIT_ROOT}/Dockerfile"
git commit -S -m "feat: update Dockerfile to use Bookstack ${BOOKSTACK_VERSION}"
47 changes: 47 additions & 0 deletions scripts/update_tags_and_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/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

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
Loading