diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml new file mode 100644 index 0000000..937a578 --- /dev/null +++ b/.forgejo/workflows/build.yaml @@ -0,0 +1,67 @@ +on: + push: + workflow_dispatch: + inputs: + verbose: + description: "Verbose" + required: false + default: false + type: boolean + +jobs: + test: + runs-on: container + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v4 + with: + version: "0.5.5" + + - name: Install + run: uv sync + + - name: Build wheel + run: uv build --wheel + + - name: Publish Python package (home) + env: + LOCAL_PYPI_TOKEN: ${{ secrets.LOCAL_PYPI_TOKEN }} + run: uv publish --publish-url https://code.philo.ydns.eu/api/packages/philorg/pypi --token $LOCAL_PYPI_TOKEN + + - name: Get version + id: version + run: echo "version=$(.venv/bin/tinyseady-mailer --version)" >> $GITHUB_OUTPUT + + - name: Workaround for bug of podman-login + run: | + mkdir -p $HOME/.docker + echo "{ \"auths\": {} }" > $HOME/.docker/config.json + + - name: Log in to the container registry (with another workaround) + uses: actions/podman-login@v1 + with: + registry: ${{ vars.REGISTRY }} + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_PASSWORD }} + auth_file_path: /tmp/auth.json + + - name: Build the container image + uses: actions/buildah-build@v1 + with: + image: tinyseady-mailer + oci: true + labels: tinyseady-mailer + tags: latest ${{ steps.version.outputs.version }} + containerfiles: | + ./Containerfile + + - name: Push the image to the registry + uses: actions/push-to-registry@v2 + with: + registry: "docker://${{ vars.REGISTRY }}/${{ vars.ORGANISATION }}" + image: tinyseady-mailer + tags: latest ${{ steps.version.outputs.version }} diff --git a/src/tinysteady_mailer/__init__.py b/src/tinysteady_mailer/__init__.py index 473613b..74e8098 100644 --- a/src/tinysteady_mailer/__init__.py +++ b/src/tinysteady_mailer/__init__.py @@ -12,6 +12,19 @@ __doc__ = ( def main() -> None: + from argparse import ArgumentParser + + parser = ArgumentParser(description=__doc__) + parser.add_argument( + "-v", "--version", action="store_true", help="Print version and exit" + ) + args = parser.parse_args() + if args.version: + from importlib.metadata import version + + print(version("tinysteady-mailer")) + sys.exit(0) + if CONFIG is None: print(__doc__) sys.exit(0)