Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cd: build snap package #181

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
28 changes: 28 additions & 0 deletions .github/workflows/cd_snap.yml
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ venv
doc/source/main_help.rst
Dockerfile
b2/licenses_output.txt
# snap package
parts
prime
stage
10 changes: 9 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 37 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -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