Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add version-bump.sh script #39

Merged
merged 1 commit into from
Jan 23, 2023
Merged
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
52 changes: 52 additions & 0 deletions scripts/version-bump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
#
# Name:: version-bump.sh
# Description:: Use this script to bump the version of the lw-scanner
# after a new release of the docker image
# Author:: Salim Afiune Maya (<[email protected]>)
#
set -eou pipefail

readonly project_name=lw-scanner-action
readonly org_name=lacework
readonly git_user="Lacework Inc."
readonly git_email="[email protected]"

if [[ "${1:-}" == "" ]]; then
echo "Unable to update version. Please provide the new version to update."
fi

_scanner_version=$1

# Update Dockerfile
sed -i '' 's/:.*$/:'${_scanner_version}'/' Dockerfile

# Configure Git if running in CI
if [ "${CI:-}" != "" ]; then
git config --global user.email $git_email
git config --global user.name $git_user
git config --global user.signingkey $GPG_SIGNING_KEY
fi

# Create a branch and commit changes
git checkout -B version-bump
git commit -sS -am "bump: lw-scanner to version ${_scanner_version}"
git push origin version-bump -f

# Open Pull Request
_body="/tmp/pr.json"
_pr="/tmp/pr.out"
cat <<EOF > $_body
{
"base": "main",
"head": "version-bump",
"title": "bump: lw-scanner to version ${_scanner_version}",
"body": "Automated update, merge if pipeline is green."
}
EOF
curl -XPOST -H "Authorization: token $GITHUB_TOKEN" --data "@$_body" \
https://api.github.com/repos/${org_name}/${project_name}/pulls > $_pr
_pr_url=$(jq .html_url $_pr)
log ""
log "It is time to for review!"
log " $_pr_url"