Skip to content

Commit

Permalink
Show a version of the aws-creds
Browse files Browse the repository at this point in the history
`aws-creds —version` will show the script's actual version. The version
is updated as follows:
1. for the development versions, a version is `{last tag}+{date}`;
2. a version is `{release tag}` for the release versions.

The version update is managed by the Elegan Git workflows.

#7
  • Loading branch information
extsoft committed Jun 25, 2024
1 parent e9646d3 commit 92b8903
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .workflows/release-work-after
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ COMMIT=$(git log --pretty=%H -1)

if type brew >/dev/null 2>&1; then
echo "Updating Homebrew formulae..."
brew bump-formula-pr --no-audit --tag=${TAG} --revision=${COMMIT} aws-creds
brew bump-formula-pr --no-audit --tag="${TAG}" --revision="${COMMIT}" aws-creds
else
echo "'brew' binary is not available."
echo "Please make a manual formulae update."
Expand All @@ -22,6 +22,7 @@ Instructions:
MESSAGE
fi
# add GitHub release
# shellcheck disable=SC2046 # Quote this to prevent word splitt...
git-elegant show-release-notes smart $(git tag | tail -2 | head -1) $(git tag | tail -1) | pbcopy
echo "Release notes are in the clipboard."
sleep 2
Expand Down
28 changes: 28 additions & 0 deletions .workflows/release-work-ahead
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -o errexit
set -o pipefail
cd "$(git rev-parse --show-toplevel)"
# prepare
git checkout main
git pull --tags
# deside on version
# shellcheck disable=SC2046 # Quote this to prevent word splitt...
latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "Commit history since the '${latest_tag}' tag:"
git log "${latest_tag}"..HEAD --oneline
read -r -p "What is the next version? " new_version
if [[ -z ${new_version} ]]; then
echo "No version provided, exiting..."
exit 1
fi
# update version in the script
if [[ $OSTYPE == "darwin"* ]]; then
# macOS system
sed -i '' "s/__version__ = .*/__version__ = \"$new_version\"/" aws-creds.py
else
sed -i "s/__version__ = .*/__version__ = \"$new_version\"/" aws-creds.py
fi
git commit --interactive \
--message "Bump program version to ${new_version}" \
--message "The $(${new_version}) is set as a version for the next release." \
--message "This commit was created by the release script."
14 changes: 13 additions & 1 deletion .workflows/save-work-ahead
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,16 @@ ruff check --config line-length=120 --fix aws-creds.py ||
ruff format --config line-length=120 aws-creds.py

echo "Verifying 'install.sh'..."
cat install.sh | INSTALL_DIR=.install bash
INSTALL_DIR=.install bash <install.sh

echo "Update __version__ in 'aws-creds.py'..."
# shellcheck disable=SC2046 # Quote this to prevent word splitt...
latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1))
new_version="${latest_tag}+$(date "+%Y%m%d-%H%M%S")"
if [[ $OSTYPE == "darwin"* ]]; then
# macOS system
sed -i '' "s/__version__ = .*/__version__ = \"$new_version\"/" aws-creds.py
else
sed -i "s/__version__ = .*/__version__ = \"$new_version\"/" aws-creds.py
fi
python aws-creds.py --version
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ For Brew users, just run `brew install bees-hive/hive/aws-creds`.
### `aws-creds`
```shell
~ aws-creds --help
usage: aws-creds [-h] {describe-creds,scan-local,scan-ic,session-ic,session-access-key} ...
usage: aws-creds [-h] [--version]
{describe-creds,scan-local,scan-ic,session-ic,session-access-key} ...

Painless CLI authentication using various AWS identities.

options:
-h, --help show this help message and exit
--version show program's version number and exit
Commands:
{describe-creds,scan-local,scan-ic,session-ic,session-access-key}
Expand Down
2 changes: 2 additions & 0 deletions aws-creds.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import sys
from typing import Dict, Optional, Literal, TextIO

__version__ = "0.6.0+20240625-113053"
_prog = Path(__file__).name.split(".")[0]
_dependencies_home = Path.home().joinpath(".cache").joinpath(_prog)
_clear_session_function_name = f"{_prog}-clear-session"
Expand Down Expand Up @@ -565,6 +566,7 @@ def main():
prog=_prog,
formatter_class=lambda prog: HelpFormatter(prog, width=100),
)
parser.add_argument("--version", action="version", version=f"{_prog} {__version__}")
subparsers = parser.add_subparsers(title="Commands", dest="subcommand")

subparsers.add_parser(
Expand Down

0 comments on commit 92b8903

Please sign in to comment.