Repository navigation
Release automatically when a version bump is merged to master #132
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
Open
conatus
wants to merge
3
commits into
master
Choose a base branch
from
release-on-version-bump
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| name: Script Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| pull_request: | ||
| workflow_call: | ||
|
|
||
| jobs: | ||
| script-tests: | ||
| name: Script tests | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Test version check | ||
| run: ./scripts/check-version.test.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Checks that the plugin version is the same in every place it is recorded, | ||
| # and that readme.txt has a changelog entry for it. Prints the version. | ||
| # | ||
| # Usage: ./scripts/check-version.sh [project root] | ||
|
|
||
| set -e | ||
|
|
||
| print_error() { | ||
| echo "ERROR: $1" >&2 | ||
| } | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| PROJECT_ROOT="${1:-$(cd "$SCRIPT_DIR/.." && pwd)}" | ||
|
|
||
| README_TXT="$PROJECT_ROOT/packages/join-block/readme.txt" | ||
| JOIN_PHP="$PROJECT_ROOT/packages/join-block/join.php" | ||
| INDEX_TSX="$PROJECT_ROOT/packages/join-flow/src/index.tsx" | ||
|
|
||
| for FILE in "$README_TXT" "$JOIN_PHP" "$INDEX_TSX"; do | ||
| if [ ! -f "$FILE" ]; then | ||
| print_error "$FILE not found" | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| PHP_VERSION=$(sed -n 's/^ \* Version: *\([^ ]*\) *$/\1/p' "$JOIN_PHP" | head -n 1) | ||
| README_VERSION=$(sed -n 's/^Stable tag: *\([^ ]*\) *$/\1/p' "$README_TXT" | head -n 1) | ||
| TSX_VERSION=$(sed -n 's/^ *release: "\([^"]*\)".*$/\1/p' "$INDEX_TSX" | head -n 1) | ||
|
|
||
| if ! [[ "$PHP_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| print_error "Could not read an X.Y.Z version from the Version header in packages/join-block/join.php (found '$PHP_VERSION')" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "$README_VERSION" != "$PHP_VERSION" ] || [ "$TSX_VERSION" != "$PHP_VERSION" ]; then | ||
| print_error "Version numbers disagree:" | ||
| echo " packages/join-block/join.php Version: $PHP_VERSION" >&2 | ||
| echo " packages/join-block/readme.txt Stable tag: $README_VERSION" >&2 | ||
| echo " packages/join-flow/src/index.tsx release: $TSX_VERSION" >&2 | ||
| echo "Run ./scripts/bump-version.sh to update all three together." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| CHANGELOG_ENTRIES=$(awk -v heading="= $PHP_VERSION =" ' | ||
| /^== Changelog ==/ { in_changelog = 1; next } | ||
| in_changelog && /^== / { exit } | ||
| in_changelog && $0 == heading { in_entry = 1; next } | ||
| in_entry && /^= / { exit } | ||
| in_entry && /^\* / { count++ } | ||
| END { print count + 0 } | ||
| ' "$README_TXT") | ||
|
|
||
| if [ "$CHANGELOG_ENTRIES" -eq 0 ]; then | ||
| print_error "packages/join-block/readme.txt has no changelog entry for $PHP_VERSION" | ||
| echo "Add a '= $PHP_VERSION =' heading with at least one '* ' line under '== Changelog =='." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "$PHP_VERSION" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Tests for check-version.sh. Run with: ./scripts/check-version.test.sh | ||
|
|
||
| set -u | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| CHECK="$SCRIPT_DIR/check-version.sh" | ||
| FIXTURES=$(mktemp -d) | ||
| trap 'rm -rf "$FIXTURES"' EXIT | ||
| FAILURES=0 | ||
|
|
||
| # make_fixture <join.php version> <readme.txt stable tag> <index.tsx release> <changelog heading> [changelog line] | ||
| make_fixture() { | ||
| local root | ||
| root=$(mktemp -d "$FIXTURES/project.XXXXXX") | ||
| mkdir -p "$root/packages/join-block" "$root/packages/join-flow/src" | ||
| cat > "$root/packages/join-block/join.php" <<EOF | ||
| <?php | ||
|
|
||
| /** | ||
| * Plugin Name: Common Knowledge Join Flow | ||
| * Version: $1 | ||
| */ | ||
| EOF | ||
| cat > "$root/packages/join-block/readme.txt" <<EOF | ||
| === Common Knowledge Join Flow === | ||
| Stable tag: $2 | ||
|
|
||
| == Changelog == | ||
|
|
||
| = $4 = | ||
| ${5-* Something changed} | ||
|
|
||
| = 1.0.0 = | ||
| * First release | ||
|
|
||
| == Upgrade Notice == | ||
|
|
||
| = $1 = | ||
| * An upgrade notice, not a changelog entry | ||
| EOF | ||
| cat > "$root/packages/join-flow/src/index.tsx" <<EOF | ||
| init({ | ||
| release: "$3" | ||
| }); | ||
| EOF | ||
| echo "$root" | ||
| } | ||
|
|
||
| expect_pass() { | ||
| local name="$1" root="$2" expected="$3" output | ||
| if output=$("$CHECK" "$root" 2>&1) && [ "$output" = "$expected" ]; then | ||
| echo "ok - $name" | ||
| else | ||
| echo "not ok - $name: expected success printing '$expected', got: $output" | ||
| FAILURES=$((FAILURES + 1)) | ||
| fi | ||
| } | ||
|
|
||
| expect_fail() { | ||
| local name="$1" root="$2" message="$3" output | ||
| if output=$("$CHECK" "$root" 2>&1); then | ||
| echo "not ok - $name: expected failure, got: $output" | ||
| FAILURES=$((FAILURES + 1)) | ||
| elif [[ "$output" != *"$message"* ]]; then | ||
| echo "not ok - $name: expected message containing '$message', got: $output" | ||
| FAILURES=$((FAILURES + 1)) | ||
| else | ||
| echo "ok - $name" | ||
| fi | ||
| } | ||
|
|
||
| expect_pass "matching versions with a changelog entry" \ | ||
| "$(make_fixture 1.2.3 1.2.3 1.2.3 1.2.3)" "1.2.3" | ||
|
|
||
| expect_fail "readme.txt stable tag differs" \ | ||
| "$(make_fixture 1.2.3 1.2.2 1.2.3 1.2.3)" "Version numbers disagree" | ||
|
|
||
| expect_fail "index.tsx release differs" \ | ||
| "$(make_fixture 1.2.3 1.2.3 1.2.2 1.2.3)" "Version numbers disagree" | ||
|
|
||
| expect_fail "no changelog entry for the version" \ | ||
| "$(make_fixture 1.2.3 1.2.3 1.2.3 1.2.2)" "no changelog entry for 1.2.3" | ||
|
|
||
| expect_fail "changelog heading with no entries" \ | ||
| "$(make_fixture 1.2.3 1.2.3 1.2.3 1.2.3 "")" "no changelog entry for 1.2.3" | ||
|
|
||
| expect_fail "version header is not X.Y.Z" \ | ||
| "$(make_fixture 1.2 1.2 1.2 1.2)" "Could not read an X.Y.Z version" | ||
|
|
||
| expect_pass "real project files" "$SCRIPT_DIR/.." \ | ||
| "$(sed -n 's/^Stable tag: *//p' "$SCRIPT_DIR/../packages/join-block/readme.txt")" | ||
|
|
||
| if [ "$FAILURES" -gt 0 ]; then | ||
| echo "$FAILURES test(s) failed" | ||
| exit 1 | ||
| fi | ||
| echo "All tests passed" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't write this kind of documentation which says a change occurred. Documentation should detail the current status, not some legacy status that people don't need to know about.