Skip to content

Commit a5d0ea0

Browse files
hopeman15Kyle Roe
andauthored
[CI/CD] Readme / Change-log Action Verification (#238)
* basic workflow * scripts * makefile * proper workflow * better messages * use get next version script --------- Co-authored-by: Kyle Roe <[hopeman15@users.noreply.github.com]>
1 parent 425c0c3 commit a5d0ea0

5 files changed

Lines changed: 76 additions & 18 deletions

File tree

.github/workflows/verify-doc.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Verify Documentation
2+
3+
on:
4+
pull_request:
5+
types: [ synchronize, opened, reopened, labeled, unlabeled ]
6+
7+
jobs:
8+
check_docs:
9+
if: ${{ contains(github.event.pull_request.labels.*.name, 'release :tada:') }}
10+
name: Check Changelog/Readme
11+
runs-on: ubuntu-latest
12+
permissions:
13+
actions: read
14+
strategy:
15+
matrix:
16+
file: [ 'website/docs/changelog.md','README.md' ]
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
- name: Major
21+
if: ${{ contains(github.event.*.labels.*.name, 'major :1st_place_medal:') }}
22+
run: make verify-doc BUMP=major FILE=${{ matrix.file }}
23+
- name: Minor
24+
if: ${{ contains(github.event.*.labels.*.name, 'minor :2nd_place_medal:') }}
25+
run: make verify-doc BUMP=minor FILE=${{ matrix.file }}
26+
- name: Patch
27+
if: ${{ contains(github.event.*.labels.*.name, 'patch :3rd_place_medal:') }}
28+
run: make verify-doc BUMP=patch FILE=${{ matrix.file }}

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
BUMP ?= patch
2+
FILE ?= empty
23

3-
.PHONY: all build clean dependencies coverage format lint local publish test version \
4+
.PHONY: all build clean dependencies coverage format lint local publish test verify-doc version \
45
build-docs install-docs start-docs upgrade-docs
56

67
all: clean format lint test coverage build
@@ -32,6 +33,9 @@ publish:
3233
test:
3334
./gradlew test
3435

36+
verify-doc:
37+
./scripts/verify-doc.sh ${BUMP} ${FILE}
38+
3539
version:
3640
./scripts/create-release.sh ${BUMP}
3741

scripts/create-release.sh

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,8 @@ set -o pipefail
44

55
RELEASE_TYPE=${1}
66

7-
# Get current release version
8-
git fetch --force --tags
9-
CURRENT_RELEASE=$(git tag --sort=committerdate | tail -1)
7+
NEW_RELEASE=$(./scripts/get_next_version.sh "$RELEASE_TYPE")
108

11-
# Separate major, minor and patch numbers
12-
IFS='.' read -r MAJOR MINOR PATCH <<<"$CURRENT_RELEASE"
13-
14-
# $/${} is unnecessary on arithmetic variables.
15-
# shellcheck disable=SC2004
16-
if [[ "${RELEASE_TYPE}" == "major" ]]; then
17-
NEW_RELEASE="$(($MAJOR + 1)).0.0"
18-
elif [ "${RELEASE_TYPE}" == "minor" ]; then
19-
NEW_RELEASE="$MAJOR.$(($MINOR + 1)).0"
20-
else
21-
NEW_RELEASE="$MAJOR.$MINOR.$(($PATCH + 1))"
22-
fi
23-
24-
echo "Bumping version from $CURRENT_RELEASE to $NEW_RELEASE"
9+
echo "Bumping version to $NEW_RELEASE"
2510

2611
gh release create "$NEW_RELEASE" --target "main" --generate-notes

scripts/get_next_version.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
set -o pipefail
4+
5+
RELEASE_TYPE=${1}
6+
7+
# Get current release version
8+
git fetch --force --tags
9+
CURRENT_RELEASE=$(git tag --sort=committerdate | tail -1)
10+
11+
# Separate major, minor and patch numbers
12+
IFS='.' read -r MAJOR MINOR PATCH <<<"$CURRENT_RELEASE"
13+
14+
# $/${} is unnecessary on arithmetic variables.
15+
# shellcheck disable=SC2004
16+
if [[ "${RELEASE_TYPE}" == "major" ]]; then
17+
NEW_RELEASE="$(($MAJOR + 1)).0.0"
18+
elif [ "${RELEASE_TYPE}" == "minor" ]; then
19+
NEW_RELEASE="$MAJOR.$(($MINOR + 1)).0"
20+
else
21+
NEW_RELEASE="$MAJOR.$MINOR.$(($PATCH + 1))"
22+
fi
23+
24+
echo "$NEW_RELEASE"

scripts/verify-doc.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
set -o pipefail
4+
5+
RELEASE_TYPE=${1}
6+
FILE=${2}
7+
8+
VERSION=$(./scripts/get_next_version.sh "$RELEASE_TYPE")
9+
10+
echo "Verifying version $VERSION is defined in: $FILE."
11+
if grep -R "$VERSION" "$FILE"; then
12+
echo "Version info found."
13+
exit 0
14+
else
15+
echo "Version info not found in: $FILE"
16+
exit 1
17+
fi

0 commit comments

Comments
 (0)