|
| 1 | +name: Publish |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + push_to_pypi: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + |
| 10 | + permissions: |
| 11 | + id-token: write |
| 12 | + contents: read |
| 13 | + |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + - name: Checkout |
| 17 | + uses: actions/setup-python@v4 |
| 18 | + with: |
| 19 | + python-version: "3.13" |
| 20 | + - name: Build distributions |
| 21 | + run: | |
| 22 | + python -m pip install --upgrade pip |
| 23 | + python -m pip install build |
| 24 | + python -m build |
| 25 | + - name: Publish release distributions to PyPI |
| 26 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 27 | + |
| 28 | + push_to_docker_hub: |
| 29 | + needs: push_to_pypi |
| 30 | + name: Push Docker image to Docker Hub |
| 31 | + runs-on: ubuntu-latest |
| 32 | + permissions: |
| 33 | + contents: write |
| 34 | + packages: write |
| 35 | + |
| 36 | + steps: |
| 37 | + - name: Check out the repo |
| 38 | + uses: actions/checkout@v4 |
| 39 | + |
| 40 | + - name: Log in to Docker Hub |
| 41 | + uses: docker/login-action@v3 |
| 42 | + with: |
| 43 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 44 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 45 | + |
| 46 | + - name: Login to GitHub Container Registry |
| 47 | + uses: docker/login-action@v3 |
| 48 | + with: |
| 49 | + registry: ghcr.io |
| 50 | + username: ${{ github.actor }} |
| 51 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 52 | + |
| 53 | + - name: Extract metadata (tags, labels) for Docker |
| 54 | + id: meta |
| 55 | + uses: docker/metadata-action@v4 |
| 56 | + with: |
| 57 | + images: elementsinteractive/lightman-ai |
| 58 | + |
| 59 | + - name: Build and push Docker image |
| 60 | + uses: docker/build-push-action@v5 |
| 61 | + with: |
| 62 | + context: . |
| 63 | + file: ./Dockerfile |
| 64 | + push: true |
| 65 | + tags: ${{ steps.meta.outputs.tags }} |
| 66 | + labels: ${{ steps.meta.outputs.labels }} |
| 67 | + cache-from: type=registry,ref=ghcr.io/elementsinteractive/lightman-ai:buildcache |
| 68 | + cache-to: type=registry,ref=ghcr.io/elementsinteractive/lightman-ai:buildcache,mode=max |
| 69 | + |
| 70 | + release_notes: |
| 71 | + runs-on: ubuntu-latest |
| 72 | + needs: push_to_docker_hub |
| 73 | + steps: |
| 74 | + - uses: actions/checkout@v4 |
| 75 | + - name: Release |
| 76 | + uses: softprops/action-gh-release@v2 |
| 77 | + with: |
| 78 | + generate_release_notes: true |
| 79 | + token: "${{ secrets.GITHUB_TOKEN }}" |
0 commit comments