From 75bae256f2ce88e4605f5c44206eb25b0d314dea Mon Sep 17 00:00:00 2001 From: Bill Date: Thu, 1 Jan 2026 10:46:12 -0500 Subject: [PATCH] refactor: separate Gitea and GitHub workflows - Add .gitea/workflows/release.yml for Gitea builds - Uses plain docker commands (no action dependencies) - Pushes to git.prettyhefty.com registry - Simplify .github/workflows/build.yaml for GitHub only - Remove Gitea detection logic - Only push latest tag for non-prerelease versions --- .gitea/workflows/release.yml | 43 +++++++++++++++++++++++++++++++++ .github/workflows/build.yaml | 47 +++++++++--------------------------- 2 files changed, 54 insertions(+), 36 deletions(-) create mode 100644 .gitea/workflows/release.yml diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..3379689 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,43 @@ +name: Build and Push Docker Image + +on: + push: + tags: + - 'v*.*.*' + +env: + REGISTRY: git.prettyhefty.com + IMAGE_NAME: bill/grist-mcp + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Extract version from tag + id: version + run: | + VERSION=${GITHUB_REF#refs/tags/} + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + if [[ "$VERSION" == *-alpha* ]] || [[ "$VERSION" == *-beta* ]] || [[ "$VERSION" == *-rc* ]]; then + echo "IS_PRERELEASE=true" >> $GITHUB_OUTPUT + else + echo "IS_PRERELEASE=false" >> $GITHUB_OUTPUT + fi + + - name: Log in to Container Registry + run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login ${{ env.REGISTRY }} -u ${{ gitea.actor }} --password-stdin + + - name: Build and push Docker image + run: | + docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }} . + docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }} + + if [ "${{ steps.version.outputs.IS_PRERELEASE }}" = "false" ]; then + docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + fi + + - name: List images + run: docker images | grep grist-mcp diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a2c6ba0..a607921 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -6,7 +6,8 @@ on: - 'v*.*.*' env: - IMAGE_NAME: grist-mcp + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} jobs: build: @@ -19,53 +20,27 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Determine registry - id: registry - run: | - if [ "${GITEA_ACTIONS}" = "true" ]; then - # Gitea: use server URL as registry - REGISTRY="${{ github.server_url }}" - REGISTRY="${REGISTRY#https://}" - REGISTRY="${REGISTRY#http://}" - echo "registry=${REGISTRY}" >> $GITHUB_OUTPUT - echo "is_gitea=true" >> $GITHUB_OUTPUT - else - # GitHub: use GHCR - echo "registry=ghcr.io" >> $GITHUB_OUTPUT - echo "is_gitea=false" >> $GITHUB_OUTPUT - fi - - - name: Log in to GitHub Container Registry - if: steps.registry.outputs.is_gitea == 'false' + - name: Log in to Container Registry uses: docker/login-action@v3 with: - registry: ghcr.io + registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Log in to Gitea Container Registry - if: steps.registry.outputs.is_gitea == 'true' - uses: docker/login-action@v3 - with: - registry: ${{ steps.registry.outputs.registry }} - username: ${{ github.actor }} - password: ${{ secrets.REGISTRY_TOKEN }} - - - name: Extract metadata (tags, labels) + - name: Extract metadata for Docker id: meta uses: docker/metadata-action@v5 with: - images: ${{ steps.registry.outputs.registry }}/${{ github.repository }} + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=raw,value=latest + type=raw,value=latest,enable=${{ !contains(github.ref, '-alpha') && !contains(github.ref, '-beta') && !contains(github.ref, '-rc') }} - - name: Build and push + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push Docker image uses: docker/build-push-action@v6 with: context: .