-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (109 loc) · 3.34 KB
/
build.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
name: package builds
on:
push:
branches:
- master
tags:
- v*
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths-ignore:
- CHANGELOG.md
- doc/**
- '!.github/workflows/build.yml'
release:
types:
- published
workflow_dispatch:
jobs:
conda:
defaults:
run:
shell: bash -l {0}
if: |
(github.event.pull_request.draft == false) ||
(github.event_name == 'workflow_dispatch') ||
(github.ref == 'refs/heads/master') ||
startsWith(github.ref, 'refs/tags/') ||
(github.event_name == 'release')
name: conda build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for all tags and branches
- name: Setup Conda Environment
uses: mamba-org/[email protected]
with:
environment-file: ./devtools/conda.recipe/build_env.yml
envrionment-name: build_env
init-shell: >-
bash
powershell
cache-downloads: true
- name: activate build env
run: micromamba activate build_env
- name: conda info
run: conda info
- name: conda list
run: conda list
- name: set pkg version
run: echo "SETUPTOOLS_SCM_PRETEND_VERSION=$(python -m setuptools_scm)" >> $GITHUB_ENV
- name: Build from local conda recipe
run: conda mambabuild -c conda-forge .
pypi:
if: |
(github.event.pull_request.draft == false) ||
(github.event_name == 'workflow_dispatch') ||
startsWith(github.ref, 'refs/tags/') ||
(github.event_name == 'release')
name: pypi build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for all tags and branches
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Cache pip
uses: actions/cache@v3
env:
# Increase this value to reset cache if ./pyproject.toml has not changed
CACHE_NUMBER: 0
with:
path: ~/.cache/pip
key: ubuntu-latest-pip-${{ env.CACHE_NUMBER }}-${{ hashFiles('pyproject.toml') }}
- name: pip installs
run: |
python -m pip install --upgrade pip
pip install setuptools setuptools_scm wheel twine build
- name: build package + create src archive (stored in dist folder)
run: |
python -m build
- uses: actions/upload-artifact@v3
with:
name: dist
path: ./dist/
- name: get sdist file
run: echo "SDIST_FILE=$(find ./dist/*.tar.gz | head -n 1)" >> $GITHUB_ENV
- name: pip dist install
run: |
pip install ${{ env.SDIST_FILE }}[all,test]
- name: run pytest
run: |
pytest
- name: set pypi test repo defaults
run: |
echo "pypi_repo=testpypi" >> $GITHUB_ENV
echo "pypi_token=${{ secrets.TESTPYPI_UPLOAD }}" >> $GITHUB_ENV
- name: set pypi main repo for release
if: github.event_name == 'release'
run: |
echo "pypi_repo=pypi" >> $GITHUB_ENV
echo "pypi_token=${{ secrets.PYPI_UPLOAD }}" >> $GITHUB_ENV
- name: pypi release
if: startsWith(github.ref, 'refs/tags/') || (github.event_name == 'release')
run: |
python -m twine upload --repository $pypi_repo dist/* -u __token__ -p $pypi_token