Skip to content

Release v0.4.0

Release v0.4.0 #5

name: Publish release build to pypi and create release tag
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.build-step.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install pip and flake package
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --statistics
- name: Install poetry and project dependencies
run: |
python -m pip install poetry
poetry install
- name: Test with pytest
run: |
echo ${{ github.workspace }}
cd ${{ github.workspace }}/tests
poetry run pytest --github-action-run=True
- name: Build
id: build-step
run: |
poetry build
VERSION=$(poetry version -s)
echo "$VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Print release version
run: |
echo "the version number is ${{ steps.build-step.outputs.version }}"
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: dwcahandler-dist-v${{ steps.build-step.outputs.version }}
path: dist
publish-to-pypi:
name: Publish dwcahandler distribution to PyPI
runs-on: ubuntu-latest
needs:
- build
environment:
name: production
url: https://pypi.org/p/dwcahandler
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: dwcahandler-dist-v${{ needs.build.outputs.version }}
path: dist/
- name: Publish dwcahandler distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
github-release:
name: >-
Sign the dwcahandler distribution with Sigstore
and upload them to GitHub Release
needs: [build, publish-to-pypi]
runs-on: ubuntu-latest
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: dwcahandler-dist-v${{ needs.build.outputs.version }}
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
id: create-release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
version="v${{ needs.build.outputs.version }}"
gh release create $version --repo ${{ github.repository }}
echo "tag-version=$version" >> "$GITHUB_OUTPUT"
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ steps.create-release.outputs.tag-version }}' dist/**
--repo '${{ github.repository }}'