Skip to content

Commit

Permalink
INF-210 Finishing changes (#3617)
Browse files Browse the repository at this point in the history
* better help message

* ensure exit's are respected
  • Loading branch information
joaquincasares authored Aug 3, 2022
1 parent 9b5f4c9 commit e164665
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 43 deletions.
3 changes: 3 additions & 0 deletions .circleci/triggers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def standardize_branch(branches):

def ensure_tag_on_master(tag):
"""Ensure tag has been merged before proceeding"""
if tag == "master":
print("Commit cannot be 'master'.")
exit(1)
try:
branches = run_cmd(
f"git branch -a --contains {tag}", exit_on_error=False
Expand Down
2 changes: 1 addition & 1 deletion .circleci/triggers/deploy-sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@click.option(
"-u",
"--slack-mentions-user",
help="Used for CircleCI @mentions",
help="Used when $CIRCLE_SLACK_MENTIONS_USER is not set, for CircleCI @mentions",
envvar="CIRCLE_SLACK_MENTIONS_USER",
required=True,
)
Expand Down
89 changes: 47 additions & 42 deletions libs/scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,50 +36,55 @@ ${CHANGE_LOG}"
# Make a new branch off GIT_TAG, bumps npm,
# commits with the relevant changelog, and pushes
function bump-npm () {
# Configure git client
git config --global user.email "audius-infra@audius.co"
git config --global user.name "audius-infra"

# Make sure master is up to date
git checkout master -f
git pull

# only allow tags/commits found on master, release branches, or tags to be deployed
git branch -a --contains ${GIT_TAG} \
| tee /dev/tty \
| grep -Eq 'remotes/origin/master|remotes/origin/release' \
|| (
echo "tag not found on master nor release branches"
exit 1
)

# Ensure working directory clean
git reset --hard ${GIT_TAG}

# grab change log early, before the version bump
LAST_RELEASED_SHA=$(jq -r '.audius.releaseSHA' package.json)
CHANGE_LOG=$(git-changelog ${LAST_RELEASED_SHA})

# Patch the version
VERSION=$(npm version patch)
tmp=$(mktemp)
jq ". += {audius: {releaseSHA: \"${GIT_TAG}\"}}" package.json > "$tmp" \
&& mv "$tmp" package.json

# Build project
npm i
npm run build

# Publishing dry run, prior to pushing a branch
npm publish . --access public --dry-run
(
# Configure git client
git config --global user.email "audius-infra@audius.co"
git config --global user.name "audius-infra"

# Commit to a new branch
git checkout -b ${STUB}-${VERSION}
git add .
git commit -m "$(commit-message)"
# Make sure master is up to date
git checkout master -f
git pull

# Push branch to remote
git push -u origin ${STUB}-${VERSION}
if [[ "${GIT_TAG}" == "master" ]]; then
echo "Commit cannot be 'master'."
exit 1
fi

# only allow tags/commits found on master, release branches, or tags to be deployed
git branch -a --contains ${GIT_TAG} \
| tee /dev/tty \
| grep -Eq 'remotes/origin/master|remotes/origin/release' \
|| echo "tag not found on master nor release branches" \
&& exit 1

# Ensure working directory clean
git reset --hard ${GIT_TAG}

# grab change log early, before the version bump
LAST_RELEASED_SHA=$(jq -r '.audius.releaseSHA' package.json)
CHANGE_LOG=$(git-changelog ${LAST_RELEASED_SHA})

# Patch the version
VERSION=$(npm version patch)
tmp=$(mktemp)
jq ". += {audius: {releaseSHA: \"${GIT_TAG}\"}}" package.json > "$tmp" \
&& mv "$tmp" package.json

# Build project
npm i
npm run build

# Publishing dry run, prior to pushing a branch
npm publish . --access public --dry-run

# Commit to a new branch
git checkout -b ${STUB}-${VERSION}
git add .
git commit -m "$(commit-message)"

# Push branch to remote
git push -u origin ${STUB}-${VERSION}
)
}

# Merge the created branch into master, then delete the branch
Expand Down

0 comments on commit e164665

Please sign in to comment.