This repository was archived by the owner on May 13, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 18
Fix broken automated release process #126
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ | |
# - git | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
# Pull in shared configuration specific to this repo | ||
base=$(dirname "$0") | ||
|
@@ -28,13 +27,16 @@ source "${base}/config.bash" | |
# We validate all that need to be set in case, in an absolute emergency, | ||
# we need to run this by hand. Otherwise the GitHub actions environment should | ||
# provide all of these if properly configured | ||
if [[ -z "${GITHUB_ACTOR}" ]]; then | ||
echo -e "\e[31mName of the user to make changes to repo as need to be set in GITHUB_ACTOR. Exiting." | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "${GITHUB_TOKEN}" ]]; then | ||
echo -e "\e[31mA personal access token needs to be set in GITHUB_TOKEN. Exiting." | ||
if [[ -z "${RELEASE_TOKEN}" ]]; then | ||
echo -e "\e[31mA personal access token needs to be set in RELEASE_TOKEN." | ||
echo -e "\e[31mIt should not be secrets.GITHUB_TOKEN. It has to be a" | ||
echo -e "\e[31mpersonal access token otherwise next steps in the release" | ||
echo -e "\e[31mprocess WILL NOT trigger." | ||
echo -e "\e[31mPersonal access tokens are in the form:" | ||
echo -e "\e[31m USERNAME:TOKEN" | ||
echo -e "\e[31mfor example:" | ||
echo -e "\e[31m ponylang-main:1234567890" | ||
echo -e "\e[31mExiting." | ||
exit 1 | ||
fi | ||
|
||
|
@@ -55,22 +57,17 @@ if [[ -z "${GITHUB_REPOSITORY}" ]]; then | |
exit 1 | ||
fi | ||
|
||
# Set up .netrc file with GitHub credentials | ||
cat <<- EOF > $HOME/.netrc | ||
machine github.com | ||
login $GITHUB_ACTOR | ||
password $GITHUB_TOKEN | ||
machine api.github.com | ||
login $GITHUB_ACTOR | ||
password $GITHUB_TOKEN | ||
EOF | ||
|
||
chmod 600 $HOME/.netrc | ||
# no unset variables allowed from here on out | ||
# allow above so we can display nice error messages for expected unset variables | ||
set -o nounset | ||
|
||
# Set up .netrc file with GitHub credentials | ||
git config --global user.name 'Ponylang Main Bot' | ||
git config --global user.email '[email protected]' | ||
git config --global push.default simple | ||
|
||
PUSH_TO="https://${ACCESS_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | ||
|
||
# Extract version from tag reference | ||
# Tag ref version: "refs/tags/release-1.0.0" | ||
# Version: "1.0.0" | ||
|
@@ -101,9 +98,9 @@ git tag "${VERSION}" | |
|
||
# push to release to remote | ||
echo -e "\e[34mPushing commited changes back to master" | ||
git push origin master | ||
git push ${PUSH_TO} master | ||
echo -e "\e[34mPushing ${VERSION} tag" | ||
git push origin "${VERSION}" | ||
git push ${PUSH_TO} "${VERSION}" | ||
|
||
# pull again, just in case, odds of this being needed are really slim | ||
git pull | ||
|
@@ -118,8 +115,8 @@ git add CHANGELOG.md | |
git commit -m "Add unreleased section to CHANGELOG post ${VERSION} release [skip ci]" | ||
|
||
echo -e "\e[34mPushing CHANGELOG.md" | ||
git push origin master | ||
git push ${PUSH_TO} master | ||
|
||
# delete release-VERSION tag | ||
echo -e "\e[34mDeleting no longer needed remote tag release-${VERSION}" | ||
git push --delete origin "release-${VERSION}" | ||
git push --delete ${PUSH_TO} "release-${VERSION}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ | |
# - git | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
# Pull in shared configuration specific to this repo | ||
base=$(dirname "$0") | ||
|
@@ -25,13 +24,16 @@ source "${base}/config.bash" | |
# We validate all that need to be set in case, in an absolute emergency, | ||
# we need to run this by hand. Otherwise the GitHub actions environment should | ||
# provide all of these if properly configured | ||
if [[ -z "${GITHUB_ACTOR}" ]]; then | ||
echo -e "\e[31mName of the user to make changes to repo as need to be set in GITHUB_ACTOR. Exiting." | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "${GITHUB_TOKEN}" ]]; then | ||
echo -e "\e[31mA personal access token needs to be set in GITHUB_TOKEN. Exiting." | ||
if [[ -z "${RELEASE_TOKEN}" ]]; then | ||
echo -e "\e[31mA personal access token needs to be set in RELEASE_TOKEN." | ||
echo -e "\e[31mIt should not be secrets.GITHUB_TOKEN. It has to be a" | ||
SeanTAllen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo -e "\e[31mpersonal access token otherwise next steps in the release" | ||
echo -e "\e[31mprocess WILL NOT trigger." | ||
echo -e "\e[31mPersonal access tokens are in the form:" | ||
echo -e "\e[31m USERNAME:TOKEN" | ||
echo -e "\e[31mfor example:" | ||
echo -e "\e[31m ponylang-main:1234567890" | ||
echo -e "\e[31mExiting." | ||
exit 1 | ||
fi | ||
|
||
|
@@ -44,22 +46,16 @@ if [[ -z "${GITHUB_REF}" ]]; then | |
exit 1 | ||
fi | ||
|
||
# Set up .netrc file with GitHub credentials | ||
cat <<- EOF > $HOME/.netrc | ||
machine github.com | ||
login $GITHUB_ACTOR | ||
password $GITHUB_TOKEN | ||
machine api.github.com | ||
login $GITHUB_ACTOR | ||
password $GITHUB_TOKEN | ||
EOF | ||
|
||
chmod 600 $HOME/.netrc | ||
# no unset variables allowed from here on out | ||
# allow above so we can display nice error messages for expected unset variables | ||
set -o nounset | ||
|
||
git config --global user.name 'Ponylang Main Bot' | ||
git config --global user.email '[email protected]' | ||
git config --global push.default simple | ||
|
||
PUSH_TO="https://${ACCESS_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | ||
|
||
# Extract version from tag reference | ||
# Tag ref version: "refs/tags/1.0.0" | ||
# Version: "1.0.0" | ||
|
@@ -71,4 +67,4 @@ git tag "announce-${VERSION}" | |
|
||
# push tag | ||
echo -e "\e[34mPushing announce-${VERSION} tag" | ||
git push origin "announce-${VERSION}" | ||
git push ${PUSH_TO} "announce-${VERSION}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this "It should not be secrets.GITHUB_TOKEN." be here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Definitely yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default assumption of someone who knows GH actions would be to use secrets.GITHUB_TOKEN. That is what I was doing. It won't work if you do.