|
| 1 | +name: release-main |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: write |
| 5 | + packages: write |
| 6 | + |
| 7 | +on: |
| 8 | + release: |
| 9 | + types: [published] |
| 10 | + |
| 11 | +jobs: |
| 12 | + set-version: |
| 13 | + runs-on: ubuntu-24.04 |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Export tag |
| 18 | + id: vars |
| 19 | + run: echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT |
| 20 | + if: ${{ github.event_name == 'release' }} |
| 21 | + |
| 22 | + - name: Update project version |
| 23 | + run: | |
| 24 | + sed -i "s/^version = \".*\"/version = \"$RELEASE_VERSION\"/" pyproject.toml |
| 25 | + env: |
| 26 | + RELEASE_VERSION: ${{ steps.vars.outputs.tag }} |
| 27 | + if: ${{ github.event_name == 'release' }} |
| 28 | + |
| 29 | + - name: Upload updated pyproject.toml |
| 30 | + uses: actions/upload-artifact@v4 |
| 31 | + with: |
| 32 | + name: pyproject-toml |
| 33 | + path: pyproject.toml |
| 34 | + |
| 35 | + publish: |
| 36 | + runs-on: ubuntu-latest |
| 37 | + needs: [set-version] |
| 38 | + steps: |
| 39 | + - name: Check out |
| 40 | + uses: actions/checkout@v4 |
| 41 | + |
| 42 | + - name: Set up the environment |
| 43 | + uses: ./.github/actions/setup-python-env |
| 44 | + |
| 45 | + - name: Download updated pyproject.toml |
| 46 | + uses: actions/download-artifact@v4 |
| 47 | + with: |
| 48 | + name: pyproject-toml |
| 49 | + |
| 50 | + - name: Build package |
| 51 | + run: uv build |
| 52 | + |
| 53 | + - name: Publish package |
| 54 | + run: uv publish |
| 55 | + env: |
| 56 | + UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }} |
| 57 | + |
| 58 | + - name: Upload dists to release |
| 59 | + uses: svenstaro/upload-release-action@v2 |
| 60 | + with: |
| 61 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 62 | + file: dist/* |
| 63 | + file_glob: true |
| 64 | + tag: ${{ github.ref }} |
| 65 | + overwrite: true |
| 66 | + |
| 67 | + |
| 68 | + push-image: |
| 69 | + runs-on: ubuntu-latest |
| 70 | + needs: [set-version] |
| 71 | + steps: |
| 72 | + - uses: actions/checkout@v4 |
| 73 | + - name: Export tag |
| 74 | + id: vars |
| 75 | + run: echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT |
| 76 | + if: ${{ github.event_name == 'release' }} |
| 77 | + - name: Set up QEMU |
| 78 | + uses: docker/setup-qemu-action@v3 |
| 79 | + - name: Set up Docker Buildx |
| 80 | + uses: docker/setup-buildx-action@v3 |
| 81 | + - name: Login to Github Container Registry |
| 82 | + uses: docker/login-action@v3 |
| 83 | + with: |
| 84 | + registry: ghcr.io |
| 85 | + username: wh1isper |
| 86 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 87 | + - name: Build and push image |
| 88 | + id: docker_build_publish |
| 89 | + uses: docker/build-push-action@v5 |
| 90 | + with: |
| 91 | + context: . |
| 92 | + platforms: linux/amd64,linux/arm64/v8 |
| 93 | + cache-from: type=gha |
| 94 | + cache-to: type=gha,mode=max |
| 95 | + file: ./Dockerfile |
| 96 | + push: true |
| 97 | + tags: | |
| 98 | + ghcr.io/wh1isper/mcp-openai-image-generation:${{ steps.vars.outputs.tag }} |
| 99 | + ghcr.io/wh1isper/mcp-openai-image-generation:latest |
0 commit comments