PyPi and Docker Deploy #20
This file contains 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
# This is triggered manually. | |
# This will bump the version and publish a package to PyPi. | |
# if it completes it will also trigger a new Docker image build and push to DockHub at: | |
# https://github.com/RhinoSecurityLabs/pacu/blob/master/.github/workflows/deploy-docker.yml | |
# | |
name: PyPi and Docker Deploy | |
on: | |
workflow_dispatch: | |
inputs: | |
SemVer_level: | |
description: 'Semantic version level to use (patch,minor,major) https://python-poetry.org/docs/cli/' | |
required: true | |
default: 'patch' | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/master' | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry | |
- name: Bump version | |
run: | | |
poetry version ${{ github.event.inputs.SemVer_level }} | |
ver="$(poetry version -s)" | |
sed -i "s/pacu.version=\".*\"/pacu.version=\"$ver\"/" Dockerfile | |
sed -i "s/pacu.version=\".*\"/pacu.version=\"$ver\"/" Dockerfile.dev | |
- name: Commit and push version changes | |
run: | | |
ver="$(poetry version -s)" | |
git config --global user.email "<>" | |
git config --global user.name "Github-Actions" | |
git config --global credential.helper store | |
echo "https://${{secrets.GIT_USERNAME}}:${{secrets.GIT_TOKEN}}@github.com" > ~/.git-credentials | |
git add . | |
git commit -m "Release v${ver}" | |
git push | |
git tag "v${ver}" | |
git push origin "refs/tags/v${ver}" | |
- name: Build and publish | |
run: | | |
poetry publish --build -u "__token__" -p "${{ secrets.PYPI_TOKEN }}" |