Skip to content

Commit

Permalink
ci(api): Add release job
Browse files Browse the repository at this point in the history
  • Loading branch information
vvatelot committed Feb 14, 2024
1 parent 113c7c3 commit 6efb590
Showing 1 changed file with 62 additions and 8 deletions.
70 changes: 62 additions & 8 deletions .github/workflows/api_build_publish_docker_hub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,23 @@ jobs:
- name: Build
run: task api:poetry:build

- name: Upload wheel to artifacts
- name: Upload version to artifacts
uses: actions/upload-artifact@v4
with:
name: wheel
path: projects/ecoindex_api/dist/*.whl
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
Expand All @@ -78,10 +90,10 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v4

- name: Download wheel from artifacts
- name: Download dist from artifacts
uses: actions/download-artifact@v4
with:
name: wheel
name: dist
path: projects/ecoindex_api/dist

- name: Set up QEMU
Expand All @@ -108,7 +120,7 @@ jobs:
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 }}
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 }}
Expand All @@ -121,10 +133,10 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v4

- name: Download wheel from artifacts
- name: Download dist from artifacts
uses: actions/download-artifact@v4
with:
name: wheel
name: dist
path: projects/ecoindex_api/dist

- name: Set up QEMU
Expand Down Expand Up @@ -155,3 +167,45 @@ jobs:
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: [backend_image, worker_image, python_project]
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Download version from artifacts
uses: actions/download-artifact@v4
with:
name: version
path: bases/ecoindex/backend/VERSION

- name: Download pyproject.toml from artifacts
uses: actions/download-artifact@v4
with:
name: pyproject
path: projects/ecoindex_api/pyproject.toml

- name: Commit files
uses: EndBug/add-and-commit@v9
with:
message: "Bump API version to ${{ needs.python_project.outputs.api_version }}"
tag: v${{ needs.python_project.outputs.api_version }}@api
tag_push: "--force"

- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.python_project.outputs.api_version }}@api
release_name: v${{ needs.python_project.outputs.api_version }}@api
prerelease: ${{ env.DRAFT }}
body: |
Changes in this Release
- Bump version to ${{ needs.python_project.outputs.api_version }}
- Update backend image to vvatelot/ecoindex-api-backend:${{ needs.python_project.outputs.api_version }}
- Update worker image to vvatelot/ecoindex-api-worker:${{ needs.python_project.outputs.api_version }}

0 comments on commit 6efb590

Please sign in to comment.