Skip to content
This repository was archived by the owner on May 13, 2020. It is now read-only.

Commit d6888f0

Browse files
committed
Fix broken automated release process
1 large issue: Pushing back to GitHub using the supplied GITHUB_TOKEN does not trigger additonal events. What does this mean? When we push back a release tag like `0.1.0`, the next workflow doesn't trigger. To address, you have to use a personal access token to trigger. This commit makes that change. Additionally, this commit improves error messages from release scripts by having the error messages actually displayed instead of an generic unbound variable error message.
1 parent d8d7b72 commit d6888f0

File tree

7 files changed

+50
-48
lines changed

7 files changed

+50
-48
lines changed

.ci-scripts/release/announce-a-release.bash

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# - jq
1616

1717
set -o errexit
18-
set -o nounset
1918

2019
# Pull in shared configuration specific to this repo
2120
base=$(dirname "$0")
@@ -62,6 +61,10 @@ if [[ -z "${ZULIP_TOKEN}" ]]; then
6261
exit 1
6362
fi
6463
64+
# no unset variables allowed from here on out
65+
# allow above so we can display nice error messages for expected unset variables
66+
set -o nounset
67+
6568
# Set up .netrc file with GitHub credentials
6669
cat <<- EOF > $HOME/.netrc
6770
machine github.com

.ci-scripts/release/build-docker-images-on-release.bash

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# - docker
1414

1515
set -o errexit
16-
set -o nounset
1716

1817
# Pull in shared configuration specific to this repo
1918
base=$(dirname "$0")
@@ -41,6 +40,10 @@ if [[ -z "${GITHUB_REPOSITORY}" ]]; then
4140
exit 1
4241
fi
4342

43+
# no unset variables allowed from here on out
44+
# allow above so we can display nice error messages for expected unset variables
45+
set -o nounset
46+
4447
# We aren't validating TAG is in our x.y.z format but we could.
4548
# For now, TAG validating is left up to the configuration in
4649
# our GitHub workflow

.ci-scripts/release/start-a-release.bash

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
# - git
1919

2020
set -o errexit
21-
set -o nounset
2221

2322
# Pull in shared configuration specific to this repo
2423
base=$(dirname "$0")
@@ -28,13 +27,16 @@ source "${base}/config.bash"
2827
# We validate all that need to be set in case, in an absolute emergency,
2928
# we need to run this by hand. Otherwise the GitHub actions environment should
3029
# provide all of these if properly configured
31-
if [[ -z "${GITHUB_ACTOR}" ]]; then
32-
echo -e "\e[31mName of the user to make changes to repo as need to be set in GITHUB_ACTOR. Exiting."
33-
exit 1
34-
fi
35-
36-
if [[ -z "${GITHUB_TOKEN}" ]]; then
37-
echo -e "\e[31mA personal access token needs to be set in GITHUB_TOKEN. Exiting."
30+
if [[ -z "${RELEASE_TOKEN}" ]]; then
31+
echo -e "\e[31mA personal access token needs to be set in RELEASE_TOKEN."
32+
echo -e "\e[31mIt should not be secrets.GITHUB_TOKEN. It has to be a"
33+
echo -e "\e[31mpersonal access token otherwise next steps in the release"
34+
echo -e "\e[31mprocess WILL NOT trigger."
35+
echo -e "\e[31mPersonal access tokens are in the form:"
36+
echo -e "\e[31m USERNAME:TOKEN"
37+
echo -e "\e[31mfor example:"
38+
echo -e "\e[31m ponylang-main:1234567890"
39+
echo -e "\e[31mExiting."
3840
exit 1
3941
fi
4042

@@ -55,22 +57,17 @@ if [[ -z "${GITHUB_REPOSITORY}" ]]; then
5557
exit 1
5658
fi
5759

58-
# Set up .netrc file with GitHub credentials
59-
cat <<- EOF > $HOME/.netrc
60-
machine github.com
61-
login $GITHUB_ACTOR
62-
password $GITHUB_TOKEN
63-
machine api.github.com
64-
login $GITHUB_ACTOR
65-
password $GITHUB_TOKEN
66-
EOF
67-
68-
chmod 600 $HOME/.netrc
60+
# no unset variables allowed from here on out
61+
# allow above so we can display nice error messages for expected unset variables
62+
set -o nounset
6963

64+
# Set up .netrc file with GitHub credentials
7065
git config --global user.name 'Ponylang Main Bot'
7166
git config --global user.email '[email protected]'
7267
git config --global push.default simple
7368

69+
PUSH_TO="https://${ACCESS_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
70+
7471
# Extract version from tag reference
7572
# Tag ref version: "refs/tags/release-1.0.0"
7673
# Version: "1.0.0"
@@ -101,9 +98,9 @@ git tag "${VERSION}"
10198

