-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease
More file actions
executable file
·51 lines (46 loc) · 1.71 KB
/
release
File metadata and controls
executable file
·51 lines (46 loc) · 1.71 KB
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
#!/usr/bin/env bash
set -TCEeuo pipefail # Strict Bash
# The release script of this repo
# It's mandatory because the tag version is in the .pre-commit-config.yaml tag file
# so we need to update it
bump_type=${1:-"patch"} # or minor, major
# Get the tags locally
git pull
# calculate the next version
export GIT_CLIFF__BUMP__INITIAL_TAG=v0.1.0 # by default it's 0.1.0
next_version=$(git cliff --unreleased --bump "$bump_type" --context --tag-pattern "v[0-9]+\\.[0-9]+\\.[0-9]+" | jq -r '.[0].version' | tr -d "v")
echo "New version: $next_version"
# Update in-place the version
# We patch to keep style formatting
echo "Updating copier.yml project version"
ORIGIN_NORMALIZED_COPIER=/tmp/copier-origin.yml
NEW_NORMALIZED_COPIER=/tmp/copier-new.yml
PATCH_COPIER=/tmp/copier-patch.yml.diff
rm /tmp/copier-*
if ! yq --exit-status . copier.yml > "$ORIGIN_NORMALIZED_COPIER"; then
echo " * Normalization failed"
exit 1
fi
if ! yq --exit-status "(.devfiles_version.default) = \"v$next_version\"" copier.yml > "$NEW_NORMALIZED_COPIER"; then
echo " * Updated Normalization failed"
exit 1
fi
# Exit code is 1 oif there is a diff
if diff "$ORIGIN_NORMALIZED_COPIER" "$NEW_NORMALIZED_COPIER" > "$PATCH_COPIER"; then
echo " * No Diff found"
# we don't exit as it may be the recreation of a release
fi
patch copier.yml "$PATCH_COPIER"
if ! grep -q "default: \"v$next_version\"" copier.yml; then
echo "Update failed"
exit 1
fi
# Commit
git-commit "chore: release $next_version"
echo "Releasing to the version $next_version"
# release
JRELEASER_PROJECT_VERSION="$next_version" jreleaser release
# Tag is created locally and remotely (force pull)
# git refuse otherwise with `tag would clobber existing tag`
git pull --force
echo "Release done"