forked from spacetelescope/stenv
-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (114 loc) · 3.85 KB
/
build.yaml
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
name: build
on:
workflow_call:
inputs:
export:
type: boolean
required: false
default: false
outputs:
date:
value: ${{ jobs.date.outputs.date }}
workflow_dispatch:
inputs:
upload_to_release:
description: upload exported files to a release of the current tag
required: false
type: boolean
default: false
push:
release:
types:
- published
concurrency:
group: build-${{ github.ref }}
defaults:
run:
shell: micromamba-shell {0}
jobs:
date:
runs-on: ubuntu-latest
steps:
- run: echo "date=$(date +%Y-%m-%d)" >> $GITHUB_OUTPUT
id: date
shell: bash
outputs:
date: ${{ steps.date.outputs.date }}
build:
needs: [ date ]
strategy:
fail-fast: false
matrix:
runs-on: [ ubuntu-latest, macos-latest ]
python-version: [ '3.9', '3.10', '3.11' ]
runs-on: ${{ matrix.runs-on }}
name: build (Python ${{ matrix.python-version }}, ${{ matrix.runs-on }})
steps:
- uses: actions/checkout@v4
- uses: mamba-org/setup-micromamba@v1
with:
environment-name: stenv-${{ runner.os }}-py${{ matrix.python-version }}
environment-file: environment.yaml
create-args: >-
python=${{ matrix.python-version }}
conda
cache-downloads: true
cache-downloads-key: downloads-${{ needs.date.outputs.date }}
cache-environment: true
cache-environment-key: environment-${{ needs.date.outputs.date }}
init-shell: none
generate-run-shell: true
- run: conda env export --no-build | grep -v "name:" | grep -v "prefix:"
- run: pytest -n auto tests/test_import.py
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- uses: mtkennerly/dunamai-action@v1
id: version
with:
args: --pattern "(?P<base>\d+\.\d+\.\d+)"
export:
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' || github.event_name == 'release' || inputs.export == 'true'
needs: [ build, version, date ]
strategy:
fail-fast: false
matrix:
runs-on: [ ubuntu-latest, macos-latest ]
python-version: [ '3.9', '3.10', '3.11' ]
runs-on: ${{ matrix.runs-on }}
name: export (Python ${{ matrix.python-version }}, ${{ matrix.runs-on }})
steps:
- uses: actions/checkout@v4
- uses: mamba-org/setup-micromamba@v1
with:
environment-name: stenv-${{ runner.os }}-py${{ matrix.python-version }}
environment-file: environment.yaml
create-args: >-
python=${{ matrix.python-version }}
conda
cache-downloads: true
cache-downloads-key: downloads-${{ needs.date.outputs.date }}
cache-environment: true
cache-environment-key: environment-${{ needs.date.outputs.date }}
init-shell: none
generate-run-shell: true
- run: echo "filename=stenv-${{ runner.os }}-${{ runner.arch }}-py${{ matrix.python-version }}-${{ needs.version.outputs.version }}.yaml" >> $GITHUB_OUTPUT
id: output
- run: conda env export --no-build | grep -v "name:" | grep -v "prefix:" > ${{ steps.output.outputs.filename }}
- run: cat ${{ steps.output.outputs.filename }}
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.output.outputs.filename }}
path: ${{ steps.output.outputs.filename }}
- if: (github.event_name == 'release' && github.event.action == 'published')
uses: svenstaro/upload-release-action@v2
with:
file: ${{ steps.output.outputs.filename }}