yaclog/.github/workflows/build.yml

141 lines
4.2 KiB
YAML
Raw Normal View History

2021-04-17 04:47:21 +00:00
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: build
2021-04-25 22:56:23 +00:00
on: [ push, pull_request ]
2021-04-17 04:47:21 +00:00
jobs:
2021-04-25 22:56:23 +00:00
test:
name: Test Python Module
runs-on: ubuntu-22.04
2021-04-25 22:56:23 +00:00
strategy:
matrix:
2024-04-16 07:02:09 +00:00
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
2024-08-08 07:50:19 +00:00
click-version: [ "click~=8.0" ]
2021-04-25 22:56:23 +00:00
steps:
2024-04-16 07:03:35 +00:00
- uses: actions/checkout@v4
2021-04-25 22:56:23 +00:00
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5.1.1
2021-04-25 22:56:23 +00:00
with:
python-version: ${{ matrix.python-version }}
2021-04-17 04:47:21 +00:00
2021-04-25 22:56:23 +00:00
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8
python -m pip install ${{ matrix.click-version }}
2021-04-25 22:56:23 +00:00
- 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 --max-complexity=10 --max-line-length=127 --statistics
2024-08-22 05:39:25 +00:00
- name: Install module
run: python -m pip install .
- name: Run Unit Tests
run: python -m unittest -v
2021-04-25 22:56:23 +00:00
2024-08-28 05:48:55 +00:00
test-action:
name: Test Github Action
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Get Changelog Information
uses: ./
id: yaclog-show
with:
changelog-path: 'tests/Test-Changelog.md'
- name: Fail Outputs
if: >
!(
steps.yaclog-show.outputs.name == '0.13.0 "Aquarius"' &&
steps.yaclog-show.outputs.header == '0.13.0 "Aquarius" - 1970-04-11 [YANKED]' &&
steps.yaclog-show.outputs.version == '0.13.0' &&
endsWith(steps.yaclog-show.outputs.changelog, 'tests/Test-Changelog.md') &&
hashFiles(steps.yaclog-show.outputs.body-file) == '33b42eab899b0ff3b0e2a0647718cf9bf748af40e5e9a7c6af3642b35001223a'
)
run: 'false' # fail the run
build:
name: Build Distribution
2024-08-28 05:48:55 +00:00
needs:
- test
- test-action
runs-on: ubuntu-22.04
outputs:
body-file: ${{ steps.yaclog-show.outputs.body-file }}
version-name: ${{ steps.yaclog-show.outputs.name }}
2021-04-17 04:47:21 +00:00
steps:
2024-04-16 07:02:09 +00:00
- uses: actions/checkout@v4
2021-04-17 04:47:21 +00:00
- name: Set up Python
uses: actions/setup-python@v5.1.1
2021-04-17 04:47:21 +00:00
with:
python-version: '3.12'
- name: Get Changelog Information
id: yaclog-show
uses: ./ # self-hosting!
2021-04-17 04:47:21 +00:00
- name: Install pypa/build
run: python -m pip install build --user
- name: Build a binary wheel and source tarball
run: python -m build --sdist --wheel --outdir dist/
- uses: actions/upload-artifact@v4
with:
name: python-distribution
path: dist/
compression-level: 0 # already compressed
publish-pypi:
name: Deploy to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: build
runs-on: ubuntu-22.04
environment:
name: Publish
url: https://pypi.org/project/yaclog/${{ github.ref_name }}
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: python-distribution
path: dist/
2021-04-17 04:47:21 +00:00
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
publish-github:
name: Deploy to Github
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: build
runs-on: ubuntu-22.04
environment:
name: Publish
url: https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }}
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
name: python-distribution
path: dist/
- name: Publish to Github
run: >
gh release create ${{ github.ref_name }}
--notes-file "${{ needs.build.outputs.body-file }}"
--title "${{ needs.build.outputs.version-name }}"
dist/*
env:
2024-08-25 03:29:44 +00:00
GH_TOKEN: ${{ github.token }}