Skip to content

Commit

Permalink
added support for snap builds closes #19;
Browse files Browse the repository at this point in the history
added snap build action workflow
  • Loading branch information
infinityofspace committed Aug 28, 2021
1 parent 100a387 commit 94bf963
Show file tree
Hide file tree
Showing 8 changed files with 319 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,5 @@ fabric.properties
# Custom rules
.github
docker
snap
*.snap
23 changes: 23 additions & 0 deletions .github/workflows/snap-publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: snap release

on:
push:
tags:
- "v*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2

- name: build snap
uses: snapcore/action-build@v1

- name: publish snap
uses: snapcore/action-publish@v1
with:
store_login: ${{ secrets.SNAP_LOGIN }}
snap: ${{ steps.build.outputs.snap }}
release: stable
24 changes: 24 additions & 0 deletions .github/workflows/snap-publish-unstable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: snap unstable

on:
workflow_dispatch:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2

- name: build snap
uses: snapcore/action-build@v1

- name: publish snap
uses: snapcore/action-publish@v1
with:
store_login: ${{ secrets.SNAP_LOGIN }}
snap: ${{ steps.build.outputs.snap }}
release: edge
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,4 @@ dmypy.json
# Custom rules
test_certbot
*.ini
*.snap
198 changes: 198 additions & 0 deletions snap-constraints.txt

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions snap-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
requests>=2.20.0
zope.interface>=5.0.0
21 changes: 21 additions & 0 deletions snap/hooks/post-refresh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh -e
# This file is generated automatically and should not be edited manually.

# get certbot version
if [ ! -f "$SNAP/certbot-shared/certbot-version.txt" ]; then
echo "No certbot version available; not doing version comparison check" >> "$SNAP_DATA/debuglog"
exit 0
fi
cb_installed=$(cat $SNAP/certbot-shared/certbot-version.txt)

# get required certbot version for plugin. certbot version must be at least the plugin's
# version. note that this is not the required version in setup.py, but the version number itself.
cb_required=$(grep -oP "version = '\K.*(?=')" $SNAP/setup.py)


$SNAP/bin/python3 -c "import sys; from packaging import version; sys.exit(1) if version.parse('$cb_installed') < version.parse('$cb_required') else sys.exit(0)" || exit_code=$?
if [ "$exit_code" -eq 1 ]; then
echo "Certbot is version $cb_installed but needs to be at least $cb_required before" \
"this plugin can be updated; will try again on next refresh."
exit 1
fi
48 changes: 48 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: certbot-dns-duckdns
summary: DuckDNS Authenticator plugin for Certbot
description: DuckDNS Authenticator plugin for Certbot
confinement: strict
grade: stable
base: core20
adopt-info: certbot-dns-duckdns

parts:
certbot-dns-duckdns:
plugin: python
source: .
override-pull: |
snapcraftctl pull
snapcraftctl set-version `grep ^__version__ $SNAPCRAFT_PART_SRC/certbot_dns_duckdns/__init__.py | cut -f2 -d= | tr -d "\"[:space:]\""`
build-environment:
- PIP_CONSTRAINT: $SNAPCRAFT_PART_SRC/snap-constraints.txt
- SNAP_BUILD: "True"
requirements:
- snap-requirements.txt
build-packages:
- gcc
- git
- build-essential
- libssl-dev
- libffi-dev
- python3-dev
- cargo
certbot-metadata:
plugin: dump
source: .
stage: [ setup.py, certbot-shared ]
override-pull: |
snapcraftctl pull
mkdir -p $SNAPCRAFT_PART_SRC/certbot-shared
slots:
certbot:
interface: content
content: certbot-1
read:
- $SNAP/lib/python3.8/site-packages

plugs:
certbot-metadata:
interface: content
content: metadata-1
target: $SNAP/certbot-shared

0 comments on commit 94bf963

Please sign in to comment.