diff --git a/.github/workflows/api_build_publish.yml b/.github/workflows/api_build_publish.yml new file mode 100644 index 0000000..4d2f8c8 --- /dev/null +++ b/.github/workflows/api_build_publish.yml @@ -0,0 +1,239 @@ +name: Publish API Docker images and create a release + +on: + workflow_dispatch: + inputs: + bump: + description: "Bump the version of the API" + type: choice + required: true + default: "patch" + options: + - "patch" + - "minor" + - "major" + - "prepatch" + - "preminor" + - "premajor" +env: + DRAFT: ${{ contains(inputs.bump, 'pre') }} + +jobs: + python_project: + name: Build ecoindex API python project + runs-on: ubuntu-latest + outputs: + wheel: ${{ steps.wheel.outputs.wheel }} + api_version: ${{ steps.version.outputs.api_version }} + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install Task + uses: arduino/setup-task@v2 + with: + version: 3.x + + - name: Install poetry + uses: abatilo/actions-poetry@v2 + + - name: Install poetry build project + run: pip install poetry-multiproject-plugin + + - name: Bump version + run: task api:bump -- ${{ github.event.inputs.bump }} + + - name: Build + run: task api:poetry:build + + - name: Upload version to artifacts + uses: actions/upload-artifact@v4 + with: + name: version + path: bases/ecoindex/backend/VERSION + + - name: Upload pyproject.toml to artifacts + uses: actions/upload-artifact@v4 + with: + name: pyproject + path: projects/ecoindex_api/pyproject.toml + + - name: Upload dist folder + uses: actions/upload-artifact@v4 + with: + name: dist + path: projects/ecoindex_api/dist + + - name: Output version + id: version + run: echo "api_version=$(task api:poetry:version-short)" >> $GITHUB_OUTPUT + + - name: Output wheel + id: wheel + run: echo "wheel=ecoindex_api-${{ steps.version.outputs.api_version }}-py3-none-any.whl" >> $GITHUB_OUTPUT + + - name: Output summary + run: | + echo "API version ${{ steps.version.outputs.api_version }}" >> $GITHUB_STEP_SUMMARY + echo "Wheel ${{ steps.wheel.outputs.wheel }}" >> $GITHUB_STEP_SUMMARY + + backend_image: + name: Build and push backend image to docker hub + runs-on: ubuntu-latest + needs: python_project + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Download dist from artifacts + uses: actions/download-artifact@v4 + with: + name: dist + path: projects/ecoindex_api/dist + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: vvatelot/ecoindex-api-backend + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: projects/ecoindex_api + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }},vvatelot/ecoindex-api-backend:${{ needs.python_project.outputs.api_version }},${{ !env.DRAFT && 'vvatelot/ecoindex-api-backend:latest' || '' }} + labels: ${{ steps.meta.outputs.labels }} + file: projects/ecoindex_api/docker/backend/dockerfile + build-args: wheel=${{ needs.python_project.outputs.wheel }} + + worker_image: + name: Build and push worker image to docker hub + runs-on: ubuntu-latest + needs: python_project + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Download dist from artifacts + uses: actions/download-artifact@v4 + with: + name: dist + path: projects/ecoindex_api/dist + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: vvatelot/ecoindex-api-worker + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: projects/ecoindex_api + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }},vvatelot/ecoindex-api-worker:${{ needs.python_project.outputs.api_version }} + labels: ${{ steps.meta.outputs.labels }} + file: projects/ecoindex_api/docker/worker/dockerfile + build-args: wheel=${{ needs.python_project.outputs.wheel }} + + release: + name: Create a release + runs-on: ubuntu-latest + needs: [python_project, backend_image, worker_image] + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Git pull + run: git pull + + - name: Download pyproject.toml to a temporary file + uses: actions/download-artifact@v4 + with: + name: pyproject + path: /tmp + + - name: Download VERSION to a temporary file + uses: actions/download-artifact@v4 + with: + name: version + path: /tmp + + - name: Copy and overwrite existing files to the repo + run: | + cp /tmp/pyproject.toml projects/ecoindex_api/pyproject.toml + cp /tmp/VERSION bases/ecoindex/backend/VERSION + + - name: Commit files + uses: EndBug/add-and-commit@v9 + with: + message: "chore(api): Bump API version to ${{ needs.python_project.outputs.api_version }}" + tag: v${{ needs.python_project.outputs.api_version }}@api + tag_push: "--force" + push: true + + - name: Get last tag (that is not a `pre` tag) for api + id: last_tag + run: echo "last_tag=$(git tag --list | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+@api$' | sort -r | head -n 1)" >> $GITHUB_OUTPUT + + - name: Update CHANGELOG + id: changelog + uses: requarks/changelog-action@v1 + with: + token: ${{ github.token }} + fromTag: v${{ needs.python_project.outputs.api_version }}@api + toTag: ${{ steps.last_tag.outputs.last_tag }} + excludeScopes: cli,scraper,compute + changelogFilePath: /tmp/changelog.md + + - name: Update changelog content with dockerhub links + run: | + echo "" >> /tmp/changelog.md + echo "### Docker images" >> /tmp/changelog.md + echo "" >> /tmp/changelog.md + echo "Docker images have been built and pushed to Docker Hub. You can find them here:" >> /tmp/changelog.md + echo "- **Backend**: [vvatelot/ecoindex-api-backend:${{ needs.python_project.outputs.api_version }}](https://hub.docker.com/r/vvatelot/ecoindex-api-backend/tags?page=1&name=${{ needs.python_project.outputs.api_version }})" >> /tmp/changelog.md + echo "- **Worker**: [vvatelot/ecoindex-api-worker:${{ needs.python_project.outputs.api_version }}](https://hub.docker.com/r/vvatelot/ecoindex-api-worker/tags?page=1&name=${{ needs.python_project.outputs.api_version }})" >> /tmp/changelog.md + + - name: Create Release + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + draft: ${{ env.DRAFT }} + makeLatest: true + name: "API: v${{ needs.python_project.outputs.api_version }}" + tag: v${{ needs.python_project.outputs.api_version }}@api + token: ${{ github.token }} + bodyFile: /tmp/changelog.md diff --git a/.github/workflows/api_build_publish_docker_hub.yml b/.github/workflows/api_build_publish_docker_hub.yml deleted file mode 100644 index 444f05a..0000000 --- a/.github/workflows/api_build_publish_docker_hub.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Publish API Docker images - -on: - workflow_dispatch: - -jobs: - backend_image: - name: Build and push backend image to docker hub - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: vvatelot/ecoindex-api-backend - - - name: Build and push - uses: docker/build-push-action@v4 - with: - context: . - platforms: linux/amd64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - file: projects/ecoindex_api/docker/backend/dockerfile - - worker_image: - name: Build and push worker image to docker hub - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: vvatelot/ecoindex-api-worker - - - name: Build and push - uses: docker/build-push-action@v4 - with: - context: . - platforms: linux/amd64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - file: projects/ecoindex_api/docker/worker/dockerfile - \ No newline at end of file diff --git a/.github/workflows/cli_build_publish.yml b/.github/workflows/cli_build_publish.yml new file mode 100644 index 0000000..3faaf25 --- /dev/null +++ b/.github/workflows/cli_build_publish.yml @@ -0,0 +1,240 @@ +name: Publish CLI Docker image, pypi package and create a release + +on: + workflow_dispatch: + inputs: + bump: + description: "Bump the version of the CLI" + type: choice + required: true + default: "patch" + options: + - "patch" + - "minor" + - "major" + - "prepatch" + - "preminor" + - "premajor" +env: + DRAFT: ${{ contains(inputs.bump, 'pre') }} + +jobs: + python_project: + name: Build ecoindex CLI python project + runs-on: ubuntu-latest + outputs: + wheel: ${{ steps.wheel.outputs.wheel }} + cli_version: ${{ steps.version.outputs.cli_version }} + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install Task + uses: arduino/setup-task@v2 + with: + version: 3.x + + - name: Install poetry + uses: abatilo/actions-poetry@v2 + + - name: Install poetry build project + run: pip install poetry-multiproject-plugin + + - name: Bump version + run: task cli:bump -- ${{ github.event.inputs.bump }} + + - name: Build + run: task cli:poetry:build + + - name: Upload version to artifacts + uses: actions/upload-artifact@v4 + with: + name: version + path: bases/ecoindex/cli/VERSION + + - name: Upload pyproject.toml to artifacts + uses: actions/upload-artifact@v4 + with: + name: pyproject + path: projects/ecoindex_cli/pyproject.toml + + - name: Upload dist folder + uses: actions/upload-artifact@v4 + with: + name: dist + path: projects/ecoindex_cli/dist + + - name: Output version + id: version + run: echo "cli_version=$(task cli:poetry:version-short)" >> $GITHUB_OUTPUT + + - name: Output wheel + id: wheel + run: echo "wheel=ecoindex_cli-${{ steps.version.outputs.cli_version }}-py3-none-any.whl" >> $GITHUB_OUTPUT + + - name: Output summary + run: | + echo "CLI version ${{ steps.version.outputs.cli_version }}" >> $GITHUB_STEP_SUMMARY + echo "Wheel ${{ steps.wheel.outputs.wheel }}" >> $GITHUB_STEP_SUMMARY + + docker_image: + name: Build and push CLI image to docker hub + runs-on: ubuntu-latest + needs: python_project + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Download dist from artifacts + uses: actions/download-artifact@v4 + with: + name: dist + path: projects/ecoindex_cli/dist + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: vvatelot/ecoindex-cli + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: projects/ecoindex_cli + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }},vvatelot/ecoindex-cli:${{ needs.python_project.outputs.cli_version }} + labels: ${{ steps.meta.outputs.labels }} + file: projects/ecoindex_cli/dockerfile + build-args: wheel=${{ needs.python_project.outputs.wheel }} + + pypi_package: + name: Build and push CLI pypi package + runs-on: ubuntu-latest + needs: python_project + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Install Task + uses: arduino/setup-task@v2 + with: + version: 3.x + + - name: Download dist from artifacts + uses: actions/download-artifact@v4 + with: + name: dist + path: projects/ecoindex_cli/dist + + - name: Download pyproject.toml from artifacts + uses: actions/download-artifact@v4 + with: + name: pyproject + path: /tmp + + - name: Copy pyproject.toml to the project + run: cp /tmp/pyproject.toml projects/ecoindex_cli/pyproject.toml + + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install poetry + uses: abatilo/actions-poetry@v2 + + - name: Login to Pypi + run: poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} + + - name: Publish + run: task cli:pypi:publish + + release: + name: Create a release + runs-on: ubuntu-latest + needs: [python_project, docker_image, pypi_package] + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Git pull + run: git pull + + - name: Download pyproject.toml to a temporary file + uses: actions/download-artifact@v4 + with: + name: pyproject + path: /tmp + + - name: Download VERSION to a temporary file + uses: actions/download-artifact@v4 + with: + name: version + path: /tmp + + - name: Copy and overwrite existing files to the repo + run: | + cp /tmp/pyproject.toml projects/ecoindex_cli/pyproject.toml + cp /tmp/VERSION bases/ecoindex/cli/VERSION + + - name: Commit files + uses: EndBug/add-and-commit@v9 + with: + message: "chore(cli): Bump CLI version to ${{ needs.python_project.outputs.cli_version }}" + tag: v${{ needs.python_project.outputs.cli_version }}@cli + tag_push: "--force" + push: true + + - name: Get last tag (that is not a `pre` tag) for CLI + id: last_tag + run: echo "last_tag=$(git tag --list | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+@cli$' | sort -r | head -n 1)" >> $GITHUB_OUTPUT + + - name: Update CHANGELOG + id: changelog + uses: requarks/changelog-action@v1 + with: + token: ${{ github.token }} + fromTag: v${{ needs.python_project.outputs.cli_version }}@cli + toTag: ${{ steps.last_tag.outputs.last_tag }} + excludeScopes: api,scraper,compute + changelogFilePath: /tmp/changelog.md + + - name: Update changelog content with dockerhub links + run: | + echo "" >> /tmp/changelog.md + echo "### Docker image" >> /tmp/changelog.md + echo "" >> /tmp/changelog.md + echo "Docker image have been built and pushed to Docker Hub: [vvatelot/ecoindex-api-backend:${{ needs.python_project.outputs.cli_version }}](https://hub.docker.com/r/vvatelot/ecoindex-cli/tags?page=1&name=${{ needs.python_project.outputs.cli_version }})" >> /tmp/changelog.md + echo "" >> /tmp/changelog.md + echo "### Pypi package" >> /tmp/changelog.md + echo "" >> /tmp/changelog.md + echo "Pypi package have been built and pushed to Pypi: [ecoindex-cli:${{ needs.python_project.outputs.cli_version }}](https://pypi.org/project/ecoindex-cli/${{ needs.python_project.outputs.cli_version }}/)" >> /tmp/changelog.md + + - name: Create Release + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + draft: ${{ env.DRAFT }} + makeLatest: true + name: "CLI: v${{ needs.python_project.outputs.cli_version }}" + tag: v${{ needs.python_project.outputs.cli_version }}@cli + token: ${{ github.token }} + bodyFile: /tmp/changelog.md diff --git a/.github/workflows/cli_build_publish_docker_hub.yml b/.github/workflows/cli_build_publish_docker_hub.yml deleted file mode 100644 index d0d6d22..0000000 --- a/.github/workflows/cli_build_publish_docker_hub.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Publish Docker image - -on: - workflow_dispatch: - -jobs: - push_to_registry: - name: Push Docker image to Docker Hub - runs-on: ubuntu-latest - environment: production_cli - steps: - - name: Check out the repo - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: vvatelot/ecoindex-cli - - - name: Build and push - uses: docker/build-push-action@v4 - with: - context: . - platforms: linux/amd64,linux/arm64,linux/arm/v7 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - file: projects/ecoindex_cli/dockerfile \ No newline at end of file diff --git a/.github/workflows/compute_build_publish.yml b/.github/workflows/compute_build_publish.yml new file mode 100644 index 0000000..daccbd0 --- /dev/null +++ b/.github/workflows/compute_build_publish.yml @@ -0,0 +1,193 @@ +name: Publish compute pypi package and create a release + +on: + workflow_dispatch: + inputs: + bump: + description: "Bump the version of the compute" + type: choice + required: true + default: "patch" + options: + - "patch" + - "minor" + - "major" + - "prepatch" + - "preminor" + - "premajor" +env: + DRAFT: ${{ contains(inputs.bump, 'pre') }} + +jobs: + python_project: + name: Build ecoindex compute python project + runs-on: ubuntu-latest + outputs: + wheel: ${{ steps.wheel.outputs.wheel }} + compute_version: ${{ steps.version.outputs.compute_version }} + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install Task + uses: arduino/setup-task@v2 + with: + version: 3.x + + - name: Install poetry + uses: abatilo/actions-poetry@v2 + + - name: Install poetry build project + run: pip install poetry-multiproject-plugin + + - name: Bump version + run: task compute:bump -- ${{ github.event.inputs.bump }} + + - name: Build + run: task compute:poetry:build + + - name: Upload version to artifacts + uses: actions/upload-artifact@v4 + with: + name: version + path: components/ecoindex/compute/VERSION + + - name: Upload pyproject.toml to artifacts + uses: actions/upload-artifact@v4 + with: + name: pyproject + path: projects/ecoindex_compute/pyproject.toml + + - name: Upload dist folder + uses: actions/upload-artifact@v4 + with: + name: dist + path: projects/ecoindex_compute/dist + + - name: Output version + id: version + run: echo "compute_version=$(task compute:poetry:version-short)" >> $GITHUB_OUTPUT + + - name: Output wheel + id: wheel + run: echo "wheel=ecoindex_compute-${{ steps.version.outputs.compute_version }}-py3-none-any.whl" >> $GITHUB_OUTPUT + + - name: Output summary + run: | + echo "Compute version ${{ steps.version.outputs.compute_version }}" >> $GITHUB_STEP_SUMMARY + echo "Wheel ${{ steps.wheel.outputs.wheel }}" >> $GITHUB_STEP_SUMMARY + + pypi_package: + name: Build and push compute pypi package + runs-on: ubuntu-latest + needs: python_project + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Install Task + uses: arduino/setup-task@v2 + with: + version: 3.x + + - name: Download dist from artifacts + uses: actions/download-artifact@v4 + with: + name: dist + path: projects/ecoindex_compute/dist + + - name: Download pyproject.toml from artifacts + uses: actions/download-artifact@v4 + with: + name: pyproject + path: /tmp + + - name: Copy pyproject.toml to the project + run: cp /tmp/pyproject.toml projects/ecoindex_compute/pyproject.toml + + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install poetry + uses: abatilo/actions-poetry@v2 + + - name: Login to Pypi + run: poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} + + - name: Publish + run: task compute:pypi:publish + + release: + name: Create a release + runs-on: ubuntu-latest + needs: [python_project, pypi_package] + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Git pull + run: git pull + + - name: Download pyproject.toml to a temporary file + uses: actions/download-artifact@v4 + with: + name: pyproject + path: /tmp + + - name: Download VERSION to a temporary file + uses: actions/download-artifact@v4 + with: + name: version + path: /tmp + + - name: Copy and overwrite existing files to the repo + run: | + cp /tmp/pyproject.toml projects/ecoindex_compute/pyproject.toml + cp /tmp/VERSION components/ecoindex/compute/VERSION + + - name: Commit files + uses: EndBug/add-and-commit@v9 + with: + message: "chore(compute): Bump compute version to ${{ needs.python_project.outputs.compute_version }}" + tag: v${{ needs.python_project.outputs.compute_version }}@compute + tag_push: "--force" + push: true + + - name: Get last tag (that is not a `pre` tag) for compute + id: last_tag + run: echo "last_tag=$(git tag --list | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+@compute$' | sort -r | head -n 1)" >> $GITHUB_OUTPUT + + - name: Update CHANGELOG + id: changelog + uses: requarks/changelog-action@v1 + with: + token: ${{ github.token }} + fromTag: v${{ needs.python_project.outputs.compute_version }}@compute + toTag: ${{ steps.last_tag.outputs.last_tag }} + excludeScopes: api,cli,compute + changelogFilePath: /tmp/changelog.md + + - name: Update changelog content with dockerhub links + run: | + echo "" >> /tmp/changelog.md + echo "### Pypi package" >> /tmp/changelog.md + echo "" >> /tmp/changelog.md + echo "Pypi package have been built and pushed to Pypi: [ecoindex-compute:${{ needs.python_project.outputs.compute_version }}](https://pypi.org/project/ecoindex-compute/${{ needs.python_project.outputs.compute_version }}/)" >> /tmp/changelog.md + + - name: Create Release + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + draft: ${{ env.DRAFT }} + makeLatest: true + name: "Compute: v${{ needs.python_project.outputs.compute_version }}" + tag: v${{ needs.python_project.outputs.compute_version }}@compute + token: ${{ github.token }} + bodyFile: /tmp/changelog.md diff --git a/.github/workflows/scraper_build_publish.yml b/.github/workflows/scraper_build_publish.yml new file mode 100644 index 0000000..441bef1 --- /dev/null +++ b/.github/workflows/scraper_build_publish.yml @@ -0,0 +1,193 @@ +name: Publish Scraper pypi package and create a release + +on: + workflow_dispatch: + inputs: + bump: + description: "Bump the version of the scraper" + type: choice + required: true + default: "patch" + options: + - "patch" + - "minor" + - "major" + - "prepatch" + - "preminor" + - "premajor" +env: + DRAFT: ${{ contains(inputs.bump, 'pre') }} + +jobs: + python_project: + name: Build ecoindex Scraper python project + runs-on: ubuntu-latest + outputs: + wheel: ${{ steps.wheel.outputs.wheel }} + scraper_version: ${{ steps.version.outputs.scraper_version }} + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install Task + uses: arduino/setup-task@v2 + with: + version: 3.x + + - name: Install poetry + uses: abatilo/actions-poetry@v2 + + - name: Install poetry build project + run: pip install poetry-multiproject-plugin + + - name: Bump version + run: task scraper:bump -- ${{ github.event.inputs.bump }} + + - name: Build + run: task scraper:poetry:build + + - name: Upload version to artifacts + uses: actions/upload-artifact@v4 + with: + name: version + path: components/ecoindex/scraper/VERSION + + - name: Upload pyproject.toml to artifacts + uses: actions/upload-artifact@v4 + with: + name: pyproject + path: projects/ecoindex_scraper/pyproject.toml + + - name: Upload dist folder + uses: actions/upload-artifact@v4 + with: + name: dist + path: projects/ecoindex_scraper/dist + + - name: Output version + id: version + run: echo "scraper_version=$(task scraper:poetry:version-short)" >> $GITHUB_OUTPUT + + - name: Output wheel + id: wheel + run: echo "wheel=ecoindex_scraper-${{ steps.version.outputs.scraper_version }}-py3-none-any.whl" >> $GITHUB_OUTPUT + + - name: Output summary + run: | + echo "Scraper version ${{ steps.version.outputs.scraper_version }}" >> $GITHUB_STEP_SUMMARY + echo "Wheel ${{ steps.wheel.outputs.wheel }}" >> $GITHUB_STEP_SUMMARY + + pypi_package: + name: Build and push scraper pypi package + runs-on: ubuntu-latest + needs: python_project + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Install Task + uses: arduino/setup-task@v2 + with: + version: 3.x + + - name: Download dist from artifacts + uses: actions/download-artifact@v4 + with: + name: dist + path: projects/ecoindex_scraper/dist + + - name: Download pyproject.toml from artifacts + uses: actions/download-artifact@v4 + with: + name: pyproject + path: /tmp + + - name: Copy pyproject.toml to the project + run: cp /tmp/pyproject.toml projects/ecoindex_scraper/pyproject.toml + + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install poetry + uses: abatilo/actions-poetry@v2 + + - name: Login to Pypi + run: poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} + + - name: Publish + run: task scraper:pypi:publish + + release: + name: Create a release + runs-on: ubuntu-latest + needs: [python_project, pypi_package] + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Git pull + run: git pull + + - name: Download pyproject.toml to a temporary file + uses: actions/download-artifact@v4 + with: + name: pyproject + path: /tmp + + - name: Download VERSION to a temporary file + uses: actions/download-artifact@v4 + with: + name: version + path: /tmp + + - name: Copy and overwrite existing files to the repo + run: | + cp /tmp/pyproject.toml projects/ecoindex_scraper/pyproject.toml + cp /tmp/VERSION components/ecoindex/scraper/VERSION + + - name: Commit files + uses: EndBug/add-and-commit@v9 + with: + message: "chore(scraper): Bump scraper version to ${{ needs.python_project.outputs.scraper_version }}" + tag: v${{ needs.python_project.outputs.scraper_version }}@scraper + tag_push: "--force" + push: true + + - name: Get last tag (that is not a `pre` tag) for scraper + id: last_tag + run: echo "last_tag=$(git tag --list | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+@scraper$' | sort -r | head -n 1)" >> $GITHUB_OUTPUT + + - name: Update CHANGELOG + id: changelog + uses: requarks/changelog-action@v1 + with: + token: ${{ github.token }} + fromTag: v${{ needs.python_project.outputs.scraper_version }}@scraper + toTag: ${{ steps.last_tag.outputs.last_tag }} + excludeScopes: api,cli,compute + changelogFilePath: /tmp/changelog.md + + - name: Update changelog content with dockerhub links + run: | + echo "" >> /tmp/changelog.md + echo "### Pypi package" >> /tmp/changelog.md + echo "" >> /tmp/changelog.md + echo "Pypi package have been built and pushed to Pypi: [ecoindex-scraper:${{ needs.python_project.outputs.scraper_version }}](https://pypi.org/project/ecoindex-scraper/${{ needs.python_project.outputs.scraper_version }}/)" >> /tmp/changelog.md + + - name: Create Release + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + draft: ${{ env.DRAFT }} + makeLatest: true + name: "Scraper: v${{ needs.python_project.outputs.scraper_version }}" + tag: v${{ needs.python_project.outputs.scraper_version }}@scraper + token: ${{ github.token }} + bodyFile: /tmp/changelog.md diff --git a/Taskfile.yml b/Taskfile.yml index 7b492fd..13e6fcb 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,4 +1,4 @@ -version: '3' +version: "3" includes: api: @@ -39,4 +39,4 @@ tasks: vars: VERSION_FILE_PATH: "VERSION" VERSION_RULE: "{{.CLI_ARGS}}" - silent: true \ No newline at end of file + silent: true diff --git a/bases/ecoindex/backend/VERSION b/bases/ecoindex/backend/VERSION index 0aec50e..e9ada01 100644 --- a/bases/ecoindex/backend/VERSION +++ b/bases/ecoindex/backend/VERSION @@ -1 +1 @@ -3.1.4 +3.2.0a0 diff --git a/projects/ecoindex_api/docker/backend/dockerfile b/projects/ecoindex_api/docker/backend/dockerfile index 9d05c2d..6f1dcdc 100644 --- a/projects/ecoindex_api/docker/backend/dockerfile +++ b/projects/ecoindex_api/docker/backend/dockerfile @@ -1,4 +1,4 @@ -FROM python:3.12-slim as requirements-stage +FROM python:3-slim as requirements-stage WORKDIR /tmp @@ -7,7 +7,7 @@ COPY pyproject.toml poetry.lock /tmp/ RUN poetry export --with=backend --output=requirements.txt --without-hashes -FROM python:3.12-slim +FROM python:3-slim ARG wheel=ecoindex_api-3.1.0-py3-none-any.whl diff --git a/projects/ecoindex_api/docker/worker/dockerfile b/projects/ecoindex_api/docker/worker/dockerfile index 6b9a87e..c24909c 100644 --- a/projects/ecoindex_api/docker/worker/dockerfile +++ b/projects/ecoindex_api/docker/worker/dockerfile @@ -1,4 +1,4 @@ -FROM python:3.12-slim as requirements-stage +FROM python:3-slim as requirements-stage WORKDIR /tmp @@ -7,7 +7,7 @@ COPY pyproject.toml poetry.lock /tmp/ RUN poetry export --with=worker --output=requirements.txt --without-hashes -FROM python:3.12-slim +FROM python:3-slim ARG wheel=ecoindex_api-3.1.0-py3-none-any.whl diff --git a/projects/ecoindex_api/pyproject.toml b/projects/ecoindex_api/pyproject.toml index 51402ef..3ce49a1 100644 --- a/projects/ecoindex_api/pyproject.toml +++ b/projects/ecoindex_api/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ecoindex_api" -version = "3.1.4" +version = "3.2.0a0" description = "REST API to expose Ecoindex" authors = ['Vincent Vatelot '] license = "Creative Commons BY-NC-ND" diff --git a/tasks/PoetryTaskfile.yml b/tasks/PoetryTaskfile.yml index c44c985..d8a379d 100644 --- a/tasks/PoetryTaskfile.yml +++ b/tasks/PoetryTaskfile.yml @@ -1,4 +1,4 @@ -version: '3' +version: "3" tasks: install: @@ -6,7 +6,7 @@ tasks: cmds: - poetry install silent: true - + add: desc: Add a new dependency to {{.PROJECT_NAME}} cmds: @@ -34,7 +34,7 @@ tasks: bump: internal: true - preconditions: + preconditions: - sh: '[[ "{{.CLI_ARGS}}" =~ ^(major|minor|patch|premajor|preminor|prepatch|prerelease)$ ]]' msg: "Invalid version rule: `{{.CLI_ARGS}}` must be major, minor, patch, premajor, preminor, prepatch or prerelease." cmds: @@ -46,10 +46,16 @@ tasks: - echo "$(cat /tmp/version-bump-output-{{.PROJECT_NAME}})" > {{.VERSION_FILE_PATH}} silent: true + version-short: + desc: Show the current version of {{.PROJECT_NAME}} + cmds: + - poetry version -s + silent: true + install-playwright: desc: Install playwright cmds: - poetry run playwright install chromium --with-deps silent: true internal: true - interactive: true \ No newline at end of file + interactive: true