Skip to content

Merge pull request #173 from InternetNZ/dependabot/pip/sphinx-rtd-the… #528

Merge pull request #173 from InternetNZ/dependabot/pip/sphinx-rtd-the…

Merge pull request #173 from InternetNZ/dependabot/pip/sphinx-rtd-the… #528

Workflow file for this run

name: PyEPP
on:
push:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements.dev.txt
pip install setuptools==65.5.1
pip install build twine
- name: Lint
run: |
./scripts/linter.sh
- name: Tests
run: |
./scripts/tests.sh
- name: Package Audit
run: |
./scripts/package-audit.sh
- name: Code Security Check
run: |
./scripts/code-security-check.sh
- name: Get Latest tag
run: |
git fetch --tags
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "LATEST_TAG: $LATEST_TAG"
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
- name: Extract version
run: |
NEW_VERSION=$(grep '^__version__' "pyepp/__init__.py" | sed -E 's/^__version__ = "(.*)"/v\1/')
echo "NEW_VERSION: $NEW_VERSION"
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
TRIMMED_VERSION=$(echo "$NEW_VERSION" | sed 's/^v//')
echo "TRIMMED_VERSION=$TRIMMED_VERSION" >> $GITHUB_ENV
- name: Publish to TestPyPi
if: github.event_name == 'push' && github.ref == 'refs/heads/develop' && env.LATEST_TAG != env.NEW_VERSION
run: |
rm -rf dist
python -m build
twine check dist/*
twine upload -r testpypi --username __token__ --password ${{ secrets.TEST_PYPI_API_TOKEN }} --skip-existing dist/*
- name: Publish to PyPi
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && env.LATEST_TAG != env.NEW_VERSION
run: |
rm -rf dist
python -m build
twine check dist/*
twine upload --username __token__ --password ${{ secrets.PYPI_API_TOKEN }} dist/*
- name: Create Tag
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && env.LATEST_TAG != env.NEW_VERSION
run: |
git tag ${{env.NEW_VERSION}}
git push origin ${{env.NEW_VERSION}}
- name: Generate changelog
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && env.LATEST_TAG != env.NEW_VERSION
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v4
with:
configurationJson: |
{
"categories": [
{
"title": "## 💬 Changes",
"labels": []
},
{
"title": "## 🐛 Fixes",
"labels": ["fix", "bug"]
},
{
"title": "## 📦 Dependencies",
"labels": ["dependencies"]
}
]
}
ignorePreReleases: "false"
fromTag: ${{ steps.previous_tag.outputs.tag }}
toTag: ${{env.NEW_VERSION}}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && env.LATEST_TAG != env.NEW_VERSION
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.NEW_VERSION }}
draft: false
body: |
[PyEPP on PyPI](https://pypi.org/project/pyepp/${{env.TRIMMED_VERSION}}/)
${{ steps.build_changelog.outputs.changelog }}
makeLatest: true
artifacts: "./dist/*"
- name: Cleanup workspace
uses: colpal/actions-clean@v1
if: ${{ always() }} # To ensure this step runs even when earlier steps fail