Debian Codegraph @

.github/workflows/push.yml

raw symbols SCIP
1 # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2 # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3 # In addition it will tag a release if setup.py is updated with a new version
4 # and publish a release to pypi from the tag
5
6 name: Python package
7
8 on:
9 push:
10 branches: [ master ]
11
12 jobs:
13 build:
14
15 runs-on: ubuntu-latest
16 strategy:
17 matrix:
18 python-version: [3.6, 3.7, 3.8, 3.9, 2.7]
19
20 steps:
21 - uses: actions/checkout@v2
22 - name: Set up Python ${{ matrix.python-version }}
23 uses: actions/setup-python@v2
24 with:
25 python-version: ${{ matrix.python-version }}
26 - name: Install dependencies
27 run: |
28 python -m pip install --upgrade pip
29 python setup.py install
30 python -m pip install -r test-requirements.txt
31 - name: Lint with flake8
32 run: |
33 # stop the build if there are Python syntax errors or undefined names
34 # Code style checks disabled until the style of the project is set.
35 ./run_tests.sh lint
36 - name: Test with pytest
37 run: |
38 ./run_tests.sh test
39
40 tag-release-if-needed:
41 runs-on: ubuntu-latest
42 outputs:
43 version: ${{ steps.tag.outputs.version }}
44 steps:
45 - uses: actions/checkout@v2
46 - id: tag
47 name: Tag release
48 env:
49 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50 TWINE_USERNAME: __token__
51 TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
52 run: |
53 git remote add tag_target "https://[email protected]/MycroftAI/adapt.git"
54 VERSION=$(python setup.py --version)
55 git tag -f release/v$VERSION || exit 0
56 if git push tag_target --tags; then
57 echo "New tag published on github, push to PyPI as well."
58 pip install twine wheel
59 python setup.py sdist bdist_wheel
60 twine check dist/*
61 twine upload dist/*
62 echo "Package pushed to PyPI. Prepare for mycroft-core PR."
63 echo "::set-output name=version::$VERSION"
64 fi
65
66 publish:
67 runs-on: ubuntu-latest
68 if: contains(github.ref, '/tags/release')
69 needs: build
70 steps:
71 - uses: actions/checkout@v2
72 - name: Push to pypi
73 env:
74 TWINE_USERNAME: __token__
75 TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
76 run: |
77 pip install twine wheel
78 python setup.py sdist bdist_wheel
79 twine check dist/*
80 twine upload dist/*
81
82 update-mycroft-core:
83 runs-on: ubuntu-latest
84 needs: [publish, tag-release-if-needed]
85 steps:
86 - uses: actions/checkout@v2
87 with:
88 repository: MycroftAI/mycroft-core
89
90 - name: Update mycroft-core
91 env:
92 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93 run: |
94 VERSION=${{needs.tag-release-if-needed.outputs.version}}
95 if [[ $VERSION != *"."* ]]; then
96 echo "Not a valid version number."
97 exit 1
98 elif [[ $VERSION == *"-"* ]]; then
99 echo "Pre-release suffix detected. Not pushing to mycroft-core."
100 else
101 sed -E "s/adapt-parser==[0-9]+\.[0-9]+\.[0-9]+/adapt-parser==$VERSION/" requirements/requirements.txt > tmp-requirements.txt
102 mv tmp-requirements.txt requirements/requirements.txt
103 echo "ADAPT_VERSION=$VERSION" >> $GITHUB_ENV
104 fi
105
106 - name: Create Pull Request
107 if: ${{ env.ADAPT_VERSION }}
108 uses: peter-evans/create-pull-request@v3
109 with:
110 token: ${{ secrets.BOT_TOKEN }}
111 push-to-fork: mycroft-adapt-bot/mycroft-core
112 commit-message: Update Adapt to v${{ env.ADAPT_VERSION }}
113 branch: feature/update-adapt
114 delete-branch: true
115 title: Update Adapt to v${{ env.ADAPT_VERSION }}
116 body: Automated update from mycroftai/adapt.