Merge pull request #42 from Authress/revert-3902d33 #109
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- main | |
- master | |
- 'release/**' | |
pull_request: | |
branches: | |
- main | |
- master | |
- 'release/**' | |
permissions: | |
contents: write | |
packages: write | |
id-token: write | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up environment | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Set Version number | |
if: github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master' && github.event_name == 'push' | |
run: | | |
branchId="${GITHUB_REF/refs\/heads\/release\//}" | |
buildNumber="${branchId}.${GITHUB_RUN_NUMBER}" | |
echo $branchId $buildNumber | |
sed "s/0.0.0/${buildNumber}/g" ./authress/VERSION -i | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 pytest | |
pip3 install -r requirements.txt -r test-requirements.txt | |
- name: Run Tests | |
run: pytest test # Only run the test directory | |
- 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 | |
- name: Build deployable | |
run: | | |
python3 -m pip install build --user | |
python3 -m build --sdist --wheel --outdir dist/ . | |
- name: Deploy package to package repository | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
if: github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master' && github.event_name == 'push' | |
with: | |
print_hash: true | |
- name: Tag and release version | |
if: github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master' && github.event_name == 'push' | |
run: | | |
git tag ${GITHUB_REF/refs\/heads\/release\//}.$GITHUB_RUN_NUMBER | |
git push origin ${GITHUB_REF/refs\/heads\/release\//}.$GITHUB_RUN_NUMBER |