-
Notifications
You must be signed in to change notification settings - Fork 696
55 lines (50 loc) · 1.77 KB
/
python-deploy-pypi.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# 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 }}"