From 9248565b1b2fd06c9287ad5a59b6cd59e1349126 Mon Sep 17 00:00:00 2001 From: Berislav Lopac Date: Thu, 6 Oct 2022 00:17:27 +0100 Subject: [PATCH] add ci pipelines --- .semaphore/create-release.yml | 27 ++++++++++++++ .semaphore/semaphore.yml | 70 +++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 .semaphore/create-release.yml create mode 100644 .semaphore/semaphore.yml diff --git a/.semaphore/create-release.yml b/.semaphore/create-release.yml new file mode 100644 index 0000000..fed1299 --- /dev/null +++ b/.semaphore/create-release.yml @@ -0,0 +1,27 @@ +version: v1.0 +name: Publish release +agent: + machine: + type: e1-standard-2 + os_image: ubuntu2004 +global_job_config: + prologue: + commands: + - sem-version python 3.8 + - checkout + - python -m pip install -U pip poetry +blocks: + - name: Create release + run: + when: "branch = 'main'" + task: + secrets: + - name: semantic-release-credentials + jobs: + - name: Collect package details and create GitHub release + commands: + - RELEASE_VERSION=$(python -m poetry version -s) + - 'RELEASE_NOTES_FILE="release-notes/${RELEASE_VERSION}.md"' + - 'if [ ! -f "$RELEASE_NOTES_FILE" ]; then echo "The release notes file \"${RELEASE_NOTES_FILE}\" does not exist."; exit 1; fi' + - 'if [[ $RELEASE_VERSION =~ \.[0-9]+(a|b|rc)[0-9] ]]; then PRERELEASE="--prerelease"; fi' + - gh release create $RELEASE_VERSION --notes-file $RELEASE_NOTES_FILE $PRERELEASE diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml new file mode 100644 index 0000000..be9d8df --- /dev/null +++ b/.semaphore/semaphore.yml @@ -0,0 +1,70 @@ +version: v1.0 +name: Python checks and tests +agent: + machine: + type: e1-standard-2 + os_image: ubuntu2004 +global_job_config: + prologue: + commands: + - checkout +blocks: + - name: Code checks + dependencies: [] + task: + prologue: + commands: + - sem-version python 3.8 + - python -m pip install -U pip poetry tox tox-poetry + jobs: + - name: checks + commands: + - python -m tox -e checks + - name: Unit tests + dependencies: + - Code checks + task: + prologue: + commands: + - sem-version python $PY_VERSION + - python -m pip install -U pip poetry tox tox-poetry + jobs: + - name: tests + matrix: + - env_var: PY_VERSION + values: + - '3.8' + - '3.9' + - '3.10' + commands: + - 'PY_ENV=py"${PY_VERSION//.}"' + - python -m tox -e $PY_ENV + epilogue: + on_pass: + commands: + - 'test-results publish "test-reports/$PY_ENV-junit.xml"' + - name: Publish release + dependencies: ["Unit tests"] + run: + when: "tag =~ '^([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*((a|b|rc)(0|[1-9][0-9]*))?$'" + task: + secrets: + - name: pypi-credentials + prologue: + commands: + - sem-version python 3.8 + - python -m pip install -U pip poetry + jobs: + - name: Build and upload Python package + commands: + - poetry build -f wheel + - poetry publish -u b11c -p $PYPI_PASSWORD +after_pipeline: + task: + jobs: + - name: Publish Test Results + commands: + - test-results gen-pipeline-report +promotions: + - name: Create new release + pipeline_file: create-release.yml