-
Notifications
You must be signed in to change notification settings - Fork 77
96 lines (87 loc) · 3.22 KB
/
push.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
# In addition it will tag a release if setup.py is updated with a new version
# and publish a release to pypi from the tag
name: Python package
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install -r requirements.txt
- name: Test with pytest
run: |
pytest
tag-release-if-needed:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.tag.outputs.version }}
steps:
- uses: actions/checkout@v2
- id: tag
name: Tag release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
git remote add tag_target "https://[email protected]/MycroftAI/lingua-franca.git"
VERSION=$(python setup.py --version)
git tag -f release/v$VERSION || exit 0
if git push tag_target --tags; then
echo "New tag published on github, push to PyPI as well."
pip install twine wheel
python setup.py sdist bdist_wheel
twine check dist/*
twine upload dist/*
echo "Package pushed to PyPI. Prepare for mycroft-core PR."
echo "::set-output name=version::$VERSION"
fi
update-mycroft-core:
runs-on: ubuntu-latest
needs: tag-release-if-needed
steps:
- uses: actions/checkout@v2
with:
repository: MycroftAI/mycroft-core
- name: Update mycroft-core
if: needs.tag-release-if-needed.outputs.version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=${{needs.tag-release-if-needed.outputs.version}}
if [[ $VERSION != *"."* ]]; then
echo "Not a valid version number."
exit 1
elif [[ $VERSION == *"-"* ]]; then
echo "Pre-release suffix detected. Not pushing to mycroft-core."
else
sed -E "s/lingua-franca==[0-9]+\.[0-9]+\.[0-9]+/lingua-franca==$VERSION/" requirements/requirements.txt > tmp-requirements.txt
mv tmp-requirements.txt requirements/requirements.txt
echo "LINGUA_FRANCA_VERSION=$VERSION" >> $GITHUB_ENV
fi
- name: Create Pull Request
if: ${{ env.LINGUA_FRANCA_VERSION }}
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.BOT_TOKEN }}
push-to-fork: mycroft-adapt-bot/mycroft-core
commit-message: Update Lingua Franca to v${{ env.LINGUA_FRANCA_VERSION }}
branch: feature/update-lingua-franca
delete-branch: true
title: Update Lingua Franca to v${{ env.LINGUA_FRANCA_VERSION }}
body: Automated update from mycroftai/lingua-franca.