SeineAI / SeineSailor

Help developers navigating through the codebase smoothly
MIT License
4 stars 7 forks source link

release tagging problem #14

Closed wenboown closed 4 months ago

wenboown commented 4 months ago

We added https://github.com/SeineAI/SeineSailor/blob/5bbf1d04d3320735da04a94b61c1dc865508b968/.github/workflows/release.yml#L42

to release-drafter. It correctly tagged one release as latest. But afterwards it cannot create any new releases.

https://github.com/SeineAI/SeineSailor/actions/runs/9104260759/job/25027772624#step:2:229

SeineAI/SeineSailor: Creating new release
{ name: 'event', id: '9104260759' }
Error: Validation Failed: {"resource":"Release","code":"already_exists","field":"tag_name"}
wenboown commented 4 months ago

I want to separate production (stable) and development (latest). can you help me?

Currently, I have a workflow file that refers:

which points to the latest tag release we made above.

then the action.yml has: using: 'docker' image: 'docker://ghcr.io/seineai/seine_sailor:latest' # change the latest to v1, v2... to separate dev and release

Which points to a docker image that we build and push when creating the latest release.

But I think the ideal setup should be: when I make a push or manually trigger a build workflow. it updates the latest docker image for the development. so an action.yml points to the "latest" or "dev" docker image. when I am ready for a release. It creates a new release and updates a docker image with "stable" or "prod" tag, and have the action.yml points to it. Then I can instruct my users to use a workflow yml points to uses: SeineAI/SeineSailor@stable and my development team use a workflow yml points to uses: SeineAI/SeineSailor@latest

is this possible?

wenboown commented 4 months ago

ChatGPT-4o said:

Yes, it is possible to set up separate workflows for development (latest) and production (stable) Docker images, and to have your GitHub Actions workflows use the appropriate version for each environment. Below is a detailed plan on how to achieve this.

1. Update Development Docker Image

Create a workflow that builds and pushes the Docker image with the latest tag whenever there's a push to the main branch or a manual trigger.

Workflow: .github/workflows/update-latest.yml

name: Update Latest Docker Image

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build-and-push:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v2
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Build and push Docker image
        run: |
          docker build -t ghcr.io/seineai/seine_sailor:latest .
          docker push ghcr.io/seineai/seine_sailor:latest

2. Create Stable Release and Update Production Docker Image

Create a workflow that builds and pushes the Docker image with a versioned tag and updates the stable tag. This workflow will be triggered manually when you're ready to release.

Workflow: .github/workflows/update-stable.yml

name: Update Stable Docker Image

on:
  workflow_dispatch:

jobs:
  build-and-push:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v2
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Build and push versioned Docker image
        run: |
          VERSION=$(date +%Y%m%d%H%M%S) # or use any versioning scheme you prefer
          docker build -t ghcr.io/seineai/seine_sailor:$VERSION .
          docker push ghcr.io/seineai/seine_sailor:$VERSION

      - name: Update stable tag
        run: |
          docker tag ghcr.io/seineai/seine_sailor:$VERSION ghcr.io/seineai/seine_sailor:stable
          docker push ghcr.io/seineai/seine_sailor:stable

3. Modify action.yml to Use Appropriate Docker Tags

Update your action.yml to point to either latest or stable based on the intended usage.

action.yml

name: 'SeineSailor'
description: 'Your action description'
author: 'SeineAI'

runs:
  using: 'docker'
  image: 'docker://ghcr.io/seineai/seine_sailor:${{ inputs.tag }}'

inputs:
  tag:
    description: 'Tag of the Docker image to use'
    required: true
    default: 'stable' # or 'latest' for development

4. Using the Action in Workflows

For Development Team

jobs:
  my-job:
    runs-on: ubuntu-latest
    steps:
      - name: Use SeineSailor Latest
        uses: SeineAI/SeineSailor@latest
        with:
          tag: latest

For Production

jobs:
  my-job:
    runs-on: ubuntu-latest
    steps:
      - name: Use SeineSailor Stable
        uses: SeineAI/SeineSailor@stable
        with:
          tag: stable

Summary

  1. Development Workflow: Updates the latest Docker image on push to main or manual trigger.
  2. Release Workflow: Manually triggered to create a versioned Docker image and update the stable tag.
  3. Action Configuration: action.yml uses an input to select between latest and stable Docker images.
  4. Workflow Usage: Separate workflows for development (latest) and production (stable).

This setup ensures a clear separation between development and production environments and allows for easy updates and deployment.

wenboown commented 4 months ago

fixed in 1bfef74

wenboown commented 4 months ago

This is hallucination:

runs:
  using: 'docker'
  image: 'docker://ghcr.io/seineai/seine_sailor:${{ inputs.tag }}'

After research, we confirmed that the github action runner cannot access inputs.tag. We will encounter errors like:

Error: SeineAI/SeineSailor/main/action.yml (Line: 211, Col: 10): Unrecognized named-value: 'inputs'. Located at position 1 within expression: inputs.tag Error: Failed to load SeineAI/SeineSailor/main/action.yml

We also tried things like:

  image: 'docker://ghcr.io/seineai/seine_sailor:${{ $INPUT_TAG }}'

or

  image: 'docker://ghcr.io/seineai/seine_sailor:${{ github.ref == 'refs/heads/main' && 'stable' || 'latest' }}'

They don't work either.

runs can be found at: https://github.com/SeineAI/SeineSailor/actions/runs/9131996292/job/25118846134

wenboown commented 4 months ago

Final solution is in https://github.com/SeineAI/SeineSailor/pull/18