From 1c27b4a952fb46dfd1ceb6cc6ee47622c42ef9be Mon Sep 17 00:00:00 2001 From: shubh Date: Thu, 17 Oct 2024 17:59:05 +0200 Subject: [PATCH 01/13] workflow to publish on release --- .github/workflows/release.yml | 67 +++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9befd23 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,67 @@ +name: Publish Package and Docs + +on: + push: + branches: + - release # Trigger this workflow when a push occurs on the "release" branch + +jobs: + build_docs: + name: Build and Publish Docs to GitHub Pages + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install sphinx sphinx_rtd_theme # Install Sphinx and theme if needed + + - name: Build Sphinx Docs + run: | + cd docs + make html # Assuming docs are configured to build HTML files + + - name: Deploy docs to GitHub Pages + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/_build/html # Location of the built HTML files + + # publish_pypi: + # name: Publish to PyPI + # runs-on: ubuntu-latest + # needs: build_docs # Only run this job after docs are built and published + + # steps: + # - name: Checkout code + # uses: actions/checkout@v3 + + # - name: Set up Python + # uses: actions/setup-python@v4 + # with: + # python-version: '3.x' + + # - name: Install dependencies + # run: | + # python -m pip install --upgrade pip + # pip install build twine # Install build and twine for publishing + + # - name: Build the package + # run: | + # python -m build + + # - name: Publish to PyPI + # env: + # TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + # TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + # run: | + # python -m twine upload dist/* # Upload the package to PyPI From baf97a1c154b63fa0a7c7c0af12584423908fce8 Mon Sep 17 00:00:00 2001 From: shubh Date: Thu, 17 Oct 2024 18:10:03 +0200 Subject: [PATCH 02/13] workflow fixed --- .github/workflows/release.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9befd23..ab630cf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,19 +22,17 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt - pip install sphinx sphinx_rtd_theme # Install Sphinx and theme if needed + pip install sphinx - name: Build Sphinx Docs run: | - cd docs make html # Assuming docs are configured to build HTML files - name: Deploy docs to GitHub Pages uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./docs/_build/html # Location of the built HTML files + publish_dir: ./build/html # Location of the built HTML files # publish_pypi: # name: Publish to PyPI From 0b1b6f6f0797f09b056822c1c6e8b0a202da3ef2 Mon Sep 17 00:00:00 2001 From: shubh Date: Thu, 17 Oct 2024 18:38:30 +0200 Subject: [PATCH 03/13] release fix --- .github/workflows/publish_doc.yml | 55 ++++++++++++++++++++++++++ .github/workflows/release.yml | 65 ------------------------------- 2 files changed, 55 insertions(+), 65 deletions(-) create mode 100644 .github/workflows/publish_doc.yml delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/publish_doc.yml b/.github/workflows/publish_doc.yml new file mode 100644 index 0000000..97b245c --- /dev/null +++ b/.github/workflows/publish_doc.yml @@ -0,0 +1,55 @@ +name: Publish Docs to GitHub Pages + +on: + push: + branches: + - release # Only trigger on the release branch + +permissions: + contents: read + pages: write # Required for GitHub Pages API + id-token: write # Required for authentication + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install sphinx # Install Sphinx and theme if needed + + - name: Build Sphinx Docs + run: | + make html # Assuming your docs are configured to build HTML + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: site + path: ./build/html # Ensure this is the correct path + + deploy: + needs: build + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} # The URL for your GitHub Pages site + + steps: + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: site + + - name: Deploy to GitHub Pages + uses: actions/deploy-pages@v2 \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index ab630cf..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Publish Package and Docs - -on: - push: - branches: - - release # Trigger this workflow when a push occurs on the "release" branch - -jobs: - build_docs: - name: Build and Publish Docs to GitHub Pages - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install sphinx - - - name: Build Sphinx Docs - run: | - make html # Assuming docs are configured to build HTML files - - - name: Deploy docs to GitHub Pages - uses: peaceiris/actions-gh-pages@v4 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./build/html # Location of the built HTML files - - # publish_pypi: - # name: Publish to PyPI - # runs-on: ubuntu-latest - # needs: build_docs # Only run this job after docs are built and published - - # steps: - # - name: Checkout code - # uses: actions/checkout@v3 - - # - name: Set up Python - # uses: actions/setup-python@v4 - # with: - # python-version: '3.x' - - # - name: Install dependencies - # run: | - # python -m pip install --upgrade pip - # pip install build twine # Install build and twine for publishing - - # - name: Build the package - # run: | - # python -m build - - # - name: Publish to PyPI - # env: - # TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - # TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - # run: | - # python -m twine upload dist/* # Upload the package to PyPI From e1dad9be1b75c8804700733569bd3202047484a5 Mon Sep 17 00:00:00 2001 From: shubh Date: Thu, 17 Oct 2024 18:54:11 +0200 Subject: [PATCH 04/13] ... --- .github/workflows/publish_doc.yml | 6 +++--- setup.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish_doc.yml b/.github/workflows/publish_doc.yml index 97b245c..e444cf4 100644 --- a/.github/workflows/publish_doc.yml +++ b/.github/workflows/publish_doc.yml @@ -21,12 +21,12 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.x' + python-version: '3.12.5' - name: Install dependencies run: | python -m pip install --upgrade pip - pip install sphinx # Install Sphinx and theme if needed + pip install sphinx=7.4.7 # Install Sphinx and theme if needed - name: Build Sphinx Docs run: | @@ -47,7 +47,7 @@ jobs: steps: - name: Download artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: site diff --git a/setup.py b/setup.py index d865c58..8845b26 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='codegreen_core', - version='0.1', + version='0.5.0', include_package_data=True, package_data={ 'codegreen_core.utilities': ['country_list.json','ci_default_values.csv','model_details.json'], From 9dbe20d02699973382974863a60e1836d7ffa8b1 Mon Sep 17 00:00:00 2001 From: shubh Date: Thu, 17 Oct 2024 18:55:11 +0200 Subject: [PATCH 05/13] ... --- .github/workflows/publish_doc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_doc.yml b/.github/workflows/publish_doc.yml index e444cf4..dfe2045 100644 --- a/.github/workflows/publish_doc.yml +++ b/.github/workflows/publish_doc.yml @@ -26,7 +26,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install sphinx=7.4.7 # Install Sphinx and theme if needed + pip install sphinx==7.4.7 # Install Sphinx and theme if needed - name: Build Sphinx Docs run: | From fb942cb06976b3c34b7a65102d70862448dbac06 Mon Sep 17 00:00:00 2001 From: shubh Date: Thu, 17 Oct 2024 19:09:13 +0200 Subject: [PATCH 06/13] ... --- .github/workflows/publish_doc.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/publish_doc.yml b/.github/workflows/publish_doc.yml index dfe2045..361dc69 100644 --- a/.github/workflows/publish_doc.yml +++ b/.github/workflows/publish_doc.yml @@ -23,9 +23,18 @@ jobs: with: python-version: '3.12.5' + # Step to dynamically generate the .config file with the secret + - name: Generate .config file + run: | + echo "[codegreen]" > docs/.codegreencore.config + echo "ENTSOE_token=${{ secrets.ENTSOE_TOKEN }}" >> docs/.codegreencore.config # Add your secret here + echo "enable_energy_caching=false" >> docs/.codegreencore.config + echo "energy_redis_path=redis://localhost:6379" >> .codegreencore.config + - name: Install dependencies run: | python -m pip install --upgrade pip + pip install . pip install sphinx==7.4.7 # Install Sphinx and theme if needed - name: Build Sphinx Docs From 82cd43878dd42f2b7f8e6cc28c94a174ad9b8ccb Mon Sep 17 00:00:00 2001 From: shubh Date: Thu, 17 Oct 2024 19:12:36 +0200 Subject: [PATCH 07/13] ... --- .github/workflows/publish_doc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_doc.yml b/.github/workflows/publish_doc.yml index 361dc69..8c4960c 100644 --- a/.github/workflows/publish_doc.yml +++ b/.github/workflows/publish_doc.yml @@ -42,7 +42,7 @@ jobs: make html # Assuming your docs are configured to build HTML - name: Upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: site path: ./build/html # Ensure this is the correct path From 6d228b4cc59661d5bb888db1a71f25733e89fa04 Mon Sep 17 00:00:00 2001 From: shubh Date: Thu, 17 Oct 2024 19:23:24 +0200 Subject: [PATCH 08/13] trying to fix pipe --- .github/workflows/publish_doc.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish_doc.yml b/.github/workflows/publish_doc.yml index 8c4960c..2c8d661 100644 --- a/.github/workflows/publish_doc.yml +++ b/.github/workflows/publish_doc.yml @@ -27,10 +27,11 @@ jobs: - name: Generate .config file run: | echo "[codegreen]" > docs/.codegreencore.config - echo "ENTSOE_token=${{ secrets.ENTSOE_TOKEN }}" >> docs/.codegreencore.config # Add your secret here + echo "ENTSOE_token=${{ secrets.ENTSOE_TOKEN }}" >> docs/.codegreencore.config echo "enable_energy_caching=false" >> docs/.codegreencore.config - echo "energy_redis_path=redis://localhost:6379" >> .codegreencore.config - + - name: Verify .config file + run: | + cat docs/.codegreencore.config - name: Install dependencies run: | python -m pip install --upgrade pip @@ -39,7 +40,7 @@ jobs: - name: Build Sphinx Docs run: | - make html # Assuming your docs are configured to build HTML + make html - name: Upload artifact uses: actions/upload-artifact@v4 From 977bca2efe0540dfe599f02dd39c0b9d0de30e27 Mon Sep 17 00:00:00 2001 From: shubh Date: Thu, 17 Oct 2024 19:24:03 +0200 Subject: [PATCH 09/13] trying to fix pipe --- .github/workflows/publish_doc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_doc.yml b/.github/workflows/publish_doc.yml index 2c8d661..48b0bab 100644 --- a/.github/workflows/publish_doc.yml +++ b/.github/workflows/publish_doc.yml @@ -31,7 +31,7 @@ jobs: echo "enable_energy_caching=false" >> docs/.codegreencore.config - name: Verify .config file run: | - cat docs/.codegreencore.config + cat docs/.codegreencore.config - name: Install dependencies run: | python -m pip install --upgrade pip From d360ba10a9f02f02ac506a661e8473cfa53ee90c Mon Sep 17 00:00:00 2001 From: shubh Date: Thu, 17 Oct 2024 19:36:09 +0200 Subject: [PATCH 10/13] still fixing --- .github/workflows/publish_doc.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_doc.yml b/.github/workflows/publish_doc.yml index 48b0bab..09f8fe5 100644 --- a/.github/workflows/publish_doc.yml +++ b/.github/workflows/publish_doc.yml @@ -29,9 +29,14 @@ jobs: echo "[codegreen]" > docs/.codegreencore.config echo "ENTSOE_token=${{ secrets.ENTSOE_TOKEN }}" >> docs/.codegreencore.config echo "enable_energy_caching=false" >> docs/.codegreencore.config + - name: Generate .config file + run: | + echo "[codegreen]" > .codegreencore.config + echo "ENTSOE_token=${{ secrets.ENTSOE_TOKEN }}" >> .codegreencore.config + echo "enable_energy_caching=false" >> .codegreencore.config - name: Verify .config file run: | - cat docs/.codegreencore.config + cat .codegreencore.config - name: Install dependencies run: | python -m pip install --upgrade pip @@ -41,6 +46,8 @@ jobs: - name: Build Sphinx Docs run: | make html + - name: List files in build directory + run: ls -R ./build/html - name: Upload artifact uses: actions/upload-artifact@v4 @@ -62,4 +69,4 @@ jobs: name: site - name: Deploy to GitHub Pages - uses: actions/deploy-pages@v2 \ No newline at end of file + uses: actions/deploy-pages@v4 \ No newline at end of file From c9a06a8e3f5ba94a117c9bb87c381a31c07f862c Mon Sep 17 00:00:00 2001 From: shubh Date: Thu, 17 Oct 2024 19:40:40 +0200 Subject: [PATCH 11/13] fixxxx --- .github/workflows/publish_doc.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_doc.yml b/.github/workflows/publish_doc.yml index 09f8fe5..7cda809 100644 --- a/.github/workflows/publish_doc.yml +++ b/.github/workflows/publish_doc.yml @@ -52,7 +52,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: site + name: github-pages path: ./build/html # Ensure this is the correct path deploy: @@ -66,7 +66,7 @@ jobs: - name: Download artifact uses: actions/download-artifact@v4 with: - name: site + name: github-pages - name: Deploy to GitHub Pages uses: actions/deploy-pages@v4 \ No newline at end of file From bfac17134af97c22975f777d119fe25e27d2709b Mon Sep 17 00:00:00 2001 From: shubh Date: Thu, 17 Oct 2024 19:50:44 +0200 Subject: [PATCH 12/13] .. --- .github/workflows/publish_doc.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/publish_doc.yml b/.github/workflows/publish_doc.yml index 7cda809..091f09a 100644 --- a/.github/workflows/publish_doc.yml +++ b/.github/workflows/publish_doc.yml @@ -54,19 +54,21 @@ jobs: with: name: github-pages path: ./build/html # Ensure this is the correct path - deploy: needs: build - runs-on: ubuntu-latest + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + # Deploy to the github-pages environment environment: name: github-pages - url: ${{ steps.deployment.outputs.page_url }} # The URL for your GitHub Pages site + url: ${{ steps.deployment.outputs.page_url }} + # Specify runner + deployment step + runs-on: ubuntu-latest steps: - - name: Download artifact - uses: actions/download-artifact@v4 - with: - name: github-pages - - name: Deploy to GitHub Pages - uses: actions/deploy-pages@v4 \ No newline at end of file + id: deployment + uses: actions/deploy-pages@v4 \ No newline at end of file From 12d29e8edee2530713bcc49589d36a1a2668801c Mon Sep 17 00:00:00 2001 From: shubh Date: Thu, 17 Oct 2024 20:43:53 +0200 Subject: [PATCH 13/13] trying out a new method --- .github/workflows/publish_doc.yml | 44 ++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/.github/workflows/publish_doc.yml b/.github/workflows/publish_doc.yml index 091f09a..b74aef5 100644 --- a/.github/workflows/publish_doc.yml +++ b/.github/workflows/publish_doc.yml @@ -48,27 +48,41 @@ jobs: make html - name: List files in build directory run: ls -R ./build/html - - - name: Upload artifact - uses: actions/upload-artifact@v4 + - name: Upload static files as artifact + id: deployment + uses: actions/upload-pages-artifact@v3 # or specific "vX.X.X" version tag for this action with: - name: github-pages - path: ./build/html # Ensure this is the correct path + path: build/html/ + # - name: Upload artifact + # uses: actions/upload-artifact@v4 + # with: + # name: github-pages + # path: ./build/html # Ensure this is the correct path deploy: - needs: build - # Grant GITHUB_TOKEN the permissions required to make a Pages deployment - permissions: - pages: write # to deploy to Pages - id-token: write # to verify the deployment originates from an appropriate source - - # Deploy to the github-pages environment environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} - - # Specify runner + deployment step runs-on: ubuntu-latest + needs: build steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 \ No newline at end of file + uses: actions/deploy-pages@v4 + # deploy: + # needs: build + # # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + # permissions: + # pages: write # to deploy to Pages + # id-token: write # to verify the deployment originates from an appropriate source + + # # Deploy to the github-pages environment + # environment: + # name: github-pages + # url: ${{ steps.deployment.outputs.page_url }} + + # # Specify runner + deployment step + # runs-on: ubuntu-latest + # steps: + # - name: Deploy to GitHub Pages + # id: deployment + # uses: actions/deploy-pages@v4 \ No newline at end of file