diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml new file mode 100644 index 000000000..627dbc24b --- /dev/null +++ b/.github/workflows/build-docs.yml @@ -0,0 +1,28 @@ +name: Build docs +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v3 + - uses: mamba-org/setup-micromamba@v2.0.3 + with: + environment-file: ./environment-dev.yml + init-shell: bash + create-args: --verbose + cache-environment: true + cache-downloads: false + + - name: "Build docs" + shell: bash -el {0} + run: | + micromamba activate ultraplot-dev + pip install . + cd docs + make html diff --git a/.github/workflows/build-ultraplot.yml b/.github/workflows/build-ultraplot.yml new file mode 100644 index 000000000..6df88c53d --- /dev/null +++ b/.github/workflows/build-ultraplot.yml @@ -0,0 +1,27 @@ +name: Build and Test +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v3 + - uses: mamba-org/setup-micromamba@v2.0.3 + with: + environment-file: ./environment-dev.yml + init-shell: bash + create-args: --verbose + cache-environment: true + cache-downloads: false + + - name: Test Ultraplot + shell: bash -el {0} + run: | + micromamba activate ultraplot-dev + pip install . + python -m pytest diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml new file mode 100644 index 000000000..66aa18b7a --- /dev/null +++ b/.github/workflows/publish-pypi.yml @@ -0,0 +1,46 @@ +name: Publish to PyPI +on: + release: + types: [published] + push: + tags: ["v*"] + +jobs: + publish-pypi-test: + runs-on: ubuntu-latest + if: github.event_name == 'push' + permissions: + id-token: write + contents: read + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Build package + run: | + python -m pip install build + python -m build + - name: Publish to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + + publish-prod: + needs: publish-test + runs-on: ubuntu-latest + if: github.event_name == 'release' + permissions: + id-token: write + contents: read + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Build package + run: | + python -m pip install build + python -m build + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/ultraplot.yml b/.github/workflows/ultraplot.yml deleted file mode 100644 index 07d73287f..000000000 --- a/.github/workflows/ultraplot.yml +++ /dev/null @@ -1,159 +0,0 @@ -name: Build and Test -on: - push: - branches: [main] - tags: ["v*"] - pull_request: - branches: [main] - release: - types: [published] -jobs: - build: - runs-on: ubuntu-latest - timeout-minutes: 15 - steps: - - uses: actions/checkout@v3 - - uses: mamba-org/setup-micromamba@v2.0.3 - with: - environment-file: ./environment-dev.yml - init-shell: >- - bash - create-args: >- - --verbose - cache-environment: true - cache-downloads: false - - - name: Test Ultraplot - shell: bash -el {0} - run: | - micromamba activate ultraplot-dev - pip install . - python -m pytest - - - name: "Build docs" - shell: bash -el {0} - run: | - micromamba activate ultraplot-dev - cd docs - make html - - publish-test: - needs: build - runs-on: ubuntu-latest - # Run on every push to main/v* branches and pull requests - if: github.event_name == 'push' || github.event_name == 'pull_request' - permissions: - id-token: write - contents: read - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.x" - - - name: Install build - run: python -m pip install build - - - name: Build package - run: python -m build - - - name: Publish to TestPyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ - - publish: - needs: [build, publish-test] - runs-on: ubuntu-latest - if: github.event_name == 'push' && contains(github.ref, 'refs/tags/v') - permissions: - # Required for trusted publishing to PyPI - id-token: write - contents: read - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.x" - - - name: Install build - run: python -m pip install build - - - name: Build package - run: python -m build - - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - - - name: Publish to Anaconda - uses: conda-incubator/setup-miniconda@v3 - with: - auto-activate-base: false - environment-file: environment-dev.yml - - - name: Install conda-build - shell: bash -l {0} - run: | - micromamba activate ultraplot-dev - micromamba install conda-build anaconda-client - - - name: Clone staged-recipes - run: git clone https://github.com/cvanelteren/staged-recipes.git - - - name: Check if recipe exists - run: | - if [ -d "staged-recipes/recipes/ultraplot" ]; then - echo "Recipe already exists. Checking version..." - RECIPE_VERSION=$(grep "version:"staged-recipes/recipes/ultraplot/meta.yaml | awk {print $2}') - PACKAGE_VERSION=$(python setup.py --version) - if [ "$RECIPE_VERSION" == "$PACKAGE_VERSION" ];then - echo "Recipe is up-to-date. Skipping." - exit 0 - fi - fi - - - name: Extract version from pyproject.toml - id: get-version - run: | - pip install tomli - python -c " - import tomli - with open('pyproject.toml', 'rb') as f: - data = tomli.load(f) - print(data['project']['version']) - " > version.txt - - - name: Generate meta.yaml - run: | - mkdir -p staged-recipes/recipes/ultraplot - cat < staged-recipes/recipes/ultraplot/meta.yaml - # Same meta.yaml generation script as above - EOF - - - name: Push changes to fork - run: | - git add staged-recipes/recipes/ultraplot - git commit -m "Update ultraplot recipe to version $(cat version.txt)" - git push origin update-ultraplot-recipe - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v5 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: "Update ultraplot recipe to version $(cat version.txt)" - branch: update-ultraplot-recipe - title: "Update ultraplot recipe" - body: | - This PR updates the ultraplot recipe to version $(cat version.txt).