v1.0.2 #9
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release Image | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| image_tag: | |
| description: Image tag to publish | |
| required: true | |
| type: string | |
| permissions: | |
| contents: read | |
| packages: write | |
| concurrency: | |
| group: release-image-${{ github.event.release.tag_name || github.ref_name }} | |
| cancel-in-progress: false | |
| jobs: | |
| build-image: | |
| name: Build ${{ matrix.archs.arch }} image | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| archs: | |
| - arch: amd64 | |
| - arch: arm64 | |
| runs-on: ubuntu-24.04-arm | |
| runs-on: ${{ matrix.archs.runs-on || 'ubuntu-24.04' }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Resolve image version | |
| id: version | |
| run: | | |
| VERSION="${{ github.event.release.tag_name || inputs.image_tag }}" | |
| echo "value=${VERSION}" >> "$GITHUB_OUTPUT" | |
| - name: Build and push for ${{ matrix.archs.arch }} | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: Dockerfile | |
| target: runner | |
| platforms: linux/${{ matrix.archs.arch }} | |
| push: true | |
| tags: | | |
| ghcr.io/${{ github.repository_owner }}/fastgpt-plugin:${{ steps.version.outputs.value }}-${{ matrix.archs.arch }} | |
| ghcr.io/${{ github.repository_owner }}/fastgpt-plugin:${{ github.sha }}-${{ matrix.archs.arch }} | |
| labels: | | |
| org.opencontainers.image.source=https://github.com/${{ github.repository }} | |
| org.opencontainers.image.description=FastGPT Plugin release image | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| org.opencontainers.image.version=${{ steps.version.outputs.value }} | |
| cache-from: type=gha,scope=release-image-${{ matrix.archs.arch }} | |
| cache-to: type=gha,mode=max,scope=release-image-${{ matrix.archs.arch }} | |
| - name: Export digest | |
| run: | | |
| mkdir -p /tmp/digests | |
| digest="${{ steps.build.outputs.digest }}" | |
| touch "/tmp/digests/${digest#sha256:}" | |
| - name: Upload digest | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: digests-${{ matrix.archs.arch }} | |
| path: /tmp/digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| merge-image: | |
| name: Publish multi-arch image | |
| runs-on: ubuntu-24.04 | |
| needs: | |
| - build-image | |
| steps: | |
| - name: Download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: /tmp/digests | |
| pattern: digests-* | |
| merge-multiple: true | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_NAME }} | |
| password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
| - name: Login to Ali Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: registry.cn-hangzhou.aliyuncs.com | |
| username: ${{ secrets.FASTGPT_ALI_IMAGE_USER }} | |
| password: ${{ secrets.FASTGPT_ALI_IMAGE_PSW }} | |
| - name: Resolve image version | |
| id: version | |
| run: | | |
| VERSION="${{ github.event.release.tag_name || inputs.image_tag }}" | |
| echo "value=${VERSION}" >> "$GITHUB_OUTPUT" | |
| - name: Create manifest list and push | |
| working-directory: /tmp/digests | |
| run: | | |
| GITHUB_IMAGE="ghcr.io/${{ github.repository_owner }}/fastgpt-plugin" | |
| ALI_IMAGE="${{ secrets.FASTGPT_ALI_IMAGE_PREFIX }}/fastgpt-plugin" | |
| DOCKER_IMAGE="${{ secrets.DOCKER_IMAGE_NAME }}/fastgpt-plugin" | |
| VERSION="${{ steps.version.outputs.value }}" | |
| TAGS="$GITHUB_IMAGE:$VERSION $GITHUB_IMAGE:latest $GITHUB_IMAGE:${{ github.sha }} $ALI_IMAGE:$VERSION $ALI_IMAGE:latest $ALI_IMAGE:${{ github.sha }} $DOCKER_IMAGE:$VERSION $DOCKER_IMAGE:latest $DOCKER_IMAGE:${{ github.sha }}" | |
| for TAG in $TAGS; do | |
| echo "Creating manifest list for: $TAG" | |
| docker buildx imagetools create -t "$TAG" \ | |
| $(printf 'ghcr.io/${{ github.repository_owner }}/fastgpt-plugin@sha256:%s ' *) | |
| sleep 2 | |
| done |