Pin GitHub Actions #77
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries | |
| name: Upload Python Package | |
| on: | |
| release: | |
| types: [published] | |
| pull_request: | |
| types: | |
| - closed | |
| jobs: | |
| create-github-release: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| permissions: write-all | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 | |
| - name: Extract version from prismacloud/cli/version.py | |
| run: | | |
| version=$(grep 'version = ' prismacloud/api/version.py | sed -E "s/version = \"([^\"]+)\"/\1/") | |
| echo "PRISMA_CLOUD_API_VERSION=$version" >> $GITHUB_ENV | |
| - name: Create GitHub Release | |
| run: | | |
| gh release create ${{ env.PRISMA_CLOUD_API_VERSION }} --generate-notes --latest | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - create-github-release | |
| steps: | |
| - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Install Dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pylint | |
| pip install build | |
| pip install -r requirements_test.txt | |
| - name: Test API | |
| run: | | |
| pylint prismacloud/api | |
| - name: Build package | |
| run: python -m build | |
| - name: Run tests | |
| run: | | |
| coverage run -m unittest discover -v -s "./tests" -p "test*.py" | |
| - name: Publish | |
| uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # release/v1 | |
| with: | |
| user: __token__ | |
| password: ${{ secrets.PYPI_API_TOKEN }} |