-
Notifications
You must be signed in to change notification settings - Fork 3
54 lines (48 loc) · 1.25 KB
/
build_and_publish.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
name: Build and upload to PyPI
on:
pull_request:
push:
branches:
- 'main'
tags:
- 'v*'
release:
types:
- published
jobs:
build_artifacts:
name: Build artifacts
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: mamba-org/setup-micromamba@8767fb704bd78032e9392f0386bf46950bdd1194
with:
environment-file: environment.yml
- name: Build
shell: bash -l {0}
# It seems as though flit publish expects a .pypirc file as compared to
# only a token passed as an argument.
# See https://flit.pypa.io/en/latest/cmdline.html#flit-publish
run: |
flit build
- uses: actions/upload-artifact@v4
with:
path: dist/*
upload_pypi:
name: Upload to PyPI
needs: [build_artifacts]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@v1.8.11
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}