|
| 1 | +name: Publish |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [ published ] |
| 6 | + |
| 7 | +jobs: |
| 8 | + test: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + strategy: |
| 11 | + matrix: |
| 12 | + python-version: ['3.7', '3.8', '3.9'] |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v2 |
| 15 | + |
| 16 | + - name: Setup Python |
| 17 | + uses: actions/setup-python@v2 |
| 18 | + with: |
| 19 | + python-version: ${{ matrix.python-version }} |
| 20 | + |
| 21 | + - name: Install dependencies |
| 22 | + run: | |
| 23 | + make setup-dev |
| 24 | +
|
| 25 | + - name: Run pytest (unit tests) and bandit (security test) |
| 26 | + run: | |
| 27 | + make test |
| 28 | +
|
| 29 | + - name: Install the package to make sure nothing is randomly broken |
| 30 | + run: | |
| 31 | + make install |
| 32 | +
|
| 33 | + publish-package: |
| 34 | + needs: test |
| 35 | + runs-on: ubuntu-latest |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@master |
| 38 | + - name: Set up Python 3.7 |
| 39 | + uses: actions/setup-python@v2 |
| 40 | + with: |
| 41 | + python-version: 3.7 |
| 42 | + |
| 43 | + |
| 44 | + - name: Install dependencies |
| 45 | + run: | |
| 46 | + pip install -r requirements.txt |
| 47 | + pip install -r requirements-dev.txt |
| 48 | + - name: create python package |
| 49 | + run: | |
| 50 | + git config --local user.email "[email protected]" |
| 51 | + git config --local user.name "GitHub Action" |
| 52 | + git fetch --tags |
| 53 | + git pull origin main |
| 54 | + pip install setuptools wheel twine |
| 55 | + python -m setup sdist bdist_wheel |
| 56 | + - name: Publish package |
| 57 | + uses: pypa/gh-action-pypi-publish@master |
| 58 | + with: |
| 59 | + user: __token__ |
| 60 | + password: ${{ secrets.PYPI_PASSWORD }} |
| 61 | + |
| 62 | + |
| 63 | + update-brew: |
| 64 | + needs: publish-package |
| 65 | + runs-on: ubuntu-latest |
| 66 | + steps: |
| 67 | + - uses: actions/checkout@master |
| 68 | + - name: Set up Python 3.7 |
| 69 | + uses: actions/setup-python@v2 |
| 70 | + with: |
| 71 | + python-version: 3.7 |
| 72 | + - name: publish brew |
| 73 | + run: | |
| 74 | + sleep 5m |
| 75 | + git config --local user.email "[email protected]" |
| 76 | + git config --local user.name "GitHub Action" |
| 77 | + pip install homebrew-pypi-poet |
| 78 | + pip install endgame -U |
| 79 | + git fetch origin |
| 80 | + git checkout --track origin/main |
| 81 | + latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) |
| 82 | + echo "latest tag: $latest_tag" |
| 83 | + git pull origin $latest_tag |
| 84 | + mkdir -p "HomebrewFormula" && touch "HomebrewFormula/endgame.rb" |
| 85 | + poet -f endgame > HomebrewFormula/endgame.rb |
| 86 | + git add . |
| 87 | + git commit -m "update brew formula" endgame/bin/cli.py HomebrewFormula/endgame.rb || echo "No brew changes to commit" |
| 88 | + git push -u origin main |
0 commit comments