From aed86a99d5537a17f4556a222db4ee6c37bcd412 Mon Sep 17 00:00:00 2001 From: Philippe Merle Date: Wed, 6 Aug 2025 13:28:59 +0300 Subject: [PATCH] Create release.yml --- .github/workflows/release.yml | 89 +++++++++++++++++++++++++++++++++++ 1 file changed, 89 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..a83a430 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,89 @@ +# When a release is created, this workflow will +# - build and upload KubeDiagrams Python Package to PyPI +# - build and upload KubeDiagrams images to DockerHub + +name: Release + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + build-pypa: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Build release distributions + run: | + python -m pip install build + python -m build + + - name: Upload distributions + uses: actions/upload-artifact@v4 + with: + name: release-dists + path: dist/ + + pypi-publish: + runs-on: ubuntu-latest + needs: + - build-pypa + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + environment: + name: pypi + url: https://pypi.org/project/KubeDiagrams/${{ github.event.release.name }} + steps: + - name: Retrieve release distributions + uses: actions/download-artifact@v4 + with: + name: release-dists + path: dist/ + + - name: Publish release distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: dist/ + + build-publish-images: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - 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 version from release tag + id: get_version + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Build and push Docker multi-arch image + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/kubediagrams:${{ env.VERSION }} + ${{ secrets.DOCKERHUB_USERNAME }}/kubediagrams:latest