forked from mlco2/codecarbon
-
Notifications
You must be signed in to change notification settings - Fork 1
71 lines (65 loc) · 2.29 KB
/
python-publish.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
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Upload Python Package
on:
release:
types: [published]
permissions:
contents: read
jobs:
deploy-pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Check versions
run: |
pip install -U pip requests
python3 .github/check_version.py
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatch==1.13.0 hatchling==1.25.0
- name: Build package
run: hatch build -c
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
publish-to-conda:
runs-on: ubuntu-24.04
needs: [ deploy-pypi ]
steps:
- uses: actions/checkout@v4
- name: Restore build
uses: actions/cache@v4
with:
path: /tmp/conda-bld
key: build-conda-${{ github.sha }}
fail-on-cache-miss: true
- uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: codecarbon
miniforge-version: latest
python-version: 3.12
use-mamba: true
- name: Install package
shell: bash -l {0}
run: mamba install --channel file:///tmp/conda-bld --channel codecarbon codecarbon
- name: Test conda package
shell: bash -l {0}
run: codecarbon --help
- name: Conda upload already build package
# This shell is made necessary by https://github.com/conda-incubator/setup-miniconda/issues/128
shell: bash -l {0}
run: |
conda install --yes anaconda-client
anaconda -t ${{ secrets.ANACONDA_TOKEN }} upload --user codecarbon /tmp/conda-bld/noarch/codecarbon-*