10299
# push to release to remote
103100
echo -e "\e[34mPushing commited changes back to master"
104-
git push origin master
101+
git push ${PUSH_TO} master
105102
echo -e "\e[34mPushing ${VERSION} tag"
106-
git push origin "${VERSION}"
103+
git push ${PUSH_TO} "${VERSION}"
107104

108105
# pull again, just in case, odds of this being needed are really slim
109106
git pull
@@ -118,8 +115,8 @@ git add CHANGELOG.md
118115
git commit -m "Add unreleased section to CHANGELOG post ${VERSION} release [skip ci]"
119116

120117
echo -e "\e[34mPushing CHANGELOG.md"
121-
git push origin master
118+
git push ${PUSH_TO} master
122119

123120
# delete release-VERSION tag
124121
echo -e "\e[34mDeleting no longer needed remote tag release-${VERSION}"
125-
git push --delete origin "release-${VERSION}"
122+
git push --delete ${PUSH_TO} "release-${VERSION}"

.ci-scripts/release/trigger-release-announcement.bash

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# - git
1616

1717
set -o errexit
18-
set -o nounset
1918

2019
# Pull in shared configuration specific to this repo
2120
base=$(dirname "$0")
@@ -25,13 +24,16 @@ source "${base}/config.bash"
2524
# We validate all that need to be set in case, in an absolute emergency,
2625
# we need to run this by hand. Otherwise the GitHub actions environment should
2726
# provide all of these if properly configured
28-
if [[ -z "${GITHUB_ACTOR}" ]]; then
29-
echo -e "\e[31mName of the user to make changes to repo as need to be set in GITHUB_ACTOR. Exiting."
30-
exit 1
31-
fi
32-
33-
if [[ -z "${GITHUB_TOKEN}" ]]; then
34-
echo -e "\e[31mA personal access token needs to be set in GITHUB_TOKEN. Exiting."
27+
if [[ -z "${RELEASE_TOKEN}" ]]; then
28+
echo -e "\e[31mA personal access token needs to be set in RELEASE_TOKEN."
29+
echo -e "\e[31mIt should not be secrets.GITHUB_TOKEN. It has to be a"
30+
echo -e "\e[31mpersonal access token otherwise next steps in the release"
31+
echo -e "\e[31mprocess WILL NOT trigger."
32+
echo -e "\e[31mPersonal access tokens are in the form:"
33+
echo -e "\e[31m USERNAME:TOKEN"
34+
echo -e "\e[31mfor example:"
35+
echo -e "\e[31m ponylang-main:1234567890"
36+
echo -e "\e[31mExiting."
3537
exit 1
3638
fi
3739

@@ -44,22 +46,16 @@ if [[ -z "${GITHUB_REF}" ]]; then
4446
exit 1
4547
fi
4648

47-
# Set up .netrc file with GitHub credentials
48-
cat <<- EOF > $HOME/.netrc
49-
machine github.com
50-
login $GITHUB_ACTOR
51-
password $GITHUB_TOKEN
52-
machine api.github.com
53-
login $GITHUB_ACTOR
54-
password $GITHUB_TOKEN
55-
EOF
56-
57-
chmod 600 $HOME/.netrc
49+
# no unset variables allowed from here on out
50+
# allow above so we can display nice error messages for expected unset variables
51+
set -o nounset
5852

5953
git config --global user.name 'Ponylang Main Bot'
6054
git config --global user.email '[email protected]'
6155
git config --global push.default simple
6256

57+
PUSH_TO="https://${ACCESS_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
58+
6359
# Extract version from tag reference
6460
# Tag ref version: "refs/tags/1.0.0"
6561
# Version: "1.0.0"
@@ -71,4 +67,4 @@ git tag "announce-${VERSION}"
7167

7268
# push tag
7369
echo -e "\e[34mPushing announce-${VERSION} tag"
74-
git push origin "announce-${VERSION}"
70+
git push ${PUSH_TO} "announce-${VERSION}"

.ci-scripts/release/x86-64-unknown-linux.bash

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# - GNU tar
1616

1717
set -o errexit
18-
set -o nounset
1918

2019
# Pull in shared configuration specific to this repo
2120
base=$(dirname "$0")
@@ -60,6 +59,10 @@ if [[ -z "${CLOUDSMITH_REPO}" ]]; then
6059
exit 1
6160
fi
6261

62+
# no unset variables allowed from here on out
63+
# allow above so we can display nice error messages for expected unset variables
64+
set -o nounset
65+
6366
TODAY=$(date +%Y%m%d)
6467

6568
# Compiler target parameters

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ jobs:
4242
- name: Trigger release announcement
4343
run: bash .ci-scripts/release/trigger-release-announcement.bash
4444
env:
45-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}

.github/workflows/start-a-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ jobs:
1515
- name: Start release process
1616
run: bash .ci-scripts/release/start-a-release.bash
1717
env:
18-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}

0 commit comments

Comments
 (0)