Skip to content

build: optimize the release flow (#42) #41

build: optimize the release flow (#42)

build: optimize the release flow (#42) #41

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: publish-docker
on:
push:
branches:
- main
release:
types:
- released
env:
SKIP_TEST: true
APP_NAME: skywalking-mcp
jobs:
build:
if: github.repository == 'apache/skywalking-mcp'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
timeout-minutes: 30
env:
PLATFORMS: linux/amd64,linux/arm64
IMAGE: ${{ github.event_name == 'release' && 'docker.io/apache/skywalking-mcp' || 'ghcr.io/apache/skywalking-mcp' }}
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f
- name: Resolve image version
run: |
if [ "${{ github.event_name }}" = "release" ]; then
VERSION="${GITHUB_REF_NAME#v}"
else
VERSION="${GITHUB_SHA}"
fi
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
echo "Resolved VERSION=${VERSION}"
- name: Log in to GHCR
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9
if: github.event_name == 'release'
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push docker images
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'release'
run: make docker-push