From 7e5e01f8b71a535477eaf74b162bc3d3480543c3 Mon Sep 17 00:00:00 2001 From: Andreas Baulig Date: Thu, 25 Nov 2021 21:57:21 +0000 Subject: [PATCH] Add PyPI deployment to CI/CD --- .github/workflows/build.yml | 64 +++++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 20 ------------ README.md | 2 +- 3 files changed, 65 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..fc6a780 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,64 @@ +name: build + +on: + push: + pull_request: + release: + types: + - published + - edited + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout repository and submodules + uses: actions/checkout@v2 + with: + submodules: recursive + - name: Run tests + uses: ./.devcontainer + with: + args: make all + - name: Run tests with config + uses: ./.devcontainer + with: + args: make all AUTOFFF_CONFIG=config.ini + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Build distribution files + uses: ./.devcontainer + with: + args: poetry build + - name: Upload distribution files as artifacts + uses: actions/upload-artifact@v2 + with: + name: dist + path: ./dist + if-no-files-found: error + deploy: + runs-on: ubuntu-latest + needs: [test, build] + steps: + - name: Download distribution files + uses: actions/download-artifact@v2 + with: + name: dist + path: ./dist + - name: Publish autofff to TestPyPI + if: ${{ github.event_name == 'release' || (github.event_name == 'push' && github.ref == 'refs/heads/master') }} + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: ${{ secrets.TEST_PYPI_USERNAME }} + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + skip_existing: true + - name: Publish autofff to PyPI + if: ${{ github.event_name == 'release' }} + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: ${{ secrets.PYPI_USERNAME }} + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 587446d..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: test - -on: [push, pull_request] - -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Checkout repository and submodules - uses: actions/checkout@v2 - with: - submodules: recursive - - name: Run tests - uses: ./.devcontainer - with: - args: make all - - name: Run tests with config - uses: ./.devcontainer - with: - args: make all AUTOFFF_CONFIG=config.ini diff --git a/README.md b/README.md index 508cc34..b5ee856 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # AutoFFF -[![test](https://github.com/ChiefGokhlayeh/autofff/actions/workflows/test.yml/badge.svg)](https://github.com/ChiefGokhlayeh/autofff/actions/workflows/test.yml) +[![build](https://github.com/ChiefGokhlayeh/autofff/actions/workflows/build.yml/badge.svg)](https://github.com/ChiefGokhlayeh/autofff/actions/workflows/build.yml) [![PyPI version](https://badge.fury.io/py/autofff.svg)](https://badge.fury.io/py/autofff) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)