chore(workflow): Adds release script using standard-version
This commit is contained in:
parent
5ef9dfecbf
commit
e11b765176
11
.versionrc
Normal file
11
.versionrc
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"bumpFiles": [
|
||||
{
|
||||
"filename": "pyproject.toml",
|
||||
"updater": "scripts/standard-version/pyproject-updater.js"
|
||||
}
|
||||
],
|
||||
"sign": true,
|
||||
"prerelease": true,
|
||||
"tag-prefix": ""
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
if [ -z "$(git status --porcelain)" ]; then
|
||||
# Working directory clean
|
||||
branch_name=$(git symbolic-ref -q HEAD)
|
||||
branch_name=${branch_name##refs/heads/}
|
||||
branch_name=${branch_name:-HEAD}
|
||||
|
||||
poetry version patch
|
||||
version=`sed 's/version = "\([0-9]*.[0-9]*.[0-9]*\)"/\1/p' -n <pyproject.toml`
|
||||
read -p "Create commit for version $version? " -n 1 -r
|
||||
echo # (optional) move to a new line
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
# do dangerous stuff
|
||||
echo "Creating a new patch"
|
||||
git add pyproject.toml
|
||||
git commit -m "Created version $version"
|
||||
git tag -a "$version" -m "patch.sh created version $version"
|
||||
git push --tags
|
||||
else
|
||||
echo "Surrendering, clean up by reverting pyproject.toml..."
|
||||
exit 2
|
||||
fi
|
||||
else
|
||||
echo "Can't create patch version, working tree unclean..."
|
||||
exit 1
|
||||
fi
|
30
scripts/release.sh
Normal file
30
scripts/release.sh
Normal file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
if [ -z "$(git status --porcelain)" ]; then
|
||||
branch_name=$(git symbolic-ref -q HEAD)
|
||||
branch_name=${branch_name##refs/heads/}
|
||||
branch_name=${branch_name:-HEAD}
|
||||
if [ $branch_name != "master" ]; then
|
||||
echo "The current branch is not master!"
|
||||
echo "I'd feel uncomfortable releasing from here..."
|
||||
exit 3
|
||||
fi
|
||||
# Working directory clean
|
||||
echo "Doing a dry run..."
|
||||
npx standard-version --dry-run
|
||||
read -p "Does that look good? [y/N] " -n 1 -r
|
||||
echo # (optional) move to a new line
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
# do dangerous stuff
|
||||
npx standard-version
|
||||
git push --follow-tags origin master
|
||||
else
|
||||
echo "okay, never mind then..."
|
||||
exit 2
|
||||
fi
|
||||
else
|
||||
echo "Can't create release, working tree unclean..."
|
||||
exit 1
|
||||
fi
|
11
scripts/standard-version/pyproject-updater.js
Normal file
11
scripts/standard-version/pyproject-updater.js
Normal file
@ -0,0 +1,11 @@
|
||||
const pattern = /(\[tool\.poetry\]\nname = "pdme"\nversion = ")(?<vers>\d+\.\d+\.\d)(")/mg;
|
||||
|
||||
module.exports.readVersion = function (contents) {
|
||||
const result = pattern.exec(contents);
|
||||
return result.groups.vers;
|
||||
}
|
||||
|
||||
module.exports.writeVersion = function (contents, version) {
|
||||
const newContents = contents.replace(pattern, `$1${version}$3`);
|
||||
return newContents;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user