-
Notifications
You must be signed in to change notification settings - Fork 70
136 lines (136 loc) · 4.69 KB
/
main.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
name: Build and test the package
on:
push:
branches:
- master
tags:
- '*'
pull_request:
branches:
- master
defaults:
run:
shell: bash
jobs:
testbed:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest,macos-latest,windows-latest]
steps:
- name: Retrieve the source code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- id: conda-root
name: Set CONDA_ROOT
run: |
CONDA_ROOT=$(dirname $GITHUB_WORKSPACE)/conda
echo "::set-output name=value::$CONDA_ROOT"
echo "CONDA_ROOT=$CONDA_ROOT" >> $GITHUB_ENV
echo "CONDA_ROOT: $CONDA_ROOT"
# Use a smaller cache entry to enable a quicker exit if we
# have already built the testbed. Any small file will do
- id: cache-key
name: Retrieve cache key
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4
with:
path: ./LICENSE
key: key-${{ matrix.os }}-${{ hashFiles('testbed') }}
- id: cache
name: Retrieve or create the conda cache
if: steps.cache-key.outputs.cache-hit != 'true'
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4
with:
path: ${{ steps.conda-root.outputs.value }}
key: testbed-${{ matrix.os }}-${{ hashFiles('testbed') }}
- name: Verify or build the testbed
if: steps.cache-key.outputs.cache-hit != 'true'
# The argument tells the script we are in caching mode
run: testbed/build.sh
build:
runs-on: ubuntu-latest
steps:
- name: Retrieve the source code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Build the package
id: build
run: |
source $CONDA/etc/profile.d/conda.sh
conda install conda conda-build --yes
conda build --no-test conda-recipe
mv $CONDA/conda-bld .
- name: Upload the build artifact
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4
with:
name: package-${{ github.sha }}
path: conda-bld/*/*.tar.bz2
tests:
runs-on: ${{ matrix.os }}
needs: [build,testbed]
strategy:
fail-fast: false
matrix:
os: [macos-latest,ubuntu-latest,windows-latest]
pyver: ["3.8","3.10","3.12"]
steps:
- name: Retrieve the source code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- id: conda-root
name: Set CONDA_ROOT and artifact suffix
run: |
if [ "$RUNNER_OS" = "Windows" ]; then sfx=win; else sfx=unx; fi
echo "::set-output name=suffix::$sfx"
CONDA_ROOT=$(dirname $GITHUB_WORKSPACE)/conda
echo "::set-output name=value::$CONDA_ROOT"
echo "CONDA_ROOT=$CONDA_ROOT" >> $GITHUB_ENV
echo "PACKAGE SUFFIX: $sfx"
echo "CONDA_ROOT: $CONDA_ROOT"
- name: Retrieve the build artfiact
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4
with:
name: package-${{ github.sha }}
path: conda-bld
- name: Retrieve the testbed
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4
with:
path: ${{ steps.conda-root.outputs.value }}
key: testbed-${{ matrix.os }}-${{ hashFiles('testbed') }}
- name: Verify the testbed
run: testbed/build.sh
- name: Test the package
run: |
source $CONDA_ROOT/etc/profile.d/conda.sh
[ "$RUNNER_OS" = "Windows" ] && export PYTHONIOENCODING=UTF-8
export PYTHONUNBUFFERED=1
conda build --test conda-bld/noarch/*.tar.bz2 | tee build.log
# Because Windows refuses to preserve the error code
if grep ' FAILED ' build.log; then exit -1; fi
upload:
needs: tests
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Retrieve the source code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Retrieve the artfiact
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4
with:
name: package-${{ github.sha }}
path: conda-bld
- name: Upload to anaconda.org
env:
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
source $CONDA/bin/activate
conda install -y anaconda-client
git describe --exact-match --tags HEAD || export LABEL="--label dev"
anaconda --verbose --token $ANACONDA_TOKEN upload --user jupycon $LABEL conda-bld/*/*.tar.bz2 --force
- name: Clean up older artifacts
uses: glassechidna/artifact-cleaner@master
with:
minimumAge: 86400