Skip to content

Commit

Permalink
Release 0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mmassenzio committed Dec 31, 2023
2 parents 51ea5a4 + d22608e commit 6c6deb7
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 44 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,18 @@ jobs:
run: |
git config user.name "$AUTHOR"
git config user.email "<$EMAIL>"
TAG=$(./get-version.sh manifest.json)
TAG=$(make version)
git tag -a $TAG -m "Release $TAG"
git push --tags
echo TAG=${TAG} >> $GITHUB_ENV
- name: Build tarball
run: |
tarball=common-utils-${{ env.TAG }}.tar.gz
sudo apt install -y pandoc
./package-utils.sh ${tarball}
echo TARBALL=${tarball} >> $GITHUB_ENV
make package
- uses: ncipollo/[email protected]
with:
tag: ${{ env.TAG }}
generateReleaseNotes: true
artifacts: ${{ env.TARBALL }}
artifacts: common-utils-${{ env.TAG }}.tar.gz
13 changes: 4 additions & 9 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Upon pushing to the main branch it runs all tests.
#
# Copyright (c) 2022 AlertAvert.com. All rights reserved.
# Copyright (c) 2020-2023 AlertAvert.com. All rights reserved.
# Author: Marco Massenzio ([email protected])
#
name: Build & Test
name: Execute Tests

on:
push:
Expand All @@ -25,10 +25,5 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Install dependencies
run: pip install pytest pytest-md
- uses: pavelzw/pytest-action@v2
with:
emoji: false
verbose: false
job-summary: true
- name: Run tests
run: make test
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@
#
# Author: Marco Massenzio ([email protected])

TESTDIR := tests
TESTDIR := parse-args
VERSION = $(shell ./scripts/get-version.sh manifest.json)
TARBALL := common-utils-$(VERSION).tar.gz

package:
./package.sh $(TARBALL)

test:
@echo "--- Running tests in the ${TESTDIR} directory"
python -m unittest discover -s ${TESTDIR}

version:
@echo $(VERSION)
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ source ${COMMON_UTILS}/utils && \

# Utils

The `utils` script contains a collection of simple utilities for shell scripts (see [`utils.sh`](utils.sh) for a full description of each command).
The `utils` script contains a collection of simple utilities for shell scripts (see [`utils.sh`](scripts/utils.sh) for a full description of each command).

- general file and path handlers:
```
Expand Down Expand Up @@ -167,7 +167,7 @@ matters when the command line is parsed. As such, obviously, an *optional* posi
result in unexpected behavior.


For example (see the [`parse_example`](parse_example) script):
For example (see the [`parse_example`](examples/parse_examples/parse_example) script):

```shell
source $(./parse_args keep- counts! take mount+ -- $@)
Expand Down Expand Up @@ -198,7 +198,7 @@ ERROR: the following arguments are required: mount

## Implementation

The source code is available [here](parse_args.py) and revolves around adding arguments to `argparse.ArgumentParser` dynamically:
The source code is available [here](parse-args/parse_args.pyrse_args.py) and revolves around adding arguments to `argparse.ArgumentParser` dynamically:

```python
for arg in args:
Expand All @@ -210,7 +210,7 @@ The source code is available [here](parse_args.py) and revolves around adding ar
parser.add_argument(f"{prefix}{m.group('opt')}", **kwargs)
```

We have subclassed the `ArgumentParser` with a [`StderrParser`](parse_args.py#lines-12) so that:
We have subclassed the `ArgumentParser` with a [`StderrParser`](parse-args/parse_args.pyrse_args.py#lines-12) so that:

* when erroring out, we emit error messages to `stderr` so they don't get "swallowed" in the bash script; and
* we need to exit with an error code, so that using `set -e` in our shell script will cause it to terminate, instead of executing the `source` command with potentially unexpected consequences.
Expand Down
File renamed without changes.
8 changes: 7 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@

set -eu

declare -r TARBALL="https://github.com/massenz/common-utils/releases/download/$VERSION/common-utils-$VERSION.tar.gz"
if [[ -z ${VERSION:-} || -z ${COMMON_UTILS} ]]
then
echo "A release version must be defined via the \$VERSION env var, and"
echo "a destination folder via \$COMMON_UTILS (it will be created if it doesn't exist)"
exit 1
fi

echo "Installing common-utils Rel. $VERSION to $COMMON_UTILS"
declare -r TARBALL="https://github.com/massenz/common-utils/releases/download/$VERSION/common-utils-$VERSION.tar.gz"
if [[ ! -d ${COMMON_UTILS} ]]
then
mkdir -p ${COMMON_UTILS}
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version" : "0.8.0",
"version" : "0.9.0",
"metadata": {
"author": "[email protected]",
"comment": "Common utilities for Shell Scripts"
Expand Down
11 changes: 6 additions & 5 deletions package-utils.sh → package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Author: Marco Massenzio ([email protected])
#
set -eu
source utils.sh
source scripts/utils.sh

declare -r TARBALL=${1:-}
if [[ -z ${TARBALL} ]]
Expand All @@ -22,15 +22,16 @@ declare -r DEST=$(mktemp -d)
declare -r BASE=$(abspath $(dirname $0))

pushd ${BASE}
for f in build parse-args runtests utils get-version; do
cp $f.* ${DEST}/$f
for f in build get-version parse-args runtests utils ; do
cp scripts/$f.sh ${DEST}/$f
chmod +x $DEST/$f
done
cp -r commons.cmake parse_args.py templates/ $DEST/
cp -r templates/ $DEST/
cp parse-args/parse_args.py $DEST/

# Generate HTML instructions.
pandoc README.md -t html -o /tmp/README.html
cat head.html /tmp/README.html >${DEST}/README.html
cat head.html /tmp/README.html tail.html >${DEST}/README.html
popd

tar cf ${TARBALL} -C ${DEST} .
Expand Down
File renamed without changes.
10 changes: 0 additions & 10 deletions tests/test_parseargs.py → parse-args/test_parseargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
# Author: Marco Massenzio ([email protected])
#
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Author: Marco Massenzio ([email protected])
#
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Author: Marco Massenzio ([email protected])

import argparse
import unittest
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 1 addition & 8 deletions tail.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
</div>
</body>
</html><!--
~ Copyright (c) 2020-2023 AlertAvert.com. All rights reserved.
~
~ Licensed under the Apache License, Version 2.0
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Author: Marco Massenzio ([email protected])
-->
</html>
File renamed without changes.

0 comments on commit 6c6deb7

Please sign in to comment.