-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathentrypoint.sh
executable file
·95 lines (74 loc) · 2.09 KB
/
entrypoint.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
#!/bin/bash
cd "${GITHUB_WORKSPACE}" \
|| (echo "Workspace is unavailable" >&2; exit 1)
. /usr/ros/${ROS_DISTRO}/setup.bash
set -eu
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
if [ ! -z "${INPUT_ISSUE_TITLE:-}" ]
then
if [ ! -z "${INPUT_VERSION:-}" ]
then
echo "Both issue_title and version are specified" >&2
exit 1
fi
INPUT_VERSION=$(echo ${INPUT_ISSUE_TITLE} | sed -e 's/^Release \(.*\)$/\1/')
fi
function cleanup() {
# Detach head to work with repo-sync/pull-request
git checkout refs/heads/${BRANCH_NAME}
git branch -D release-${INPUT_VERSION} || true
}
# Check duplication
if git ls-remote --exit-code origin ${INPUT_VERSION}
then
echo "Release already exists. Nothing to do." >&2
cleanup
exit 0
fi
update=false
if git ls-remote --exit-code origin release-${INPUT_VERSION}
then
echo "Release candidate branch already exists. Updating." >&2
update=true
fi
echo "created_branch=release-${INPUT_VERSION}" >> ${GITHUB_OUTPUT}
echo "version=${INPUT_VERSION}" >> ${GITHUB_OUTPUT}
# Setup
echo -e "machine github.com\nlogin ${INPUT_GITHUB_TOKEN}" > ~/.netrc
git config user.name "${INPUT_GIT_USER}"
git config user.email "${INPUT_GIT_EMAIL}"
# Fetch all history to generate changelog
git fetch --tags --prune --unshallow
# Update CHANGELOG
catkin_generate_changelog -y
if ${update}
then
# Store updated CHANGELOGs
git stash
# Update release candidate branch
git checkout release-${INPUT_VERSION}
if git merge --no-edit ${BRANCH_NAME} | (grep "Already up to date.")
then
echo "Release already updated. Nothing to do." >&2
cleanup
exit 0
fi
# Overwrite CHANGELOGs
git checkout stash@{0} $(find . -name CHANGELOG.rst)
else
git checkout -b release-${INPUT_VERSION}
fi
# Fix RST format
sed '/^Forthcoming/,/^[0-9]\+\.[0-9]\+\.[0-9]\+/{/^ /d}' \
-i $(find . -name CHANGELOG.rst)
git add $(find . -name CHANGELOG.rst)
git commit -m "Update changelog"
# Bump version
catkin_prepare_release -y --no-push --version ${INPUT_VERSION}
git tag -d ${INPUT_VERSION}
# Show
git log ${BRANCH_NAME}..HEAD
# Push
git push origin release-${INPUT_VERSION}
# Clean-up
cleanup