|
| 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). |
0 commit comments