forked from neutrons/python_project_template
-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (122 loc) · 3.69 KB
/
test_and_deploy.yaml
File metadata and controls
141 lines (122 loc) · 3.69 KB
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
name: Tests, Package, and Deployment
on:
workflow_dispatch:
pull_request:
push:
branches: [next, qa, main]
tags: ["v*"]
env:
PKG_NAME: examplepyapp
MODULE_NAME: packagenamepy
jobs:
tests:
name: Unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
fetch-tags: true
- name: Setup pixi
uses: prefix-dev/setup-pixi@v0.9.0
with:
pixi-version: v0.50.2
manifest-path: pyproject.toml
- name: Run unit tests
run: pixi run test
- name: Upload coverage to codecov
uses: codecov/codecov-action@v5
if: github.actor != 'dependabot[bot]'
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Dependency check
run: |
pixi run audit-deps
conda-build:
name: Build conda package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
fetch-tags: true
- name: Setup pixi
uses: prefix-dev/setup-pixi@v0.9.0
with:
pixi-version: v0.50.2
manifest-path: pyproject.toml
- name: Build conda package
run: |
pixi run conda-build
mkdir -p /tmp/local-channel/linux-64
cp *.conda /tmp/local-channel/linux-64
- name: Verify conda package
uses: neutrons/conda-verify@main
with:
package-name: ${{ env.PKG_NAME }}
module-name: ${{ env.MODULE_NAME }}
local-channel: /tmp/local-channel
- name: Upload conda package as artifact
uses: actions/upload-artifact@v4
with:
name: artifact-conda-package
path: ${{ env.PKG_NAME }}-*.conda
publish:
name: Upload package to anaconda
runs-on: ubuntu-latest
needs: [tests, conda-build]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Pixi
uses: prefix-dev/setup-pixi@v0.9.0
with:
pixi-version: v0.50.2
manifest-path: pyproject.toml
- name: Download conda package artifact
uses: actions/download-artifact@v5
with:
name: artifact-conda-package
- name: Upload package to anaconda
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
IS_RC: ${{ contains(github.ref, 'rc') }}
run: |
# label is main or rc depending on the tag-name
CONDA_LABEL="main"
if [ "${IS_RC}" = "true" ]; then CONDA_LABEL="rc"; fi
echo pushing ${{ github.ref }} with label $CONDA_LABEL
pixi run anaconda upload --label $CONDA_LABEL --user neutrons ${{ env.PKG_NAME }}-*.conda
pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
needs: tests
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
fetch-tags: true
- name: Setup pixi
uses: prefix-dev/setup-pixi@v0.9.0
with:
pixi-version: v0.50.2
manifest-path: pyproject.toml
- name: Build pypi package
run: |
# build the package
VERSION=$(pixi run -- versioningit .)
pixi run pypi-build
# publish your distributions here (need to setup on PyPI first)
- name: Publish package distributions to PyPI
if: startsWith(github.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@release/v1