Skip to content

Commit a123d57

Browse files
committed
separated workflows
1 parent 5609372 commit a123d57

File tree

3 files changed

+175
-0
lines changed

3 files changed

+175
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Build and Test
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 15
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: mamba-org/setup-micromamba@v2.0.3
15+
with:
16+
environment-file: ./environment-dev.yml
17+
init-shell: bash
18+
create-args: --verbose
19+
cache-environment: true
20+
cache-downloads: false
21+
22+
- name: Test Ultraplot
23+
shell: bash -el {0}
24+
run: |
25+
micromamba activate ultraplot-dev
26+
pip install .
27+
python -m pytest
28+
29+
- name: "Build docs"
30+
shell: bash -el {0}
31+
run: |
32+
micromamba activate ultraplot-dev
33+
cd docs
34+
make html
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Publish to Conda
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
publish-conda:
8+
needs: [build, publish-test]
9+
runs-on: ubuntu-latest
10+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/v')
11+
permissions:
12+
# Required for trusted publishing to PyPI
13+
id-token: write
14+
contents: read
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: "3.x"
26+
27+
- name: Install build
28+
run: python -m pip install build
29+
30+
- name: Build package
31+
run: python -m build
32+
33+
- name: Publish to PyPI
34+
uses: pypa/gh-action-pypi-publish@release/v1
35+
36+
- name: Publish to Anaconda
37+
uses: conda-incubator/setup-miniconda@v3
38+
with:
39+
auto-activate-base: false
40+
environment-file: environment-dev.yml
41+
42+
- name: Install conda-build
43+
shell: bash -l {0}
44+
run: |
45+
micromamba activate ultraplot-dev
46+
micromamba install conda-build anaconda-client
47+
48+
- name: Clone staged-recipes
49+
run: git clone https://github.com/cvanelteren/staged-recipes.git
50+
51+
- name: Check if recipe exists
52+
run: |
53+
if [ -d "staged-recipes/recipes/ultraplot" ]; then
54+
echo "Recipe already exists. Checking version..."
55+
RECIPE_VERSION=$(grep "version:"staged-recipes/recipes/ultraplot/meta.yaml | awk {print $2}')
56+
PACKAGE_VERSION=$(python setup.py --version)
57+
if [ "$RECIPE_VERSION" == "$PACKAGE_VERSION" ];then
58+
echo "Recipe is up-to-date. Skipping."
59+
exit 0
60+
fi
61+
fi
62+
63+
- name: Extract version from pyproject.toml
64+
id: get-version
65+
run: |
66+
pip install tomli
67+
python -c "
68+
import tomli
69+
with open('pyproject.toml', 'rb') as f:
70+
data = tomli.load(f)
71+
print(data['project']['version'])
72+
" > version.txt
73+
74+
- name: Generate meta.yaml
75+
run: |
76+
mkdir -p staged-recipes/recipes/ultraplot
77+
cat <<EOF > staged-recipes/recipes/ultraplot/meta.yaml
78+
# Same meta.yaml generation script as above
79+
EOF
80+
81+
- name: Push changes to fork
82+
run: |
83+
git add staged-recipes/recipes/ultraplot
84+
git commit -m "Update ultraplot recipe to version $(cat version.txt)"
85+
git push origin update-ultraplot-recipe
86+
87+
- name: Create Pull Request
88+
uses: peter-evans/create-pull-request@v5
89+
with:
90+
token: ${{ secrets.GITHUB_TOKEN }}
91+
commit-message: "Update ultraplot recipe to version $(cat version.txt)"
92+
branch: update-ultraplot-recipe
93+
title: "Update ultraplot recipe"
94+
body: |
95+
This PR updates the ultraplot recipe to version $(cat version.txt).
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Publish to PyPI
2+
on:
3+
release:
4+
types: [published]
5+
push:
6+
tags: ["v*"]
7+
8+
jobs:
9+
publish-pypi-test:
10+
runs-on: ubuntu-latest
11+
if: github.event_name == 'push'
12+
permissions:
13+
id-token: write
14+
contents: read
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-python@v4
18+
with:
19+
python-version: "3.x"
20+
- name: Build package
21+
run: |
22+
python -m pip install build
23+
python -m build
24+
- name: Publish to TestPyPI
25+
uses: pypa/gh-action-pypi-publish@release/v1
26+
with:
27+
repository-url: https://test.pypi.org/legacy/
28+
29+
publish-prod:
30+
needs: publish-test
31+
runs-on: ubuntu-latest
32+
if: github.event_name == 'release'
33+
permissions:
34+
id-token: write
35+
contents: read
36+
steps:
37+
- uses: actions/checkout@v3
38+
- uses: actions/setup-python@v4
39+
with:
40+
python-version: "3.x"
41+
- name: Build package
42+
run: |
43+
python -m pip install build
44+
python -m build
45+
- name: Publish to PyPI
46+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)