File: release.zsh

package info (click to toggle)
zplug 2.4.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,068 kB
  • sloc: sh: 1,504; awk: 235; makefile: 26
file content (126 lines) | stat: -rw-r--r-- 2,657 bytes parent folder | download | duplicates (3)
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/zsh

set -e

printf "Now zplug version is $_ZPLUG_VERSION\n"
printf "Please let me know new version: "
read next_version
printf "OK? $next_version: [y/n] "
read ok
case "$ok" in
    "Y"|"y"|"YES"|"yes"|"OK"|"ok")
        # ok
        ;;
    *)
        echo "canceled" >&2
        exit 1
        ;;
esac

dir="$(git rev-parse --show-toplevel)"
source "$dir/base/base/base.zsh"

if ! __zplug::base::base::valid_semver "$_ZPLUG_VERSION" "$next_version"; then
    printf "$next_version: invalid semver\n"
    exit 1
fi

branch="$(git rev-parse --abbrev-ref HEAD)"
if [[ ! $branch =~ $next_version ]]; then
    echo "You are on $branch, but next version is $next_version" >&2
    exit 1
fi

if [[ -z $GITHUB_TOKEN ]]; then
    printf "GITHUB_TOKEN is missing\n" >&2
    exit 1
fi

if [[ -n "$(git status -s)" ]]; then
    git status -s
    printf "your $branch branch is not clean\n" >&2
    exit 1
fi

files=(
"$dir/base/core/core.zsh"
"$dir/README.md"
"$dir/doc/guide/ja/README.md"
)

# overwrite
echo "$next_version" >| "$dir/doc/VERSION"

# overwrite
for file in "$files[@]"
do
    cat "$file" | (rm "$file"; sed "s/$_ZPLUG_VERSION/$next_version/" > "$file")
done

# show diff
git diff

printf "Can I continue to process? [y/n] "
read ok
case "$ok" in
    "Y"|"y"|"YES"|"yes"|"OK"|"ok")
        # ok
        ;;
    *)
        echo "canceled" >&2
        exit 1
        ;;
esac

# git ops
set -x
git add -p
git commit -m "New version $next_version"
git push -u origin $branch
git checkout master
git merge --no-ff $branch
git push -u origin master
# maybe not necessary thanks to curl post proc
# git tag -a $next_version -m $next_version
# git push origin $next_version
set +x

body="Release of version '$next_version'"
printf "Do you enter releases message? [y/n] "
read ok
case "$ok" in
    "Y"|"y"|"YES"|"yes"|"OK"|"ok")
        while true
        do
            echo "Please let me know release message (kill to type ^D)"
            ok=
            message="$(cat)"
            printf "--- OK? --- [y/n] "
            read ok
            case "$ok" in
                [Yy]*)
                    break
                    ;;
                [Nn]*)
                    continue
                    ;;
                * ) echo "Please answer yes or no.";;
            esac
        done
        ;;
    *)
        # do nothing
        ;;
esac

curl --data \
    '{ \
    "tag_name": "'$next_version'", \
    "target_commitish": "master", \
    "name": "'$next_version'", \
    "body": "'$body'", \
    "draft": false, \
    "prerelease": false \
}' "https://api.github.com/repos/zplug/zplug/releases?access_token=$GITHUB_TOKEN"

printf "Completed.\n"