-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrelease.sh
105 lines (85 loc) · 2.71 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env bash
#
# SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# Stop at first error
set -e
if ! command -v gh > /dev/null; then
echo "Could not find the GitHub CLI, please install it from https://github.com/cli/cli"
exit 1
fi
# Use version from changelog
version=$(grep '^## \[' CHANGELOG.md|head -n1|cut -d'[' -f2|cut -d']' -f1);
# version=$1
# The target branch, defaults to the current branch
target=${2:-$(git branch --show-current)}
# The tag
tag=v$version
if ! [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+\.[0-9]+)?$ ]]; then
echo "Invalid version, please enter a valid semantic version"
exit 1
fi
if [[ $(git branch --show-current) != $target ]]; then
if ! git switch $target > /dev/null; then
echo "Target branch does not exist, please enter a valid branch name"
exit 1
fi
fi
echo "Releasing version $version on branch $target";
# Ask for confirmation
read -r -p "Are you sure? [y/N] " input
case $input in
[yY][eE][sS]|[yY])
echo "You say Yes"
;;
[nN][oO]|[nN])
echo "You say No"
exit 1
;;
*)
echo "Invalid input..."
exit 1
;;
esac
# Ask for confirmation
read -r -p "Create commit and tag? [y/N] " input
case $input in
[yY][eE][sS]|[yY])
echo "You say Yes"
# Bump version in info.xml
sed -i -E "s|^\t<version>.+</version>|\t<version>$version</version>|" appinfo/info.xml
# Add changed files to git
git add CHANGELOG.md
git add appinfo/info.xml
# Create commit
git commit --signoff --message $tag
# Create tag
git tag $tag
# Show the result
git log -1 -p
;;
*)
echo "You say No"
;;
esac
# Ask for confirmation
read -r -p "Push and draft releases? [y/N] " input
case $input in
[yY][eE][sS]|[yY])
echo "You say Yes"
# Push commit
git push git@github.com:nextcloud/user_migration.git
# Push tag
git push git@github.com:nextcloud/user_migration.git $tag
git push git@github.com:nextcloud-releases/user_migration.git $tag
# Draft GitHub releases
gh release create --repo nextcloud/user_migration --draft --generate-notes --target $target --title $tag --verify-tag $tag
gh release create --repo nextcloud-releases/user_migration --draft --generate-notes --title $tag --verify-tag $tag
;;
*)
echo "You say No"
;;
esac
echo "Check and publish the drafted release on https://github.com/nextcloud/user_migration/releases"
echo "Check and publish the drafted release on https://github.com/nextcloud-releases/user_migration/releases"