prepare pypi release

This commit is contained in:
Robert Kaussow 2020-04-11 19:28:56 +02:00
parent b110295dd5
commit 3abce0822e
4 changed files with 262 additions and 197 deletions

View File

@ -1,239 +1,271 @@
local PythonVersion(pyversion="3.5") = { local PythonVersion(pyversion='3.5') = {
name: "python" + std.strReplace(pyversion, '.', '') + "-pytest", name: 'python' + std.strReplace(pyversion, '.', '') + '-pytest',
image: "python:" + pyversion, image: 'python:' + pyversion,
pull: "always", pull: 'always',
environment: { environment: {
PY_COLORS: 1 PY_COLORS: 1,
}, },
commands: [ commands: [
"pip install -r dev-requirements.txt -qq", 'pip install -r dev-requirements.txt -qq',
"pip install -qq .", 'pip install -qq .',
"git-batch --help", 'git-batch --help',
], ],
depends_on: [ depends_on: [
"clone", 'clone',
], ],
}; };
local PipelineLint = { local PipelineLint = {
kind: "pipeline", kind: 'pipeline',
name: "lint", name: 'lint',
platform: { platform: {
os: "linux", os: 'linux',
arch: "amd64", arch: 'amd64',
}, },
steps: [ steps: [
{ {
name: "flake8", name: 'flake8',
image: "python:3.8", image: 'python:3.8',
pull: "always", pull: 'always',
environment: { environment: {
PY_COLORS: 1 PY_COLORS: 1,
}, },
commands: [ commands: [
"pip install -r dev-requirements.txt -qq", 'pip install -r dev-requirements.txt -qq',
"pip install -qq .", 'pip install -qq .',
"flake8 ./gitbatch", 'flake8 ./gitbatch',
], ],
},
],
trigger: {
ref: ["refs/heads/master", "refs/tags/**", "refs/pull/**"],
}, },
],
trigger: {
ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
},
}; };
local PipelineTest = { local PipelineTest = {
kind: "pipeline", kind: 'pipeline',
name: "test", name: 'test',
platform: { platform: {
os: "linux", os: 'linux',
arch: "amd64", arch: 'amd64',
}, },
steps: [ steps: [
PythonVersion(pyversion="3.5"), PythonVersion(pyversion='3.5'),
PythonVersion(pyversion="3.6"), PythonVersion(pyversion='3.6'),
PythonVersion(pyversion="3.7"), PythonVersion(pyversion='3.7'),
PythonVersion(pyversion="3.8"), PythonVersion(pyversion='3.8'),
], ],
trigger: { trigger: {
ref: ["refs/heads/master", "refs/tags/**", "refs/pull/**"], ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
}, },
depends_on: [ depends_on: [
"lint", 'lint',
], ],
}; };
local PipelineSecurity = { local PipelineSecurity = {
kind: "pipeline", kind: 'pipeline',
name: "security", name: 'security',
platform: { platform: {
os: "linux", os: 'linux',
arch: "amd64", arch: 'amd64',
}, },
steps: [ steps: [
{ {
name: "bandit", name: 'bandit',
image: "python:3.8", image: 'python:3.8',
pull: "always", pull: 'always',
environment: { environment: {
PY_COLORS: 1 PY_COLORS: 1,
}, },
commands: [ commands: [
"pip install -r dev-requirements.txt -qq", 'pip install -r dev-requirements.txt -qq',
"pip install -qq .", 'pip install -qq .',
"bandit -r ./gitbatch -x ./gitbatch/tests", 'bandit -r ./gitbatch -x ./gitbatch/tests',
], ],
},
],
depends_on: [
"test",
],
trigger: {
ref: ["refs/heads/master", "refs/tags/**", "refs/pull/**"],
}, },
],
depends_on: [
'test',
],
trigger: {
ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
},
}; };
local PipelineBuildContainer(arch="amd64") = { local PipelineBuildPackage = {
kind: "pipeline", kind: 'pipeline',
name: "build-container-" + arch, name: 'build-package',
platform: { platform: {
os: "linux", os: 'linux',
arch: 'amd64',
},
steps: [
{
name: 'build',
image: 'python:3.8',
commands: [
'python setup.py sdist bdist_wheel',
],
},
{
name: 'checksum',
image: 'alpine',
commands: [
'cd dist/ && sha256sum * > ../sha256sum.txt',
],
},
{
name: 'publish-github',
image: 'plugins/github-release',
settings: {
overwrite: true,
api_key: { from_secret: 'github_token' },
files: ['dist/*', 'sha256sum.txt'],
title: '${DRONE_TAG}',
note: 'CHANGELOG.md',
},
when: {
ref: ['refs/tags/**'],
},
},
{
name: 'publish-pypi',
image: 'plugins/pypi',
settings: {
username: { from_secret: 'pypi_username' },
password: { from_secret: 'pypi_password' },
repository: 'https://upload.pypi.org/legacy/',
skip_build: true,
},
when: {
ref: ['refs/tags/**'],
},
},
],
depends_on: [
'security',
],
trigger: {
ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
},
};
local PipelineBuildContainer(arch='amd64') = {
kind: 'pipeline',
name: 'build-container-' + arch,
platform: {
os: 'linux',
arch: arch, arch: arch,
}, },
steps: [ steps: [
{ {
name: "build", name: 'build',
image: "python:3.8", image: 'python:3.8',
pull: "always", pull: 'always',
commands: [ commands: [
"python setup.py bdist_wheel", 'python setup.py bdist_wheel',
] ],
}, },
{ {
name: "dryrun", name: 'dryrun',
image: "plugins/docker:18-linux-" + arch, image: 'plugins/docker:18-linux-' + arch,
pull: "always", pull: 'always',
settings: { settings: {
dry_run: true, dry_run: true,
dockerfile: "Dockerfile", dockerfile: 'Dockerfile',
repo: "xoxys/git-batch", repo: 'xoxys/git-batch',
username: { "from_secret": "docker_username" }, username: { from_secret: 'docker_username' },
password: { "from_secret": "docker_password" }, password: { from_secret: 'docker_password' },
}, },
when: { when: {
ref: ["refs/pull/**"], ref: ['refs/pull/**'],
}, },
}, },
{ {
name: "publish", name: 'publish',
image: "plugins/docker:18-linux-" + arch, image: 'plugins/docker:18-linux-' + arch,
pull: "always", pull: 'always',
settings: { settings: {
auto_tag: true, auto_tag: true,
auto_tag_suffix: arch, auto_tag_suffix: arch,
dockerfile: "Dockerfile", dockerfile: 'Dockerfile',
repo: "xoxys/git-batch", repo: 'xoxys/git-batch',
username: { "from_secret": "docker_username" }, username: { from_secret: 'docker_username' },
password: { "from_secret": "docker_password" }, password: { from_secret: 'docker_password' },
}, },
when: { when: {
ref: ["refs/heads/master", "refs/tags/**"], ref: ['refs/heads/master', 'refs/tags/**'],
}, },
}, },
], ],
depends_on: [ depends_on: [
"security", 'security',
], ],
trigger: { trigger: {
ref: ["refs/heads/master", "refs/tags/**", "refs/pull/**"], ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
}, },
}; };
local PipelineNotifications = { local PipelineNotifications = {
kind: "pipeline", kind: 'pipeline',
name: "notifications", name: 'notifications',
platform: { platform: {
os: "linux", os: 'linux',
arch: "amd64", arch: 'amd64',
}, },
steps: [ steps: [
{ {
image: "plugins/manifest", image: 'plugins/manifest',
name: "manifest", name: 'manifest',
pull: "always",
settings: { settings: {
ignore_missing: true, ignore_missing: true,
auto_tag: true, auto_tag: true,
username: { from_secret: "docker_username" }, username: { from_secret: 'docker_username' },
password: { from_secret: "docker_password" }, password: { from_secret: 'docker_password' },
spec: "manifest.tmpl", spec: 'manifest.tmpl',
},
when: {
ref: [
'refs/heads/master',
'refs/tags/**',
],
}, },
}, },
{ {
name: "readme", name: 'readme',
image: "sheogorath/readme-to-dockerhub", image: 'sheogorath/readme-to-dockerhub',
pull: "always",
environment: { environment: {
DOCKERHUB_USERNAME: { from_secret: "docker_username" }, DOCKERHUB_USERNAME: { from_secret: 'docker_username' },
DOCKERHUB_PASSWORD: { from_secret: "docker_password" }, DOCKERHUB_PASSWORD: { from_secret: 'docker_password' },
DOCKERHUB_REPO_PREFIX: "xoxys", DOCKERHUB_REPO_PREFIX: 'xoxys',
DOCKERHUB_REPO_NAME: "git-batch", DOCKERHUB_REPO_NAME: 'git-batch',
README_PATH: "README.md", README_PATH: 'README.md',
SHORT_DESCRIPTION: "git-batch" SHORT_DESCRIPTION: 'git-batch - Automate cloning a single branch from a repo list',
},
when: {
ref: [
'refs/heads/master',
'refs/tags/**',
],
}, },
}, },
{ {
name: "microbadger", name: 'matrix',
image: "plugins/webhook", image: 'plugins/matrix',
pull: "always",
settings: { settings: {
urls: { from_secret: "microbadger_url" }, homeserver: { from_secret: 'matrix_homeserver' },
}, roomid: { from_secret: 'matrix_roomid' },
}, template: 'Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}',
{ username: { from_secret: 'matrix_username' },
name: "matrix", password: { from_secret: 'matrix_password' },
image: "plugins/matrix",
settings: {
template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}",
roomid: { "from_secret": "matrix_roomid" },
homeserver: { "from_secret": "matrix_homeserver" },
username: { "from_secret": "matrix_username" },
password: { "from_secret": "matrix_password" },
},
when: {
status: [ "success", "failure" ],
}, },
}, },
], ],
depends_on: [ depends_on: [
"build-container-amd64", 'docs',
"build-container-arm64",
"build-container-arm"
], ],
trigger: { trigger: {
ref: ["refs/heads/master", "refs/tags/**"], ref: ['refs/heads/master', 'refs/tags/**'],
status: [ "success", "failure" ], status: ['success', 'failure'],
}, },
}; };
[ [
PipelineLint, PipelineLint,
PipelineTest, PipelineTest,
PipelineSecurity, PipelineSecurity,
PipelineBuildContainer(arch="amd64"), PipelineBuildPackage,
PipelineBuildContainer(arch="arm64"), PipelineBuildContainer(arch='amd64'),
PipelineBuildContainer(arch="arm"), PipelineBuildContainer(arch='arm64'),
PipelineNotifications, PipelineBuildContainer(arch='arm'),
PipelineNotifications,
] ]

