File: push.yml

package info (click to toggle)
adapt 1.0.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 344 kB
  • sloc: python: 2,112; sh: 50; makefile: 3
file content (116 lines) | stat: -rw-r--r-- 3,858 bytes parent folder | download
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# 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.6, 3.7, 3.8, 3.9, 2.7]

    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
        python setup.py install
        python -m pip install -r test-requirements.txt
    - name: Lint with flake8
      run: |
        # stop the build if there are Python syntax errors or undefined names
        # Code style checks disabled until the style of the project is set.
        ./run_tests.sh lint
    - name: Test with pytest
      run: |
        ./run_tests.sh test

  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://$GITHUB_TOKEN@github.com/MycroftAI/adapt.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

  publish:
    runs-on: ubuntu-latest
    if: contains(github.ref, '/tags/release')
    needs: build
    steps:
    - uses: actions/checkout@v2
    - name: Push to pypi
      env:
        TWINE_USERNAME: __token__
        TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
      run: |
        pip install twine wheel
        python setup.py sdist bdist_wheel
        twine check dist/*
        twine upload dist/*

  update-mycroft-core:
    runs-on: ubuntu-latest
    needs: [publish, tag-release-if-needed]
    steps:
    - uses: actions/checkout@v2
      with: 
        repository: MycroftAI/mycroft-core

    - name: Update mycroft-core
      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/adapt-parser==[0-9]+\.[0-9]+\.[0-9]+/adapt-parser==$VERSION/" requirements/requirements.txt > tmp-requirements.txt
          mv tmp-requirements.txt requirements/requirements.txt
          echo "ADAPT_VERSION=$VERSION" >> $GITHUB_ENV
        fi

    - name: Create Pull Request
      if: ${{ env.ADAPT_VERSION }}
      uses: peter-evans/create-pull-request@v3
      with:
        token: ${{ secrets.BOT_TOKEN }}
        push-to-fork: mycroft-adapt-bot/mycroft-core
        commit-message: Update Adapt to v${{ env.ADAPT_VERSION }}
        branch: feature/update-adapt
        delete-branch: true
        title: Update Adapt to v${{ env.ADAPT_VERSION }}
        body: Automated update from mycroftai/adapt.