stegtext 0.1.3

Text steganography command-line tool and library.
Documentation
#!/usr/bin/env python3

#
# release.py: release script. run checks, publish crate, build/tag/push
# signed image to container registry.
#
# Usage:
#
#   # create signed tag
#   git tag -sF path/to/release-notes.txt 1.2.3
#
#   # run this script
#   ./release.py
#

import os, subprocess, sys, tomllib

# signing key
# used to sign the container image and the release tag
SIGN_KEY: str = '021136521548EB198F64FF738E182534CDD1F2B8'

def run(cmd: list[str]) -> None:
  '''execute command'''
  print(' '.join(cmd))
  subprocess.run(cmd, check=True)

# get version from Cargo.toml and revision from tag
version: str = tomllib.load(open(os.path.join(os.path.dirname(__file__), 'Cargo.toml'), 'rb'))['package']['version']
revision = subprocess.run(['git', 'show-ref', version], capture_output=True, check=True).stdout.decode()[0:40]

# verify release tag signature
run(['git', 'tag', '-v', version])

# check release
run(['cargo', 'check', '--release']) # check build
run(['cargo', 'test', '--release']) # run tests
run(['cargo', 'clippy', '--release']) # lint
run(['cargo', 'tarpaulin', '--release', '--engine', 'llvm', '--fail-under', '94']) # check coverage
run(['cargo', 'publish', '--dry-run']) # dry-run publish

# publish crate
run(['cargo', 'publish'])

# build container image tags
tags = [f'codeberg.org/pablotron/stegtext:{tag}' for tag in ['latest', version]]

# build/tag container image
run(['podman', 'build', '-t', 'stegtext:latest', '--build-arg', f'VERSION={version}', '--build-arg', f'REVISION={revision}', '.'])
run(['podman', 'tag', 'stegtext:latest', f'stegtext:{version}'] + tags)

# push signed container images
for tag in tags:
  run(['podman', 'push', '--sign-by', SIGN_KEY, tag])