Compare commits
No commits in common. "d228660900853c12df620bfbdd58c2e2ef0741ab" and "2b5959281919612101eb6931959973a0876d2ed9" have entirely different histories.
d228660900
...
2b59592819
4 changed files with 8 additions and 67 deletions
|
@ -1,3 +0,0 @@
|
|||
[MESSAGES CONTROL]
|
||||
disable=locally-disabled,
|
||||
redefined-outer-name,
|
|
@ -1,13 +0,0 @@
|
|||
pipeline:
|
||||
test-pylint:
|
||||
group: test
|
||||
image: pipelinecomponents/pylint
|
||||
commands:
|
||||
- python3 -m pip install debian-parser
|
||||
- pylint entrypoint.py
|
||||
|
||||
test-flake8:
|
||||
group: test
|
||||
image: pipelinecomponents/flake8
|
||||
commands:
|
||||
- flake8 entrypoint.py
|
38
README.md
38
README.md
|
@ -1,38 +0,0 @@
|
|||
# Woodpecker CI plugin to publish Debian package on a Aptly repository
|
||||
|
||||
This docker image could be used as an Woodpecker CI plugin to publish one (or more) Debian package on a Aptly repository using its API.
|
||||
|
||||
This plugin will try to :
|
||||
- locate all `changes` files in the `dist` directory (that matched `source_name` if provided)
|
||||
- extract files that are mentioned by the changes files and upload it using Aptly files API. Files are published on a subdirectory of the name of the source package
|
||||
- include all processed changes files using Aplty repos API
|
||||
- create a snapshot of the repository named using current datetime and repository name (format: `YYYYMMDD-HHMMSS-repo`) using Aptly snapshot API
|
||||
- update the published snapshot of the repository using Aptly publish API
|
||||
|
||||
[![status-badge](https://ci.zionetrix.net/api/badges/bn8/aptly-publish/status.svg)](https://ci.zionetrix.net/bn8/aptly-publish)
|
||||
|
||||
# Usage
|
||||
|
||||
The below pipeline configuration demonstrates simple usage:
|
||||
|
||||
```
|
||||
pipeline:
|
||||
publish:
|
||||
image: brenard/aptly-publish
|
||||
settings:
|
||||
api_url: https://your.aptly.tld/api
|
||||
api_username: myproject
|
||||
api_password:
|
||||
from_secret: aptly_api_password
|
||||
repo_name: stable
|
||||
path: dist
|
||||
source_name: myproject
|
||||
```
|
||||
|
||||
__Parameters:__
|
||||
- __api_url:__ Your Aptly API URL (required)
|
||||
- __api_username:__ Username to authenticate on your Aptly API (required)
|
||||
- __api_password:__ Password to authenticate on your Aptly API (required)
|
||||
- __repo_name:__ Repository name to publish on (optional, default: `stable`)
|
||||
- __path:__ Path to the directory where files to publish are stored (optional, default: `dist`)
|
||||
- __source_name:__ Name of the source package to publish (optional, default: all `changes` files are will be publish)
|
|
@ -1,9 +1,4 @@
|
|||
#!/usr/bin/python3
|
||||
""""
|
||||
Entrypoint of a Woodpecker CI docker image plugin that permit to publish Debian
|
||||
packages on a Aptly repository using its API
|
||||
"""
|
||||
|
||||
import datetime
|
||||
import os
|
||||
import re
|
||||
|
@ -81,8 +76,8 @@ if MAX_RETRY:
|
|||
def list_files_in_changes_file(filepath):
|
||||
""" List files included by a changes file """
|
||||
dirpath = os.path.dirname(filepath)
|
||||
with open(filepath, "r", encoding="utf-8") as file_desc:
|
||||
changes_file = file_desc.read()
|
||||
with open(filepath, "r", encoding="utf-8") as fd:
|
||||
changes_file = fd.read()
|
||||
|
||||
parser = PackagesParser(changes_file)
|
||||
files = []
|
||||
|
@ -106,8 +101,8 @@ def changes_file2package_name(changes_file):
|
|||
def upload_file(package_name, filepath):
|
||||
""" Upload a file using Aptly API """
|
||||
url = f'{API_URL}/files/{package_name}'
|
||||
with open(filepath, 'rb') as file_desc:
|
||||
result = session.post(url, files={'file': file_desc})
|
||||
with open(filepath, 'rb') as fd:
|
||||
result = session.post(url, files={'file': fd})
|
||||
return (
|
||||
result.status_code == 200 and
|
||||
f'{package_name}/{os.path.basename(filepath)}' in result.json()
|
||||
|
@ -165,16 +160,16 @@ for changes_file in changes_files:
|
|||
|
||||
|
||||
# Create a snapshot of the repository
|
||||
snap_name = datetime.datetime.now().strftime(f'%Y%m%d-%H%M%S_{REPO_NAME}')
|
||||
snap_name = datetime.datetime.now().strftime('%Y%m%d-%H%M%S') + f'{REPO_NAME}'
|
||||
print(f'Create new snapshot "{snap_name}" of repository "{REPO_NAME}"')
|
||||
|
||||
url = f'{API_URL}/repos/{REPO_NAME}/snapshots'
|
||||
payload = {'Name': snap_name}
|
||||
result = session.post(url, json=payload)
|
||||
try:
|
||||
data = result.json()
|
||||
except Exception: # pylint: disable=broad-except
|
||||
data = {}
|
||||
data = result.json()
|
||||
except Exception:
|
||||
data = {}
|
||||
error = (
|
||||
result.status_code < 200 or
|
||||
result.status_code > 299 or
|
||||
|
|
Loading…
Reference in a new issue