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

Fix broken automated release process #126

Merged
merged 1 commit into from
Nov 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .ci-scripts/release/announce-a-release.bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# - jq

set -o errexit
set -o nounset

# Pull in shared configuration specific to this repo
base=$(dirname "$0")
Expand Down Expand Up @@ -62,6 +61,10 @@ if [[ -z "${ZULIP_TOKEN}" ]]; then
exit 1
fi

# 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
cat <<- EOF > $HOME/.netrc
machine github.com
Expand Down
5 changes: 4 additions & 1 deletion .ci-scripts/release/build-docker-images-on-release.bash
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# - docker

set -o errexit
set -o nounset

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

# no unset variables allowed from here on out
# allow above so we can display nice error messages for expected unset variables
set -o nounset

# We aren't validating TAG is in our x.y.z format but we could.
# For now, TAG validating is left up to the configuration in
# our GitHub workflow
Expand Down
43 changes: 20 additions & 23 deletions .ci-scripts/release/start-a-release.bash
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# - git

set -o errexit
set -o nounset

# Pull in shared configuration specific to this repo
base=$(dirname "$0")
Expand All @@ -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"
Copy link
Contributor

@Theodus Theodus Nov 9, 2019

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Definitely yes.

Copy link
Member Author

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.

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

Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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}"
36 changes: 16 additions & 20 deletions .ci-scripts/release/trigger-release-announcement.bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# - git

set -o errexit
set -o nounset

# Pull in shared configuration specific to this repo
base=$(dirname "$0")
Expand All @@ -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"
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

Expand All @@ -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"
Expand All @@ -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}"
5 changes: 4 additions & 1 deletion .ci-scripts/release/x86-64-unknown-linux.bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# - GNU tar

set -o errexit
set -o nounset

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

# no unset variables allowed from here on out
# allow above so we can display nice error messages for expected unset variables
set -o nounset

TODAY=$(date +%Y%m%d)

# Compiler target parameters
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ jobs:
- name: Trigger release announcement
run: bash .ci-scripts/release/trigger-release-announcement.bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/start-a-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
- name: Start release process
run: bash .ci-scripts/release/start-a-release.bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}