cordova-plugin-ymchat 3.4.2 → 3.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/release.yml +104 -0
- package/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/plugin.xml +1 -1
- package/scripts/extract_changelog_section.sh +32 -0
- package/scripts/prepare_release.sh +191 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# Reproduces this repo's existing manual release process: whenever a push to
|
|
4
|
+
# main carries a version in package.json that hasn't been tagged yet, tag
|
|
5
|
+
# that commit (vX.Y.Z), publish a GitHub Release whose body is the matching
|
|
6
|
+
# CHANGELOG.md section, and publish the package to npm. A push to main that
|
|
7
|
+
# isn't a release (its package.json version is already tagged) is a no-op.
|
|
8
|
+
#
|
|
9
|
+
# Tag/release creation and the npm publish are gated independently: tag+
|
|
10
|
+
# release only happen for a not-yet-tagged version, but npm publish is
|
|
11
|
+
# retried on every run (including a manual workflow_dispatch, e.g. to
|
|
12
|
+
# recover from a publish failure) as long as that version isn't on npm yet.
|
|
13
|
+
#
|
|
14
|
+
# Requires an NPM_TOKEN repo secret (an npm token created with 2FA-bypass —
|
|
15
|
+
# "Automation" for a classic token, or the "Bypass two-factor authentication"
|
|
16
|
+
# checkbox for a granular token — otherwise `npm publish` fails with
|
|
17
|
+
# EOTP/E403 since CI can't supply a one-time password).
|
|
18
|
+
|
|
19
|
+
on:
|
|
20
|
+
push:
|
|
21
|
+
branches: [main]
|
|
22
|
+
workflow_dispatch: {}
|
|
23
|
+
|
|
24
|
+
permissions:
|
|
25
|
+
contents: write
|
|
26
|
+
|
|
27
|
+
jobs:
|
|
28
|
+
release:
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v4
|
|
32
|
+
with:
|
|
33
|
+
fetch-depth: 0
|
|
34
|
+
|
|
35
|
+
- name: Determine version from package.json
|
|
36
|
+
id: version
|
|
37
|
+
run: |
|
|
38
|
+
VERSION="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' package.json | head -1)"
|
|
39
|
+
if [[ -z "$VERSION" ]]; then
|
|
40
|
+
echo "::error::could not read version from package.json"
|
|
41
|
+
exit 1
|
|
42
|
+
fi
|
|
43
|
+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
44
|
+
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
|
|
45
|
+
|
|
46
|
+
- name: Check whether this version is already released
|
|
47
|
+
id: check
|
|
48
|
+
run: |
|
|
49
|
+
if git rev-parse -q --verify "refs/tags/${{ steps.version.outputs.tag }}" >/dev/null; then
|
|
50
|
+
echo "already_tagged=true" >> "$GITHUB_OUTPUT"
|
|
51
|
+
else
|
|
52
|
+
echo "already_tagged=false" >> "$GITHUB_OUTPUT"
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
if npm view "cordova-plugin-ymchat@${{ steps.version.outputs.version }}" version >/dev/null 2>&1; then
|
|
56
|
+
echo "already_published=true" >> "$GITHUB_OUTPUT"
|
|
57
|
+
else
|
|
58
|
+
echo "already_published=false" >> "$GITHUB_OUTPUT"
|
|
59
|
+
fi
|
|
60
|
+
|
|
61
|
+
- name: Extract CHANGELOG section
|
|
62
|
+
if: steps.check.outputs.already_tagged == 'false'
|
|
63
|
+
id: changelog
|
|
64
|
+
run: |
|
|
65
|
+
VERSION="${{ steps.version.outputs.version }}"
|
|
66
|
+
NOTES_FILE="$(mktemp)"
|
|
67
|
+
if ! ./scripts/extract_changelog_section.sh "$VERSION" CHANGELOG.md > "$NOTES_FILE"; then
|
|
68
|
+
echo "::error::no CHANGELOG.md section found for $VERSION"
|
|
69
|
+
exit 1
|
|
70
|
+
fi
|
|
71
|
+
echo "notes_file=$NOTES_FILE" >> "$GITHUB_OUTPUT"
|
|
72
|
+
|
|
73
|
+
- name: Create tag
|
|
74
|
+
if: steps.check.outputs.already_tagged == 'false'
|
|
75
|
+
env:
|
|
76
|
+
TAG: ${{ steps.version.outputs.tag }}
|
|
77
|
+
run: |
|
|
78
|
+
git config user.name "github-actions[bot]"
|
|
79
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
80
|
+
git tag -a "$TAG" -m "$TAG"
|
|
81
|
+
git push origin "$TAG"
|
|
82
|
+
|
|
83
|
+
- name: Create GitHub Release
|
|
84
|
+
if: steps.check.outputs.already_tagged == 'false'
|
|
85
|
+
env:
|
|
86
|
+
TAG: ${{ steps.version.outputs.tag }}
|
|
87
|
+
GH_TOKEN: ${{ github.token }}
|
|
88
|
+
run: |
|
|
89
|
+
gh release create "$TAG" \
|
|
90
|
+
--title "$TAG" \
|
|
91
|
+
--notes-file "${{ steps.changelog.outputs.notes_file }}"
|
|
92
|
+
|
|
93
|
+
- name: Set up Node for npm publish
|
|
94
|
+
if: steps.check.outputs.already_published == 'false'
|
|
95
|
+
uses: actions/setup-node@v4
|
|
96
|
+
with:
|
|
97
|
+
node-version: 20
|
|
98
|
+
registry-url: https://registry.npmjs.org
|
|
99
|
+
|
|
100
|
+
- name: Publish to npm
|
|
101
|
+
if: steps.check.outputs.already_published == 'false'
|
|
102
|
+
env:
|
|
103
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
104
|
+
run: npm publish --access public
|
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [3.4.3]
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- No functional change — validates the automated tag/CHANGELOG/GitHub Release/npm-publish pipeline end-to-end (see #87).
|
|
13
|
+
|
|
8
14
|
## [3.4.2]
|
|
9
15
|
|
|
10
16
|
### Fixed
|
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
|
2
|
-
<plugin id="cordova-plugin-ymchat" version="3.4.
|
|
2
|
+
<plugin id="cordova-plugin-ymchat" version="3.4.3"
|
|
3
3
|
xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
4
4
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
5
5
|
<name>ymchat</name>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Extracts the CHANGELOG.md section for a given release version (e.g. "3.4.2",
|
|
3
|
+
# no "v" prefix — that's how entries are headed in this repo's Keep a Changelog
|
|
4
|
+
# -style CHANGELOG.md): the category header + bullets between its "## [X.Y.Z]"
|
|
5
|
+
# heading and the next heading, heading itself stripped. This is exactly what
|
|
6
|
+
# goes into the GitHub Release body.
|
|
7
|
+
#
|
|
8
|
+
# Usage: extract_changelog_section.sh <version e.g. 3.4.2> [changelog-file]
|
|
9
|
+
|
|
10
|
+
set -euo pipefail
|
|
11
|
+
|
|
12
|
+
VERSION="${1:?usage: extract_changelog_section.sh <version e.g. 3.4.2> [changelog-file]}"
|
|
13
|
+
CHANGELOG="${2:-CHANGELOG.md}"
|
|
14
|
+
|
|
15
|
+
awk -v ver="$VERSION" '
|
|
16
|
+
BEGIN { in_section = 0; found = 0; n = 0 }
|
|
17
|
+
/^## \[[0-9]/ {
|
|
18
|
+
if (in_section) { exit }
|
|
19
|
+
if ($0 == "## [" ver "]") { in_section = 1; found = 1; next }
|
|
20
|
+
next
|
|
21
|
+
}
|
|
22
|
+
in_section { n++; buf[n] = $0 }
|
|
23
|
+
END {
|
|
24
|
+
if (!found) { exit 1 }
|
|
25
|
+
# trim trailing blank lines
|
|
26
|
+
while (n > 0 && buf[n] ~ /^[[:space:]]*$/) { n-- }
|
|
27
|
+
# trim leading blank lines
|
|
28
|
+
start = 1
|
|
29
|
+
while (start <= n && buf[start] ~ /^[[:space:]]*$/) { start++ }
|
|
30
|
+
for (i = start; i <= n; i++) { print buf[i] }
|
|
31
|
+
}
|
|
32
|
+
' "$CHANGELOG"
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Prepares a release on the current feature/fix branch, following this repo's
|
|
3
|
+
# established convention: bump package.json's version, plugin.xml's version
|
|
4
|
+
# attribute (Cordova requires the two to match), optionally the pinned
|
|
5
|
+
# native-SDK dependency (Android and/or iOS) if this release exists to pick
|
|
6
|
+
# up a native SDK change, prepend a Keep-a-Changelog-style CHANGELOG.md
|
|
7
|
+
# entry, and create the single combined commit release PRs have historically
|
|
8
|
+
# carried.
|
|
9
|
+
#
|
|
10
|
+
# This script does NOT tag, create the GitHub Release, or publish to npm —
|
|
11
|
+
# per repo convention, that happens automatically once the PR merges to main
|
|
12
|
+
# (see .github/workflows/release.yml). Run this on your feature branch before
|
|
13
|
+
# opening the PR.
|
|
14
|
+
#
|
|
15
|
+
# Usage:
|
|
16
|
+
# scripts/prepare_release.sh --bump <patch|minor|major> --category <category> \
|
|
17
|
+
# [--android-dep vX.Y.Z] [--ios-dep X.Y.Z] "<bullet 1>" ["<bullet 2>" ...]
|
|
18
|
+
# scripts/prepare_release.sh --version <X.Y.Z> --category <category> ...
|
|
19
|
+
#
|
|
20
|
+
# --category is a Keep a Changelog category: Added, Changed, Deprecated,
|
|
21
|
+
# Removed, Fixed, or Security (or any custom text).
|
|
22
|
+
# --android-dep only touches src/android/build.gradle's YMChatbot-Android
|
|
23
|
+
# pin; --ios-dep only touches plugin.xml's inline <pod name="YMChat"> spec.
|
|
24
|
+
# Omit whichever platform's native SDK didn't change for this release.
|
|
25
|
+
#
|
|
26
|
+
# Example:
|
|
27
|
+
# scripts/prepare_release.sh --bump patch --category Fixed --ios-dep 2.4.1 \
|
|
28
|
+
# "Upgraded native iOS SDK to pick up a WebView keyboard-resize fix."
|
|
29
|
+
|
|
30
|
+
set -euo pipefail
|
|
31
|
+
|
|
32
|
+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
33
|
+
cd "$REPO_ROOT"
|
|
34
|
+
|
|
35
|
+
PACKAGE_JSON="package.json"
|
|
36
|
+
PLUGIN_XML="plugin.xml"
|
|
37
|
+
ANDROID_GRADLE="src/android/build.gradle"
|
|
38
|
+
CHANGELOG="CHANGELOG.md"
|
|
39
|
+
INTEGRATION_BRANCH="main"
|
|
40
|
+
|
|
41
|
+
BUMP=""
|
|
42
|
+
NEW_VERSION=""
|
|
43
|
+
CATEGORY=""
|
|
44
|
+
ANDROID_DEP=""
|
|
45
|
+
IOS_DEP=""
|
|
46
|
+
BULLETS=()
|
|
47
|
+
|
|
48
|
+
while [[ $# -gt 0 ]]; do
|
|
49
|
+
case "$1" in
|
|
50
|
+
--bump) BUMP="$2"; shift 2 ;;
|
|
51
|
+
--version) NEW_VERSION="$2"; shift 2 ;;
|
|
52
|
+
--category) CATEGORY="$2"; shift 2 ;;
|
|
53
|
+
--android-dep) ANDROID_DEP="$2"; shift 2 ;;
|
|
54
|
+
--ios-dep) IOS_DEP="$2"; shift 2 ;;
|
|
55
|
+
-h|--help) grep '^#' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
56
|
+
*) BULLETS+=("$1"); shift ;;
|
|
57
|
+
esac
|
|
58
|
+
done
|
|
59
|
+
|
|
60
|
+
if [[ -z "$CATEGORY" || ${#BULLETS[@]} -eq 0 ]]; then
|
|
61
|
+
echo "error: --category and at least one changelog bullet are required" >&2
|
|
62
|
+
exit 1
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
if [[ -n "$BUMP" && -n "$NEW_VERSION" ]]; then
|
|
66
|
+
echo "error: pass either --bump or --version, not both" >&2
|
|
67
|
+
exit 1
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
|
|
71
|
+
if [[ "$BRANCH" == "$INTEGRATION_BRANCH" ]]; then
|
|
72
|
+
echo "error: run this on a feature/fix branch, not $INTEGRATION_BRANCH (matches repo convention: the bump+changelog commit lives on the PR branch)" >&2
|
|
73
|
+
exit 1
|
|
74
|
+
fi
|
|
75
|
+
|
|
76
|
+
if [[ -n "$(git status --porcelain)" ]]; then
|
|
77
|
+
echo "error: working tree is not clean; commit or stash your changes first" >&2
|
|
78
|
+
exit 1
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
CURRENT_VERSION="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$PACKAGE_JSON" | head -1)"
|
|
82
|
+
if [[ -z "$CURRENT_VERSION" ]]; then
|
|
83
|
+
echo "error: could not read current version from $PACKAGE_JSON" >&2
|
|
84
|
+
exit 1
|
|
85
|
+
fi
|
|
86
|
+
|
|
87
|
+
if [[ -n "$BUMP" ]]; then
|
|
88
|
+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
|
|
89
|
+
case "$BUMP" in
|
|
90
|
+
major) NEW_VERSION="$((MAJOR + 1)).0.0" ;;
|
|
91
|
+
minor) NEW_VERSION="${MAJOR}.$((MINOR + 1)).0" ;;
|
|
92
|
+
patch) NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))" ;;
|
|
93
|
+
*) echo "error: --bump must be patch, minor, or major" >&2; exit 1 ;;
|
|
94
|
+
esac
|
|
95
|
+
elif [[ -z "$NEW_VERSION" ]]; then
|
|
96
|
+
echo "error: pass --bump <patch|minor|major> or --version <X.Y.Z>" >&2
|
|
97
|
+
exit 1
|
|
98
|
+
fi
|
|
99
|
+
|
|
100
|
+
if [[ ! "$NEW_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
101
|
+
echo "error: version must look like X.Y.Z, got: $NEW_VERSION" >&2
|
|
102
|
+
exit 1
|
|
103
|
+
fi
|
|
104
|
+
|
|
105
|
+
TAG="v${NEW_VERSION}"
|
|
106
|
+
if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then
|
|
107
|
+
echo "error: tag $TAG already exists" >&2
|
|
108
|
+
exit 1
|
|
109
|
+
fi
|
|
110
|
+
|
|
111
|
+
echo "Bumping $CURRENT_VERSION -> $NEW_VERSION ($TAG)"
|
|
112
|
+
|
|
113
|
+
FILES_TO_COMMIT=("$PACKAGE_JSON" "$PLUGIN_XML" "$CHANGELOG")
|
|
114
|
+
|
|
115
|
+
# --- 1. Bump package.json version ---
|
|
116
|
+
sed -i.bak "s/\"version\": \"$CURRENT_VERSION\"/\"version\": \"$NEW_VERSION\"/" "$PACKAGE_JSON" && rm -f "$PACKAGE_JSON.bak"
|
|
117
|
+
if ! grep -q "\"version\": \"$NEW_VERSION\"" "$PACKAGE_JSON"; then
|
|
118
|
+
echo "error: failed to update version in $PACKAGE_JSON" >&2
|
|
119
|
+
exit 1
|
|
120
|
+
fi
|
|
121
|
+
|
|
122
|
+
# --- 2. Bump plugin.xml's version attribute (must match package.json) ---
|
|
123
|
+
sed -i.bak "s/<plugin id=\"cordova-plugin-ymchat\" version=\"$CURRENT_VERSION\"/<plugin id=\"cordova-plugin-ymchat\" version=\"$NEW_VERSION\"/" "$PLUGIN_XML" && rm -f "$PLUGIN_XML.bak"
|
|
124
|
+
if ! grep -q "<plugin id=\"cordova-plugin-ymchat\" version=\"$NEW_VERSION\"" "$PLUGIN_XML"; then
|
|
125
|
+
echo "error: failed to update the version attribute in $PLUGIN_XML" >&2
|
|
126
|
+
exit 1
|
|
127
|
+
fi
|
|
128
|
+
|
|
129
|
+
# --- 3. Optionally bump the pinned native-SDK dependencies ---
|
|
130
|
+
if [[ -n "$ANDROID_DEP" ]]; then
|
|
131
|
+
CURRENT_ANDROID_DEP="$(sed -n "s/.*YMChatbot-Android:\(v[^']*\)'.*/\1/p" "$ANDROID_GRADLE")"
|
|
132
|
+
sed -i.bak "s/YMChatbot-Android:$CURRENT_ANDROID_DEP'/YMChatbot-Android:$ANDROID_DEP'/" "$ANDROID_GRADLE" && rm -f "$ANDROID_GRADLE.bak"
|
|
133
|
+
if ! grep -q "YMChatbot-Android:$ANDROID_DEP'" "$ANDROID_GRADLE"; then
|
|
134
|
+
echo "error: failed to update the YMChatbot-Android pin in $ANDROID_GRADLE" >&2
|
|
135
|
+
exit 1
|
|
136
|
+
fi
|
|
137
|
+
FILES_TO_COMMIT+=("$ANDROID_GRADLE")
|
|
138
|
+
fi
|
|
139
|
+
|
|
140
|
+
if [[ -n "$IOS_DEP" ]]; then
|
|
141
|
+
CURRENT_IOS_DEP="$(sed -n 's/.*<pod name="YMChat" spec="~> \([^"]*\)".*/\1/p' "$PLUGIN_XML")"
|
|
142
|
+
sed -i.bak "s/<pod name=\"YMChat\" spec=\"~> $CURRENT_IOS_DEP\"/<pod name=\"YMChat\" spec=\"~> $IOS_DEP\"/" "$PLUGIN_XML" && rm -f "$PLUGIN_XML.bak"
|
|
143
|
+
if ! grep -q "<pod name=\"YMChat\" spec=\"~> $IOS_DEP\"" "$PLUGIN_XML"; then
|
|
144
|
+
echo "error: failed to update the YMChat pod pin in $PLUGIN_XML" >&2
|
|
145
|
+
exit 1
|
|
146
|
+
fi
|
|
147
|
+
fi
|
|
148
|
+
|
|
149
|
+
# --- 4. Prepend CHANGELOG entry (Keep a Changelog style: no date, no link) ---
|
|
150
|
+
ENTRY_FILE="$(mktemp)"
|
|
151
|
+
{
|
|
152
|
+
echo "## [${NEW_VERSION}]"
|
|
153
|
+
echo ""
|
|
154
|
+
echo "### ${CATEGORY}"
|
|
155
|
+
echo ""
|
|
156
|
+
for b in "${BULLETS[@]}"; do
|
|
157
|
+
echo "- ${b}"
|
|
158
|
+
done
|
|
159
|
+
echo ""
|
|
160
|
+
} > "$ENTRY_FILE"
|
|
161
|
+
|
|
162
|
+
# Insert right before the first existing entry (or at EOF if the changelog
|
|
163
|
+
# has none yet).
|
|
164
|
+
awk -v entryfile="$ENTRY_FILE" '
|
|
165
|
+
inserted { print; next }
|
|
166
|
+
/^## \[[0-9]/ {
|
|
167
|
+
while ((getline line < entryfile) > 0) print line
|
|
168
|
+
inserted = 1
|
|
169
|
+
print
|
|
170
|
+
next
|
|
171
|
+
}
|
|
172
|
+
{ print }
|
|
173
|
+
END {
|
|
174
|
+
if (!inserted) {
|
|
175
|
+
while ((getline line < entryfile) > 0) print line
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
' "$CHANGELOG" > "$CHANGELOG.new" && mv "$CHANGELOG.new" "$CHANGELOG"
|
|
179
|
+
rm -f "$ENTRY_FILE"
|
|
180
|
+
|
|
181
|
+
git add "${FILES_TO_COMMIT[@]}"
|
|
182
|
+
|
|
183
|
+
COMMIT_MSG="Bump version to ${NEW_VERSION}"
|
|
184
|
+
if [[ -n "$ANDROID_DEP" || -n "$IOS_DEP" ]]; then
|
|
185
|
+
COMMIT_MSG="Bump native SDK deps, update version to ${NEW_VERSION}"
|
|
186
|
+
fi
|
|
187
|
+
git commit -m "$COMMIT_MSG"
|
|
188
|
+
|
|
189
|
+
echo ""
|
|
190
|
+
echo "Done. Push this branch and open the PR as usual — merging to $INTEGRATION_BRANCH will"
|
|
191
|
+
echo "automatically tag ${TAG}, publish the GitHub Release, and publish to npm."
|