Repository navigation
84 lines (83 loc) · 2.82 KB
/
Copy pathpython-package-deploy.yml
File metadata and controls
84 lines (83 loc) · 2.82 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
---
# Inspired from:
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
name: Publish to PyPI and Anaconda
on:
push:
branches: [main, develop]
tags: ['v*', '*.*.*']
jobs:
build-n-publish:
name: Publish to PyPI and Anaconda
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Set version
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION="${GITHUB_REF#refs/tags/}"
VERSION="${VERSION#v}"
else
# Dev builds for TestPyPI / legacy LCA channel only; not published to PyPI
VERSION="0.1.0.dev$(git rev-list --count HEAD)"
fi
echo "BW_FUNCTIONAL_VERSION=${VERSION}" >> "$GITHUB_ENV"
echo "Using version ${VERSION}"
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--outdir dist/
.
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/')
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: false
- name: Set up Conda 3.11
uses: conda-incubator/setup-miniconda@v3
with:
python-version: 3.11
activate-environment: build
environment-file: .github/environments/build.yml
# DEPRECATED: Private LCA Anaconda channel upload. Prefer conda-forge once the
# feedstock is live. Kept temporarily so existing LCA-channel users keep working.
# continue-on-error: do not fail the release job if only the legacy channel breaks.
# Use the conda-build CLI (not `conda build`): modern conda no longer exposes
# build as a subcommand unless the plugin is installed in base.
- name: Build a Conda tarball
continue-on-error: true
id: conda_build
run: |
PKG="$(conda-build -c conda-forge -c cmutel ./recipe/ --output)"
conda-build -c conda-forge -c cmutel ./recipe/
echo "Built package: ${PKG}"
ls -la "${PKG}"
echo "CONDA_PKG_PATH=${PKG}" >> "$GITHUB_ENV"
- name: Publish to Anaconda (deprecated; use conda-forge)
if: steps.conda_build.outcome == 'success'
continue-on-error: true
run: |
anaconda -t ${{ secrets.CONDA_LCA }} upload --user lca "${CONDA_PKG_PATH}"