View File

@ -117,6 +117,62 @@ trigger:
depends_on: depends_on:
- test - test
---
kind: pipeline
name: build-package
platform:
os: linux
arch: amd64
steps:
- name: build
image: python:3.8
commands:
- python setup.py sdist bdist_wheel
- name: checksum
image: alpine
commands:
- cd dist/ && sha256sum * > ../sha256sum.txt
- name: publish-github
image: plugins/github-release
settings:
api_key:
from_secret: github_token
files:
- dist/*
- sha256sum.txt
note: CHANGELOG.md
overwrite: true
title: ${DRONE_TAG}
when:
ref:
- refs/tags/**
- name: publish-pypi
image: plugins/pypi
settings:
password:
from_secret: pypi_password
repository: https://upload.pypi.org/legacy/
skip_build: true
username:
from_secret: pypi_username
when:
ref:
- refs/tags/**
trigger:
ref:
- refs/heads/master
- refs/tags/**
- refs/pull/**
depends_on:
- security
--- ---
kind: pipeline kind: pipeline
name: build-container-amd64 name: build-container-amd64
@ -295,7 +351,6 @@ platform:
steps: steps:
- name: manifest - name: manifest
pull: always
image: plugins/manifest image: plugins/manifest
settings: settings:
auto_tag: true auto_tag: true
@ -305,13 +360,8 @@ steps:
spec: manifest.tmpl spec: manifest.tmpl
username: username:
from_secret: docker_username from_secret: docker_username
when:
ref:
- refs/heads/master
- refs/tags/**
- name: readme - name: readme
pull: always
image: sheogorath/readme-to-dockerhub image: sheogorath/readme-to-dockerhub
environment: environment:
DOCKERHUB_PASSWORD: DOCKERHUB_PASSWORD:
@ -321,18 +371,7 @@ steps:
DOCKERHUB_USERNAME: DOCKERHUB_USERNAME:
from_secret: docker_username from_secret: docker_username
README_PATH: README.md README_PATH: README.md
SHORT_DESCRIPTION: git-batch SHORT_DESCRIPTION: git-batch - Automate cloning a single branch from a repo list
when:
ref:
- refs/heads/master
- refs/tags/**
- name: microbadger
pull: always
image: plugins/webhook
settings:
urls:
from_secret: microbadger_url
- name: matrix - name: matrix
image: plugins/matrix image: plugins/matrix
@ -346,10 +385,6 @@ steps:
template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}" template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}"
username: username:
from_secret: matrix_username from_secret: matrix_username
when:
status:
- success
- failure
trigger: trigger:
ref: ref:
@ -360,12 +395,10 @@ trigger:
- failure - failure
depends_on: depends_on:
- build-container-amd64 - docs
- build-container-arm64
- build-container-arm
--- ---
kind: signature kind: signature
hmac: b0b80a9e961c9d56a25b583c0e5404b09039a725be5e635670d7c2ef346add5e hmac: 3e6e5bc16fce1351d01113283724c7642644fa7be4726e77879986a08395080b
... ...

0
CHANGELOG.md Normal file
View File

View File

@ -2,7 +2,7 @@
__author__ = "Robert Kaussow" __author__ = "Robert Kaussow"
__project__ = "git-batch" __project__ = "git-batch"
__version__ = "0.1.0" __version__ = "0.2.0"
__license__ = "MIT" __license__ = "MIT"
__maintainer__ = "Robert Kaussow" __maintainer__ = "Robert Kaussow"
__email__ = "mail@geeklabor.de" __email__ = "mail@geeklabor.de"