/janderscripts

Intented to collect personal scripts and misc. snippets over time. If some one else finds any use for these, great.

Primary LanguageShellMIT LicenseMIT

GitHub tag (latest SemVer)

Janderscripts

Gather small helpers and scripts, in different languages, mostly for personal usage, but who knows, there might be something for you in there.

About the scripts:

  • They should be glue scripts i.e. not use too much intricate logic, but serve as glueing a few specific commands and utils together.
  • They should come with a fair amount of unit- and integration-tests.
  • They should be structured enough for a non script expert to understand.
  • If growing, or beneficial in a more general sense, make no mistake - they should be obsoleted, and rewritten in a more robust language. Even better - be submitted as a PR to any relevant project where the overall function itself would feel at home.

Currently Maintained Script Descriptions

Bash

  • bash/src/changelog_release.bash - A util script to making an atomic release commit including an tag, changelog, updated project file. mvn, npm or gradle. Relies on Conventional Commits-standard.
  • bash/src/dirsumgen.bash - A wrapper for the creating md5 and sha256 sums for directory trees. One of each for each dir.
  • bash/src/export_gpg.sh - A script which exports your GPG private-, public keys and owner trust data (to a directory with locked down permissions).

Dependencies

Bash

General Usage

./bash/src/<script>.bash -h

SCRIPT: changelog_release usage

To make a nice release commit might need a few boring steps - adding a changelog, tagging, update project verison. Add Conventional commits, signing and signoffs. It is easy to forget and miss something. So why not make it easier, a one step process:

This script:

  1. calculate and tags next semver tag
  2. generates a changelog
  3. updates the project file version with the version tag
  4. commits the changelog and tag in a release commit

Requirements

  1. Your project is following Conventional Commits Standard.
  2. Your Git Settings is configured to sign and tag with SSH.
  3. You need asdf-vm installed to easily download all dependencies for the script.

Usage

  • Clone this repo
git@github.com:janderssonse/janderscripts.git

ALTERNATIVE 1 - Running the Changelog_Release script directly

  1. Easiest is to install asdf-vm

  2. Install the needed dependencies. Here are two commands that adds the plugins and then installs them for you. Note it will set them globally, but you can later switch versions easily with asdf, if needed for other projects.

# add asdf plugins from .tool-versions
$ cut -d' ' -f1 .tool-versions | xargs -i asdf plugin add {}

# install all listed .tool-versions plugins versions
$ asdf install

# pin the asdf versions
$ asdf global install git-chglog 0.15.4
$ asdf global install java adoptopenjdk-17.0.6+10
$ asdf global install maven 3.8.7
$ asdf global install nodejs 18.4.0
$ asdf global install semver 3.4.0
  1. From the root dir of the project you are about to update a changelog to, do
/path/to/janderscriptsrepo/you/just/cloned/bash/src/changelog_release.bash --help

ALTERNATIVE 2 - Running the Container image (saves you installing asdf-vm and dependencies)

There is a helpscript which will mount ssh agent and more for you.

/path/to/repo/you/just/cloned/scripts/run_changelog_release_container.sh '--help'

And you should get an overview of options. NOTE: as you run in an container, arguments will have to be given in one string surrounded by ''

The script requires that you are following the conventional commit format, and the commits and tags will be gpg-signed and signed off.

Examples

changelog_release cli

changelog_release with --help option

changelog_release cli

changelog_release run

changelog_release cli

changelog_release generated changelog example

changelog_release cli

changelog_release commit example - project file, changelog, tag and release commit message

SCRIPT: export_gpg

A script which exports your private keys, public keys and owner trust data (to a directory with locked down permissions).

I use it with YADM handle encryption/decryption of the export, and easily move between environments.

YADM-usage: Put a pattern of .gnupg/.exported-keyring/* into .config/yadm/config and use YADM encrypt/decrypt.

Importing the keys to a new location

$ gpg --import "$HOME/.gnupg/.exported-keyring"/*.asc
$ gpg --import-ownertrust "$HOME/.gnupg/.exported-keyring"/ownertrust.txt

Development

Test and code style

Bash

Running the bash tests

Install bats-core with support libs.

  1. To Install the Bats-core dependencies where the bats scripts can find them (/bash/lib):
./bash/install_bats.bash
  1. To run the tests:
./bash/lib/bats/bin/bats bash/src/test
  1. Run a script:
./bash/src/<script>.bash -h

Getting involved

See CONTRIBUTING.


License

Scripts in this project are licensed under the MIT LICENSE.


Credits

The Bats project - for making us create robust Bash-scripts.