From b9dd2916bdf9a54f3f45501510e2b57a07d515b5 Mon Sep 17 00:00:00 2001 From: MarleneKress79789 Date: Mon, 20 Nov 2023 13:13:54 +0100 Subject: [PATCH] added pypi release workflow --- .../actions/prepare_poetry_env/action.yaml | 20 ++++++++++ .github/workflows/pypi_release.yaml | 37 +++++++++++++++++++ .github/workflows/pytest.yaml | 15 +++----- 3 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 .github/actions/prepare_poetry_env/action.yaml create mode 100644 .github/workflows/pypi_release.yaml diff --git a/.github/actions/prepare_poetry_env/action.yaml b/.github/actions/prepare_poetry_env/action.yaml new file mode 100644 index 0000000..ca3299e --- /dev/null +++ b/.github/actions/prepare_poetry_env/action.yaml @@ -0,0 +1,20 @@ +name: 'Prepare Poetry environment' +description: 'This composite actions checks out out the project, installs Poetry, and install the project in the Poetry environment' +inputs: + python-version: + description: 'The Python version to use' + required: true + default: '3.8' + +runs: + using: "composite" + steps: + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install Poetry + uses: abatilo/actions-poetry@v2.1.4 + with: + poetry-version: 1.4.0 + - name: Install dependencies + run: poetry install diff --git a/.github/workflows/pypi_release.yaml b/.github/workflows/pypi_release.yaml new file mode 100644 index 0000000..29f7538 --- /dev/null +++ b/.github/workflows/pypi_release.yaml @@ -0,0 +1,37 @@ +name: Build & Publish + +on: + push: + tags: '**' + + workflow_dispatch: + +jobs: + + cd-job: + name: Continues Delivery + runs-on: ubuntu-latest + steps: + + - name: SCM Checkout + uses: actions/checkout@v3 + + - name: Setup Python & Poetry Environment + uses: ./.github/actions/prepare_poetry_env + + - name: Build Artifacts + run: poetry build + + - name: PyPi Release + env: + POETRY_HTTP_BASIC_PYPI_USERNAME: "__token__" + POETRY_HTTP_BASIC_PYPI_PASSWORD: "${{ secrets.PYPI_TOKEN }}" + run: poetry publish + + - name: GitHub Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: > + gh release create ${GITHUB_REF_NAME} + --title ${GITHUB_REF_NAME} -F "./doc/changes/changes_${GITHUB_REF_NAME}.md" + dist/* \ No newline at end of file diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index d18a3bc..957308d 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -11,13 +11,8 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install Poetry - uses: abatilo/actions-poetry@v2.1.4 - - name: Install dependencies - run: poetry install - - name: Run pytest - run: poetry run python3 -m pytest + - uses: actions/checkout@v2 + - name: Setup Python & Poetry Environment + uses: ./.github/actions/prepare_poetry_env + - name: Run pytest + run: poetry run python3 -m pytest