Skip to content

Pin GitHub Actions

Pin GitHub Actions #77

Workflow file for this run

# 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 }}