-
Notifications
You must be signed in to change notification settings - Fork 1
78 lines (68 loc) · 2.04 KB
/
deploy.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: deploy
on:
workflow_run:
workflows:
- check
types:
- completed
branches:
- master
- main
- develop
workflow_dispatch:
env:
PROJECT_NAME: psyki-python
WORKFLOW: deploy
jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Deploy on PyPI and create release
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # all history
- name: Get All Tags
run: git fetch --tags -f
- name: Get Python Version
id: get-python-version
run: echo "version=$(cat .python-version)" >> $GITHUB_OUTPUT
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ steps.get-python-version.outputs.version }}
- name: Restore Python dependencies
run: pip install -r requirements.txt
- name: Change default logging level
run: sed -i -e 's/DEBUG/WARN/g' psyki/__init__.py
- name: Pack
run: python -m build
- name: Archive Dist Artifacts
if: failure() || success()
uses: actions/upload-artifact@v4
with:
name: dist
path: './dist'
- name: Upload
run: python -m twine upload dist/*
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
- name: Get Version
id: get-version
run: echo "version=$(python setup.py get_project_version | tail -n 1)" >> $GITHUB_OUTPUT
- name: Release Assets
id: upload-release-assets
run: |
set -x
ASSETS=()
for A in dist/*; do
ASSETS+=("-a" "$A")
echo "Releasing $A"
done
RELEASE_TAG='${{ steps.get-version.outputs.version }}'
sudo apt-get update && sudo apt-get install -y hub
hub release create "${ASSETS[@]}" -m "$RELEASE_TAG" "$RELEASE_TAG"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}