Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
build(fix): update release hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsneighbour committed Jun 30, 2023
1 parent 8700c7c commit c4385b0
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 15 deletions.
27 changes: 14 additions & 13 deletions bin/release/postrelease
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/bin/bash
# v20230630.1

REQUIRED_TOOLS=(
git
sed
node
)

# check if all requirements are met
for TOOL in "${REQUIRED_TOOLS[@]}"; do
if ! command -v "${TOOL}" >/dev/null; then
echo "${TOOL} is required... "
Expand All @@ -25,24 +23,29 @@ if [ -f "$FILE" ]; then
# shellcheck source=/dev/null
source "${FILE}"
set +a # stop exporting
else
echo "no .env file found"
exit 0
fi

# update version in citation configuration
FILE=CITATION.cff
if test -f "$FILE"; then
VERSION=$(node -pe 'require("./package.json")["version"]')
sed -i "s/^version: .*/version: ${VERSION}/" $FILE
DATE=$(date +%F)
sed -i "s/^date-released: .*/date-released: ${DATE}/" $FILE
sed -i "s/date-released: .*/date-released: ${DATE}/" $FILE
git add $FILE
fi

# add re-versioned files to recent edit
git add data/dnb/
git commit --amend --no-edit --quiet --signoff --no-verify
# adding data directory for new build information
git add data/dnb
git add README.md
git commit --signoff --amend --no-edit

# push everything up
git push --follow-tags origin main --quiet --force
git push --tags --quiet --force
# push release to GitHub
git push origin main --follow-tags
git push origin --tags

# create a release on GitHub
GITHUB_REPO=https://github.com/${GITHUB_REPOSLUG}
Expand All @@ -53,6 +56,4 @@ curl \
-H "Authorization: token ${GITHUB_SECRET}" \
https://api.github.com/repos/"${GITHUB_REPOSLUG}"/releases \
-d "{\"tag_name\":\"v${VERSION}\",\"name\":\"v${VERSION}\",\"draft\":false,\"prerelease\":false,\"generate_release_notes\":true}"
//xdg-open "${URL}" &>>/dev/null

git push origin main --quiet
xdg-open "${URL}" &>>/dev/null
44 changes: 42 additions & 2 deletions bin/release/prerelease
Original file line number Diff line number Diff line change
@@ -1,4 +1,44 @@
#!/bin/bash
# v20230630.1

# TODO read component names into array
# TODO read replacement configuration into array
REQUIRED_TOOLS=(
git
hugo
typos
)

for TOOL in "${REQUIRED_TOOLS[@]}"; do
if ! command -v "${TOOL}" >/dev/null; then
echo "${TOOL} is required... "
exit 1
fi
done

FILE=.env
if [ -f "$FILE" ]; then
echo "exporting .env"
set -a # export all variables created next
# this routine ranges through a folder of files that we don't explicitly know (@davidsneighbour)
# see https://github.com/koalaman/shellcheck/wiki/SC1090
# shellcheck source=/dev/null
source "${FILE}"
set +a # stop exporting
else
echo "no .env file found"
exit 0
fi

SCRIPTPATH="$(
cd "$(dirname "$0")" >/dev/null 2>&1 || exit
pwd -P
)"
CURPATH="$(pwd -P)"

hugo mod get -u ./...
hugo mod tidy

git add "${CURPATH}"/go.mod
FILE="${CURPATH}"/go.sum
if test -f "$FILE"; then
git add go.sum
fi

0 comments on commit c4385b0

Please sign in to comment.