Skip to content

ControlPlaneKubeletLocalMode-fix-1 #2339

ControlPlaneKubeletLocalMode-fix-1

ControlPlaneKubeletLocalMode-fix-1 #2339

Workflow file for this run

name: Build and Release
on:
push:
branches:
- '**'
tags:
- '*'
jobs:
build-package:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Build Package via Docker
run: |
docker build -t kubemarine --build-arg BUILD_TYPE=package --no-cache .
CONTAINER_ID=$(docker create kubemarine)
docker cp "${CONTAINER_ID}:/opt/kubemarine/dist" dist
docker rm -v "${CONTAINER_ID}"
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: package
path: ./dist
retention-days: 1
build-binary:
runs-on: ${{ matrix.target.os }}
needs: build-package
strategy:
fail-fast: false
matrix:
target:
- {os: windows-2022, arch: 'win64'}
- {os: macos-12, arch: 'macos12-x86_64'}
- {os: macos-12, arch: 'macos12-arm64'}
- {os: ubuntu-latest, arch: 'linux-x86_64'}
include:
- executable_path: './dist/kubemarine'
- target: {os: windows-2022, arch: 'win64'}
executable_path: 'dist\kubemarine.exe'
- target: {os: ubuntu-latest, arch: 'linux-x86_64'}
# It is important to build on centos7 base image as long as we support running of the executable on Centos 7
build_cmd: >
docker run -t -v $(pwd):/opt/app-root/src centos/python-38-centos7 bash -c
'python scripts/ci/build_binary.py'
- target: {os: windows-2022, arch: 'win64'}
build_cmd: python scripts/ci/build_binary.py
- target: {os: macos-12, arch: 'macos12-x86_64'}
build_cmd: python scripts/ci/build_binary.py x86_64
- target: {os: macos-12, arch: 'macos12-arm64'}
build_cmd: python scripts/ci/build_binary.py arm64
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Download Package
uses: actions/download-artifact@v3
with:
name: package
path: ./dist
# Remove the step after https://github.com/actions/setup-python/issues/713 is solved
- name: Fix broken pip installation
if: ${{ matrix.target.os == 'macos-12' }}
run: |
SITE_PACKAGES="/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages"
PIP_VERSION=$(cat $SITE_PACKAGES/pip/__init__.py | grep __version__ | sed 's/["=]//g' | awk '{print $2}')
for dist_info in $(find $SITE_PACKAGES -name 'pip-*.dist-info'); do
if [[ $(basename "$dist_info") != "pip-$PIP_VERSION.dist-info" ]]; then
echo "Removing broken pip installation $dist_info"
rm -rf $dist_info
fi
done
- name: Build
run: ${{ matrix.build_cmd }}
- name: Run Selftest
if: ${{ matrix.target.arch != 'macos12-arm64' }}
run: ${{ matrix.executable_path }} selftest
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: kubemarine-${{ matrix.target.arch }}
path: ${{ matrix.executable_path }}
retention-days: 1
test-binary:
# Currently macos-latest is macos-14-arm64, and thus binary build for macos12-arm64 can be tested on it.
runs-on: macos-latest
needs: build-binary
steps:
- name: Download Executable
uses: actions/download-artifact@v3
with:
name: kubemarine-macos12-arm64
- name: Run Selftest
run: |
chmod +x kubemarine
./kubemarine selftest
test-package:
runs-on: ${{ matrix.os }}
needs: build-package
# Testing of packages can consume some time, so it is currently decided to run them only on main branch and tags.
# Meanwhile, testing of the image with package internally is done in the separate workflow on each push.
if: ${{ startsWith(github.ref, 'refs/tags') || github.ref_name == 'main' }}
strategy:
fail-fast: false
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
include:
- wheel: 'dist/*.whl'
remove_files_script: 'find . -not -path "./test*" -not -path "./examples*" -not -path "./scripts*" -delete'
- os: windows-latest
wheel: '(get-item dist\*.whl).FullName'
remove_files_script: 'Get-ChildItem -Exclude test,examples,scripts | Remove-Item -Recurse -Force'
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Keep Testing Files
run: ${{ matrix.remove_files_script }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Download Package
uses: actions/download-artifact@v3
with:
name: package
path: ./dist
- name: Install Package
run: python -m pip install ${{ matrix.wheel }}
- name: Enable UTF-8 on Windows
run: echo "PYTHONIOENCODING=utf-8" >> $env:GITHUB_ENV
if: runner.os == 'Windows'
- name: Run Tests
run: python -m unittest discover -s test/unit -t test/unit
create-release:
runs-on: ubuntu-latest
# For simpler and faster solution, release now requires only package, and it is uploaded to the release immediately.
# Binaries will be built and uploaded asynchronously.
needs: build-package
if: startsWith(github.ref, 'refs/tags')
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Validate and Prepare
id: prepare
run: |
VERSION=$(cat kubemarine/version)
if [[ $VERSION != "${{ github.ref_name }}" ]]; then
echo -e "\033[91mGit tag does not equal to kubemarine/version\033[0m"
exit 1
fi
BRANCH_OWNERS=$(git branch -r --contains HEAD | sed 's/^[[:space:]]*origin\/\(.*\)$/\1/' | grep "^\(main\|.*_branch\)$" || true)
if [[ -z "$BRANCH_OWNERS" || $(echo "$BRANCH_OWNERS" | wc -l) != 1 ]]; then
echo -e "\033[91mFailed to detect the only release branch containing the HEAD commit.\033[0m"
echo "Available branches:"
git branch -r --contains HEAD
exit 1
fi
echo -e "\033[0;32mTarget commitish: ${BRANCH_OWNERS}\033[0m"
echo "target_commitish=$BRANCH_OWNERS" >> $GITHUB_OUTPUT
- name: Download Package
uses: actions/download-artifact@v3
with:
name: package
path: ./dist
- name: Pack Package
run: zip -r package.zip dist
- name: Create Release
uses: softprops/action-gh-release@v1
with:
draft: false
prerelease: true
generate_release_notes: true
# The value is necessary to manage the branch after release is released.
# See patch.yaml workflow.
target_commitish: ${{ steps.prepare.outputs.target_commitish }}
files: |
package.zip
upload-binary:
runs-on: ubuntu-latest
needs: [ build-binary, test-binary, create-release ]
if: startsWith(github.ref, 'refs/tags')
strategy:
matrix:
arch: [ 'win64', 'macos12-x86_64', 'macos12-arm64', 'linux-x86_64' ]
include:
- ext: ''
- arch: 'win64'
ext: '.exe'
steps:
- name: Download Executable
uses: actions/download-artifact@v3
with:
name: kubemarine-${{ matrix.arch }}
- name: Prepare Executable
run: mv kubemarine${{ matrix.ext }} kubemarine-${{ matrix.arch }}${{ matrix.ext }}
- name: Upload Release Asset
uses: softprops/action-gh-release@v1
with:
# Since the release already exists, the following does not change it, but only uploads the artifact.
files: |
kubemarine-${{ matrix.arch }}${{ matrix.ext }}