-
Notifications
You must be signed in to change notification settings - Fork 7
97 lines (93 loc) · 3.24 KB
/
python-publish.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# This workflow will upload a Python Package using Twine when a release is created
name: Build and Upload Python Package
on:
workflow_dispatch:
inputs:
version:
description: 'Version number'
required: true
description:
description: 'Description'
required: false
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
environment: build_and_publish
steps:
- uses: actions/checkout@v3
- name: Print version number
run: echo ${{ github.event.inputs.version }}
- name: set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: update version number
run: |
python ./.github/update_version.py setup.py ${{ github.event.inputs.version }}
python ./.github/update_version.py conda-recipe/meta.yaml ${{ github.event.inputs.version }}
python ./.github/update_version.py docs/source/conf.py ${{ github.event.inputs.version }}
- name: install yapf
run: |
python -m pip install --upgrade pip
pip install yapf
- name: format repository with yapf in google-python format
run: yapf -i -r --style ./.github/style.yapf .
- name: retrieve name and E-Mail configuration
run: |
git config --global user.name ${{ secrets.NAME_GITHUB }}
git config --global user.email ${{ secrets.MAIL_GITHUB }}
- name: check for changes
run: git status
- name: stage changed files
run: git add .
- name: commit changed files
run: git commit -m "updated version number" --allow-empty
- name: fetch
run: git fetch
- name: push code to main
run: git push
- name: Create Release
uses: actions/create-release@v1
id: create_release
with:
draft: false
prerelease: false
release_name: v${{ github.event.inputs.version }}
tag_name: v${{ github.event.inputs.version }}
body: ${{ github.event.inputs.description }}
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Install setuptools, wheel and twine
run: |
pip install build setuptools wheel twine
- name: Clean PyPi build directories
run: rm -rf dist
- name: Build for PyPi
# env:
# TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
# TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
# twine upload dist/*
- name: Install conda dependencies
run: conda install anaconda-client conda-build
- name: Clean Anaconda build directories
run: rm -rf conda-bld
- name: Build and publish on Anaconda
env:
ANCONDA_USERNAME: ${{ secrets.ANACONDA_USERNAME }}
ANACONDA_PASSWORD: ${{ secrets.ANACONDA_PASSWORD }}
run: |
conda build conda-recipe/. -c conda-forge --croot conda-bld
/usr/share/miniconda/bin/anaconda login --username $ANCONDA_USERNAME --password $ANACONDA_PASSWORD
/usr/share/miniconda/bin/anaconda upload -u cnapy conda-bld/noarch/straindesign*
- name: Final clean up
run: |
rm -rf dist
rm -rf conda-bld