1
1
mirror of https://github.com/orhun/git-cliff.git synced 2024-12-12 16:25:30 +03:00
git-cliff/release.sh
Orhun Parmaksız b7dd592653
chore(npm): package git-cliff for npm (#133)
* chore: scaffold a typescript node project

* feat: execute git cliff binary using nodejs

* fix: process doesnt return status code

* fix: optional dependencies are not added to git-cliff

* chore(npm): move NPM package to npm folder

* chore(docker): add NPM package to .dockerignore

* feat(cd): publish NPM package via continuous deployment workflow

* docs: add npm instructions to README

* chore(npm): update package keywords

* chore(cd): publish the NPM package publicly

* style(readme): update NPM section in README.md

Co-authored-by: Burak Güner <burak.guner@callstack.com>
Co-authored-by: Burak Güner <md.burak.guner@gmail.com>
2023-01-09 15:12:22 +01:00

39 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
if [ -z "$1" ]; then
echo "Please provide a tag."
echo "Usage: ./release.sh v[X.Y.Z]"
exit
fi
echo "Preparing $1..."
# update the version
msg="# managed by release.sh"
sed -E -i "s/^version = .* $msg$/version = \"${1#v}\" $msg/" git-cliff*/Cargo.toml
sed -E -i "s/\"version\": \".+\"/\"version\": \"${1#v}\"/" npm/git-cliff/package.json
sed -E -i "s/\"(git-cliff-.+)\": \".+\"/\"\1\": \"${1#v}\"/g" npm/git-cliff/package.json
# update the changelog
sed -E -i "s/\s+\#\s(.*)\s\#\sreplace issue numbers/\\t\1/g" config/cliff.toml
cargo run -- --tag "$1" >CHANGELOG.md
git restore config/cliff.toml
git add -A && git commit -m "chore(release): prepare for $1"
git show
# generate a changelog for the tag message
export GIT_CLIFF_TEMPLATE="\
{% for group, commits in commits | group_by(attribute=\"group\") %}
{{ group | upper_first }}\
{% for commit in commits %}
- {% if commit.breaking %}(breaking) {% endif %}{{ commit.message | upper_first }} ({{ commit.id | truncate(length=7, end=\"\") }})\
{% endfor %}
{% endfor %}"
changelog=$(cargo run -- --config examples/detailed.toml --unreleased --strip all)
# create a signed tag
# https://keyserver.ubuntu.com/pks/lookup?search=0x4A92FA17B6619297&op=vindex
git -c user.name="git-cliff" \
-c user.email="git-cliff@protonmail.com" \
-c user.signingkey="1D2D410A741137EBC544826F4A92FA17B6619297" \
tag -s -a "$1" -m "Release $1" -m "$changelog"
git tag -v "$1"
echo "Done!"
echo "Now push the commit (git push) and the tag (git push --tags)."