|
| 1 | +# .github/workflows/publish.yml |
| 2 | + |
| 3 | +name: Publish |
| 4 | + |
| 5 | +on: |
| 6 | + release: |
| 7 | + types: [published] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v2 |
| 14 | + |
| 15 | + - name: Setup Python |
| 16 | + uses: actions/setup-python@v1 |
| 17 | + with: |
| 18 | + python-version: 3.7 |
| 19 | + |
| 20 | + - name: Install dependencies with pipenv |
| 21 | + run: | |
| 22 | + sleep 2m |
| 23 | + pip install pipenv |
| 24 | + pipenv install --dev --skip-lock |
| 25 | +
|
| 26 | + - run: pipenv run invoke build.install-package |
| 27 | + - run: pipenv run invoke test.format |
| 28 | + - run: pipenv run invoke test.lint |
| 29 | + - run: pipenv run invoke integration.clean |
| 30 | + - run: pipenv run invoke integration.version |
| 31 | + - run: pipenv run invoke integration.initialize |
| 32 | + - run: pipenv run invoke unit.pytest |
| 33 | + - run: pipenv run invoke test.security |
| 34 | + - run: pipenv run invoke integration.query |
| 35 | + - run: pipenv run invoke integration.write-policy |
| 36 | + - run: pipenv run invoke build.uninstall-package |
| 37 | + |
| 38 | + publish-package: |
| 39 | + needs: test |
| 40 | + runs-on: ubuntu-latest |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@master |
| 43 | + - name: Set up Python 3.7 |
| 44 | + uses: actions/setup-python@v1 |
| 45 | + with: |
| 46 | + python-version: 3.7 |
| 47 | + - uses: dschep/install-pipenv-action@v1 |
| 48 | + - name: Install dependencies |
| 49 | + run: | |
| 50 | + pipenv install --dev |
| 51 | + - name: create python package |
| 52 | + run: | |
| 53 | + git config --local user.email "action@github.com" |
| 54 | + git config --local user.name "GitHub Action" |
| 55 | + git fetch --tags |
| 56 | + git pull origin master |
| 57 | + pipenv run python setup.py sdist bdist_wheel |
| 58 | + - name: Publish package |
| 59 | + uses: pypa/gh-action-pypi-publish@master |
| 60 | + with: |
| 61 | + user: __token__ |
| 62 | + password: ${{ secrets.PYPI_PASSWORD }} |
| 63 | + |
| 64 | + update-brew: |
| 65 | + needs: publish-package |
| 66 | + runs-on: ubuntu-latest |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@master |
| 69 | + - name: Set up Python 3.7 |
| 70 | + uses: actions/setup-python@v1 |
| 71 | + with: |
| 72 | + python-version: 3.7 |
| 73 | + - uses: dschep/install-pipenv-action@v1 |
| 74 | + - name: publish brew |
| 75 | + run: | |
| 76 | + git config --local user.email "action@github.com" |
| 77 | + git config --local user.name "GitHub Action" |
| 78 | + pipenv run pip install homebrew-pypi-poet |
| 79 | + pipenv run pip install policy_sentry -U |
| 80 | + git fetch origin |
| 81 | + git checkout --track origin/master |
| 82 | + latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) |
| 83 | + echo "latest tag: $latest_tag" |
| 84 | + git pull origin $latest_tag |
| 85 | + pipenv run poet -f policy_sentry > HomebrewFormula/policy_sentry.rb |
| 86 | + git add . |
| 87 | + git commit -m "update brew formula" policy_sentry/bin/cli.py HomebrewFormula/policy_sentry.rb || echo "No brew changes to commit" |
| 88 | + git push -u origin master |
0 commit comments