Compare commits

...

4 commits

Author SHA1 Message Date
Markus Siebert 9aa5b31fac
Merge 55643c3051 into 4d7c9d57bf 2024-04-29 18:56:19 +02:00
Marvin Gaube 4d7c9d57bf
feat: automatic build & publish, update authors 2024-04-29 18:36:29 +02:00
Florian Meinicke c6a82af9d9
Add --digits option
to allow configuring the number of digits in the ASN string. This
argument is optional and defaults to 7 to keep backwards compatibility.
2024-04-29 18:27:56 +02:00
Markus 55643c3051 feat: add herma 4346 labels 2024-01-06 11:11:14 +01:00
5 changed files with 106 additions and 1 deletions

87
.github/workflows/publish.yaml vendored Normal file
View file

@ -0,0 +1,87 @@
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
# based on https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows
on: push
jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all history for tags, allowing to build proper dev version
- run: pipx install hatch
- run: hatch build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/
publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' # only publish to PyPI on tag pushes or dev version for main
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/paperless-asn-qr-codes
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
github-release:
name: >-
Sign the Python 🐍 distribution 📦 with Sigstore
and upload them to GitHub Release
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- publish-to-pypi
runs-on: ubuntu-latest
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v1.2.3
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'

View file

@ -24,6 +24,8 @@ positional arguments:
options:
-h, --help show this help message and exit
--format {averyL4731,avery5160,avery5161,avery5163,avery5167,avery5371}, -f {averyL4731,avery5160,avery5161,avery5163,avery5167,avery5371}
--digits DIGITS, -d DIGITS
Number of digits in the ASN (default: 7, produces 'ASN0000001')
--border, -b Display borders around labels, useful for debugging the printer alignment
```
@ -39,6 +41,7 @@ options:
- `-h`, `--help`: Shows the help message
- `-f`, `--format`: Selects the format of the output sheet (see [Supported Sheets](#supported-sheets))
- `-d`, `--digits`: Specifies the number of digits in the ASN (e.g. for the default number 7, the ASN will look like 'ASN0000001')
- `-b`, `--border`: Generates the borders around the labels to help debug alignment issues (see [Tips & Tricks](#tips--tricks))
## Supported Sheets

View file

@ -82,6 +82,14 @@ labelInfo: dict[str, LabelInfo] = {
margin=(54, 36),
pagesize=LETTER,
),
"herma4346": LabelInfo(
labels_horizontal=4,
labels_vertical=12,
label_size=(45.72*mm, 21.167*mm),
gutter_size=(2.54*mm, 0),
margin=(9.75*mm,21.5*mm),
pagesize=A4,
)
}
RETURN_ADDRESS = 5167

View file

@ -8,7 +8,8 @@ from paperless_asn_qr_codes import avery_labels
def render(c, x, y):
global startASN
barcode_value = f"ASN{startASN:07d}"
global digits
barcode_value = f"ASN{startASN:0{digits}d}"
startASN = startASN + 1
qr = QRCodeImage(barcode_value, size=y * 0.9)
@ -27,6 +28,9 @@ def main():
parser.add_argument(
"--format", "-f", choices=avery_labels.labelInfo.keys(), default="averyL4731"
)
parser.add_argument(
"--digits", "-d", default=7, help="Number of digits in the ASN (default: 7, produces 'ASN0000001')", type=int
)
parser.add_argument(
"--border",
"-b",
@ -35,7 +39,9 @@ def main():
)
args = parser.parse_args()
global startASN
global digits
startASN = int(args.start_asn)
digits = int(args.digits)
label = avery_labels.AveryLabel(args.format, args.border)
label.open(args.output_file)
# by default, we render all labels possible on a single sheet

View file

@ -11,6 +11,7 @@ license = "GPL-3.0"
keywords = []
authors = [
{ name = "Jan Christian Grünhage", email = "jan.christian@gruenhage.xyz" },
{ name = "margau", email = "dev@marvingaube.de" },
]
classifiers = [
"Development Status :: 4 - Beta",