generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathrelease.sh
executable file
·56 lines (42 loc) · 1.8 KB
/
release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
set -euo pipefail
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <new-version> <minimum-obsidian-version>"
exit 1
fi
NEW_VERSION=$1
MINIMUM_OBSIDIAN_VERSION=$2
BRANCH_NAME="release/${NEW_VERSION}"
# Ensure no uncommitted changes
if [[ $(git status --porcelain) ]]; then
echo "Uncommitted changes detected. Please commit or stash them before running the release script."
exit 1
fi
echo "Preparing release ${NEW_VERSION} with minimum Obsidian version ${MINIMUM_OBSIDIAN_VERSION}"
# Create and switch to a new branch
git checkout -b "${BRANCH_NAME}"
# Update version in package.json
echo "Updating package.json..."
jq ".version = \"${NEW_VERSION}\"" package.json > package.json.tmp && mv package.json.tmp package.json
# Update version in manifest.json
echo "Updating manifest.json..."
jq ".version = \"${NEW_VERSION}\" | .minAppVersion = \"${MINIMUM_OBSIDIAN_VERSION}\"" manifest.json > manifest.json.tmp && mv manifest.json.tmp manifest.json
# Update versions.json
echo "Updating versions.json..."
jq ". += {\"${NEW_VERSION}\": \"${MINIMUM_OBSIDIAN_VERSION}\"}" versions.json > versions.json.tmp && mv versions.json.tmp versions.json
# Install dependencies to update package-lock.json
echo "Updating package-lock.json..."
npm install
# Commit changes
git add package.json package-lock.json manifest.json versions.json
git commit -m "Release ${NEW_VERSION}"
# Push branch to remote
git push --set-upstream origin "${BRANCH_NAME}"
# Create a pull request
echo "Creating a pull request..."
gh pr create \
--title "Release ${NEW_VERSION}" \
--body "This pull request updates the version to ${NEW_VERSION} and sets the minimum Obsidian version to ${MINIMUM_OBSIDIAN_VERSION}." \
--base master \
--head "${BRANCH_NAME}"
echo "Pull request created. Please review and merge it to trigger the release workflow."