Repository navigation
152 lines (129 loc) · 4.5 KB
/
Copy pathpython-package-conda.yml
File metadata and controls
152 lines (129 loc) · 4.5 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
142
143
144
145
146
147
148
149
150
151
152
name: Python Package using Conda
on: [push]
env:
PKG_NAME: garnet
MODULE_NAME: garnet
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Miniconda with garnet environment
uses: conda-incubator/setup-miniconda@v3
with:
python-version: 3.13
environment-file: environment.yml
activate-environment: garnet
- name: Install package in editable mode
shell: bash -l {0} # activate conda environment
run: |
python -m pip install -e .
- name: Run tests with pytest
shell: bash -l {0} # ensures conda environment is active
run: |
pytest
conda-build:
name: Build conda package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Miniconda for conda-build
uses: conda-incubator/setup-miniconda@v3
with:
python-version: 3.13
channels: conda-forge
auto-update-conda: true
- name: Install conda-build
shell: bash -l {0}
run: conda install -y conda-build anaconda-client
- name: Compute package version
shell: bash -l {0}
run: |
set -e
pip install versioningit
PKG_VERSION=$(python -m versioningit .)
echo "Computed package version: ${PKG_VERSION}"
if [ -z "${PKG_VERSION}" ]; then
echo "Failed to compute package version with versioningit" >&2
exit 1
fi
echo "PKG_VERSION=${PKG_VERSION}" >> "$GITHUB_ENV"
- name: Build conda package
shell: bash -l {0}
run: |
cat > /tmp/conda-variant.yaml <<EOF
version:
- "${PKG_VERSION}"
EOF
conda-build conda.recipe \
-c conda-forge -c mantid/label/nightly -c oncat \
--variant-config-files /tmp/conda-variant.yaml \
--output-folder /tmp/local-channel
- name: Install conda package
id: install
uses: neutrons/gh-actions/pkg-install@eb7a7c6fcfd0cda1a7b238329afc0afd09a4f4af # v2
with:
package-name: ${{ env.PKG_NAME }}
local-channel: /tmp/local-channel
extra-channels: mantid/label/nightly oncat
python-version: "3.13"
- name: Verify conda package
uses: neutrons/gh-actions/pkg-verify@eb7a7c6fcfd0cda1a7b238329afc0afd09a4f4af # v2
with:
package-name: ${{ env.PKG_NAME }}
module-name: ${{ env.MODULE_NAME }}
conda-env-name: ${{ steps.install.outputs.conda-env }}
- name: Upload conda package as artifact
uses: actions/upload-artifact@v4
with:
name: artifact-conda-package
path: /tmp/local-channel/noarch/${{ env.PKG_NAME }}-*.conda
publish:
name: Upload package to anaconda
runs-on: ubuntu-latest
needs: [build-linux, conda-build]
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Set up Miniconda for publishing
uses: conda-incubator/setup-miniconda@v3
with:
python-version: 3.13
channels: conda-forge
auto-update-conda: true
- name: Install pixi
shell: bash
run: |
curl -fsSL https://pixi.sh/install.sh | bash
echo "$HOME/.pixi/bin" >> "$GITHUB_PATH"
- name: Verify pixi
shell: bash
run: pixi --version
- name: Install anaconda-client
shell: bash -l {0}
run: |
conda install -y anaconda-client
echo "$CONDA_PREFIX/bin" >> "$GITHUB_PATH"
- name: Download conda package artifact
uses: actions/download-artifact@v4
with:
name: artifact-conda-package
- name: Upload package to anaconda
uses: neutrons/gh-actions/publish@eb7a7c6fcfd0cda1a7b238329afc0afd09a4f4af # v2
with:
anaconda-token: ${{ secrets.ANACONDA_TOKEN }}
organization: neutrons
package-path: ${{ env.PKG_NAME }}-*.conda
label: ${{ github.ref == 'refs/heads/main' && 'dev' || '' }}
- name: Remove old packages
if: github.ref == 'refs/heads/main'
uses: neutrons/gh-actions/pkg-remove@eb7a7c6fcfd0cda1a7b238329afc0afd09a4f4af # v2
with:
anaconda-token: ${{ secrets.ANACONDA_TOKEN }}
organization: neutrons
package-name: ${{ env.PKG_NAME }}
label: dev
keep: 5