-
Notifications
You must be signed in to change notification settings - Fork 2
143 lines (124 loc) · 4.47 KB
/
release.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: release
on:
workflow_dispatch:
release:
types: [published]
env:
PACKAGE_DIR: adbpyg_adapter
TESTS_DIR: tests
jobs:
build:
runs-on: self-hosted
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
include:
- python: "3.7"
DB_NAME: "py37"
- python: "3.8"
DB_NAME: "py38"
- python: "3.9"
DB_NAME: "py39"
- python: "3.10"
DB_NAME: "py310"
name: Python ${{ matrix.python }}
steps:
- uses: actions/checkout@v2
- name: Set up pip & install packages
run: |
source ~/anaconda3/etc/profile.d/conda.sh
conda activate ${{ matrix.python }}
python -m pip install --upgrade pip setuptools wheel
pip install torch
pip install .[dev]
- name: Run black
run: conda run -n ${{ matrix.python }} black --check --verbose --diff --color ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}
- name: Run flake8
run: flake8 ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}
- name: Run isort
run: isort --check --profile=black ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}
- name: Run mypy
run: conda run -n ${{ matrix.python }} mypy ${{env.PACKAGE_DIR}} ${{env.TESTS_DIR}}
- name: Run pytest in conda env
run: conda run -n ${{ matrix.python }} pytest --dbName ${{ matrix.DB_NAME }} --cov=${{env.PACKAGE_DIR}} --cov-report xml --cov-report term-missing -v --color=yes --no-cov-on-fail --code-highlight=yes
- name: Publish to coveralls.io
if: matrix.python == '3.8'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: conda run -n ${{ matrix.python }} coveralls --service=github
release:
needs: build
runs-on: self-hosted
defaults:
run:
shell: bash -l {0}
name: Release package
steps:
- uses: actions/checkout@v2
- name: Fetch complete history for all tags and branches
run: git fetch --prune --unshallow
- name: Install packages
run: |
source ~/anaconda3/etc/profile.d/conda.sh
conda activate 3.8
pip install setuptools wheel twine setuptools-scm[toml]
pip install torch
pip install .[dev]
- name: Remove (old) distribution
run: rm -rf dist
- name: Build distribution
run: conda run -n 3.8 python setup.py sdist bdist_wheel
- name: Publish to Test PyPi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD_TEST }}
run: conda run -n 3.8 twine upload --repository testpypi dist/* #--skip-existing
- name: Publish to PyPi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
run: conda run -n "3.8" twine upload --repository pypi dist/* #--skip-existing
changelog:
needs: release
runs-on: ubuntu-latest
name: Update Changelog
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Create new branch
run: git checkout -b actions/changelog
- name: Set branch upstream
run: git push -u origin actions/changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install release packages
run: pip install wheel gitchangelog pystache
- name: Set variables
run: echo "VERSION=$(curl ${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/latest | python -c "import sys; import json; print(json.load(sys.stdin)['tag_name'])")" >> $GITHUB_ENV
- name: Generate newest changelog
run: gitchangelog ${{env.VERSION}} > CHANGELOG.md
- name: Make commit for auto-generated changelog
uses: EndBug/add-and-commit@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
add: "CHANGELOG.md"
branch: actions/changelog
message: "!gitchangelog"
- name: Create pull request for the auto generated changelog
run: |
echo "PR_URL=$(gh pr create \
--title "changelog: release ${{env.VERSION}}" \
--body "beep boop, i am a robot" \
--label documentation)" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Alert developer of open PR
run: echo "Changelog $PR_URL is ready to be merged by developer."