-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgenerate-weekly-changelog.sh
executable file
·102 lines (71 loc) · 3.48 KB
/
generate-weekly-changelog.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
#!/usr/bin/env bash
set -e
# Currently assumes you are running it from jenkinsci/jenkins
DRY_RUN=false
REMOTE=origin
JENKINS_IO_REPO=jenkins-infra/jenkins.io
CHANGELOG_GENERATOR_REPO=jenkinsci/core-changelog-generator
if [ ! -d "../jenkins.io" ]
then
cd ../
git config --global --add safe.directory $(pwd)
gh repo clone ${JENKINS_IO_REPO}
cd jenkins
fi
if [ ! -d "../core-changelog-generator" ]
then
cd ../
git config --global --add safe.directory $(pwd)
gh repo clone ${CHANGELOG_GENERATOR_REPO}
cd jenkins
fi
command -v gh > /dev/null || (echo "GitHub CLI needs to be installed" && exit 1)
ls -lash ../core-changelog-generator/
ls -lash ../core-changelog-generator/changelog-config.yml
echo "Working directory:"
pwd
export CONFIG_PATH=../core-changelog-generator/changelog-config.yml
rm -f /tmp/weekly.yaml
# shellcheck disable=SC2016
NEXT_JENKINS_VERSION=$(mvn -q \
-Dexec.executable=echo \
-Dexec.args='${project.version}' \
--non-recursive \
exec:exec | awk '{sub(/-SNAPSHOT/,""); print}')
echo "Next version is: ${NEXT_JENKINS_VERSION}"
WEEKLY_VERSION=$(echo "$NEXT_JENKINS_VERSION" | cut -d '.' -f 2)
MAJOR_VERSION=$(echo "$NEXT_JENKINS_VERSION" | cut -d '.' -f 1)
LAST_WEEKLY="${MAJOR_VERSION}.$((WEEKLY_VERSION-1))"
echo "Previous weekly is ${LAST_WEEKLY}"
../core-changelog-generator/generate-jenkins-changelog.rb jenkins-"${LAST_WEEKLY}"..master | sed '/TODO fixup changelog/d' | sed '/\(regression in TODO\)/d' | awk '{sub(/version: master/,"version: \047'"${NEXT_JENKINS_VERSION}"'\047"); print}' | tee /tmp/new-changelog-entry.yaml
cat << EOF > /tmp/weekly.yaml
# DO NOT EDIT THIS FILE DIRECTLY ON GITHUB IF YOU HAVE COMMIT ACCESS
# ALL CHANGES MUST GO THROUGH PULL REQUESTS
# MALFORMED FILE CONTENTS WILL BREAK THE SITE BUILD
EOF
pip3 install -r ../core-changelog-generator/requirements.txt
../core-changelog-generator/replace-changelog-entry.py "${NEXT_JENKINS_VERSION}" ../jenkins.io/content/_data/changelogs/weekly.yml /tmp/new-changelog-entry.yaml \
| sed -e '/DO NOT EDIT THIS FILE/d' -e '/ALL CHANGES MUST GO THROUGH PULL REQUESTS/d' -e '/MALFORMED FILE CONTENTS WILL BREAK THE SITE BUILD/d' >> /tmp/weekly.yaml
cat << EOF >> /tmp/weekly.yaml
# DO NOT EDIT THIS FILE DIRECTLY ON GITHUB IF YOU HAVE COMMIT ACCESS
# ALL CHANGES MUST GO THROUGH PULL REQUESTS
# MALFORMED FILE CONTENTS WILL BREAK THE SITE BUILD
EOF
cp /tmp/weekly.yaml ../jenkins.io/content/_data/changelogs/weekly.yml
if [ "${DRY_RUN}" != true ]
then
cd ../jenkins.io
git checkout -b automated-weekly-changelog/"${NEXT_JENKINS_VERSION}" || git checkout automated-weekly-changelog/"${NEXT_JENKINS_VERSION}"
if [ -z "$(git status --porcelain)" ]
then
echo "No changes, skipping pull request"
exit 0
else
git commit content/_data/changelogs/weekly.yml -m "Automated changelog for ${NEXT_JENKINS_VERSION}"
git remote set-url ${REMOTE} "https://nobody:${GITHUB_TOKEN}@github.com/${JENKINS_IO_REPO}.git"
git push -u ${REMOTE} automated-weekly-changelog/"${NEXT_JENKINS_VERSION}" --force
gh pr create -R ${JENKINS_IO_REPO} --title "Automated changelog for ${NEXT_JENKINS_VERSION}" --body "Created by [generate-changelog.rb](https://github.com/jenkinsci/core-changelog-generator/blob/master/generate-jenkins-changelog.rb)
Co-ordinated by [generate-weekly-changelog.sh](https://github.com/jenkinsci/core-changelog-generator/blob/master/generate-weekly-changelog.sh)
[Report an issue](https://github.com/jenkinsci/core-changelog-generator/issues)" || echo "PR creation failed"
fi
fi