diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 0716f6fd5..02c40a511 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -158,3 +158,11 @@ jobs: context: . push: true tags: backblaze/b2:${{ steps.build.outputs.version }} + + snap-release: + if: ${{ vars.B2_DEBIAN_BUCKET_UPLOAD }} + name: Build Snap Package + uses: ./.github/workflows/cd_snap.yml + secrets: inherit + with: + b2-upload-bucket: ${{ vars.B2_DEBIAN_BUCKET_UPLOAD }} diff --git a/.github/workflows/cd_snap.yml b/.github/workflows/cd_snap.yml new file mode 100644 index 000000000..0a5997ed1 --- /dev/null +++ b/.github/workflows/cd_snap.yml @@ -0,0 +1,28 @@ +name: Snap Package Continuous Delivery + +on: + workflow_call: + inputs: + b2-upload-bucket: + required: true + type: string + +jobs: + build-deb: + env: + B2_APPLICATION_KEY_ID: '${{ secrets.B2_DEBIAN_APPLICATION_KEY_ID }}' + B2_APPLICATION_KEY: '${{ secrets.B2_DEBIAN_APPLICATION_KEY }}' + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: snapcore/action-build@v1 + id: snapcraft + + - name: Upload to B2 + run: | + pip install -U wheel b2 + b2 upload_file ${{ inputs.b2-upload-bucket }} ${{ steps.snapcraft.outputs.snap }} ${{ steps.snapcraft.outputs.snap }} diff --git a/.gitignore b/.gitignore index c0cd70cdf..80c5f7379 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,7 @@ venv doc/source/main_help.rst Dockerfile b2/licenses_output.txt +# snap package +parts +prime +stage diff --git a/pyproject.toml b/pyproject.toml index 142af8456..1e1e2d1c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] requires-python = ">=3.7" name = "b2" -version = "0.0.0" # this is wrong, but setuptools>61 insists its here +dynamic = ["version"] [tool.ruff] # TODO add D @@ -17,3 +17,11 @@ line-length = 100 [tool.ruff.per-file-ignores] "__init__.py" = ["F401"] "test/**" = ["D", "F403", "F405"] + +[build-system] +requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +version_scheme = "post-release" + diff --git a/setup.py b/setup.py index 899d1a179..b9dbd534d 100644 --- a/setup.py +++ b/setup.py @@ -112,7 +112,7 @@ def read_requirements(extra=None): 'doc': read_requirements('doc'), 'license': read_requirements('license'), }, - setup_requires=['setuptools_scm<6.0'], + setup_requires=['setuptools_scm'], use_scm_version=True, # If there are data files included in your packages that need to be diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 000000000..2819929b0 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,37 @@ +name: backblaze-b2 +base: core22 +version: git +summary: This program provides command-line access to the B2 service. +description: The command-line tool that gives easy access to all of the capabilities of B2 Cloud Storage. +adopt-info: backblaze-b2 + +grade: stable +confinement: strict + +architectures: + - build-on: arm64 + - build-on: amd64 + +apps: + backblaze-b2: + command: bin/b2 + aliases: [ backblaze-b2 ] + plugs: [ network ] + environment: + PYTHONPATH: $PYTHONPATH:$SNAP/lib/python3.11/site-packages + +parts: + backblaze-b2: + source: . + source-type: git + plugin: python + build-packages: + - python3-setuptools + - python3-setuptools-scm + + override-pull: | + snapcraftctl pull + # remove pyproject.toml until _fully_ migrated to it + mv pyproject.toml pyproject.toml_snapignore || true + version="$(python3 setup.py --version)" + craftctl set version=$version