release #976
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 | |
| on: | |
| schedule: | |
| - cron: '0 13 * * *' # This schedule runs every 13:00:00Z(21:00:00+08:00) | |
| # https://github.com/orgs/community/discussions/26286?utm_source=chatgpt.com#discussioncomment-3251208 | |
| # "The create event does not support branch filter and tag filter." | |
| # The "create tags" trigger is specifically focused on the creation of new tags, while the "push tags" trigger is activated when tags are pushed, including both new tag creations and updates to existing tags. | |
| push: | |
| tags: | |
| - 'v*.*.*' # normal release | |
| permissions: | |
| contents: write | |
| actions: read | |
| checks: read | |
| statuses: read | |
| # https://docs.github.com/en/actions/using-jobs/using-concurrency | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| release: | |
| # https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md | |
| # https://github.com/actions/runner-images/discussions/5734 | |
| # It's not possible to disable avx512 CPU hardware instruction of ubuntu-latest. | |
| runs-on: [ "self-hosted", "infinity-test" ] | |
| steps: | |
| - name: Ensure workspace ownership | |
| run: echo "chown -R ${USER} ${GITHUB_WORKSPACE}" && sudo chown -R ${USER} ${GITHUB_WORKSPACE} | |
| # https://github.com/actions/checkout/blob/v6/README.md | |
| - name: Check out code | |
| uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| - name: Prepare release body | |
| run: | | |
| if [[ ${GITHUB_EVENT_NAME} != 'schedule' ]]; then | |
| RELEASE_TAG=${GITHUB_REF#refs/tags/} | |
| if [[ ${RELEASE_TAG} == v* ]]; then | |
| PRERELEASE=false | |
| else | |
| PRERELEASE=true | |
| fi | |
| echo "Workflow triggered by push tag: ${RELEASE_TAG}" | |
| else | |
| RELEASE_TAG=nightly | |
| PRERELEASE=true | |
| echo "Workflow triggered by schedule" | |
| fi | |
| echo "RELEASE_TAG=${RELEASE_TAG}" >> ${GITHUB_ENV} | |
| echo "PRERELEASE=${PRERELEASE}" >> ${GITHUB_ENV} | |
| RELEASE_DATETIME=$(date --rfc-3339=seconds) | |
| cat <<EOF > release_template.md | |
| Release ${RELEASE_TAG} created from ${GITHUB_SHA} at ${RELEASE_DATETIME} | |
| EOF | |
| envsubst < release_template.md > release_body.md | |
| - name: Move the existing mutable tag | |
| # https://github.com/softprops/action-gh-release/issues/171 | |
| run: | | |
| if [[ ${GITHUB_EVENT_NAME} == 'schedule' ]]; then | |
| # Determine if a given tag exists and matches a specific Git commit. | |
| # actions/checkout@v6 fetch-tags doesn't work when triggered by schedule | |
| git fetch --tags | |
| if [ "$(git rev-parse -q --verify "refs/tags/${RELEASE_TAG}")" = "${GITHUB_SHA}" ]; then | |
| echo "mutable tag ${RELEASE_TAG} exists and matches ${GITHUB_SHA}" | |
| else | |
| git tag -f ${RELEASE_TAG} ${GITHUB_SHA} | |
| git push -f origin ${RELEASE_TAG}:refs/tags/${RELEASE_TAG} | |
| echo "created/moved mutable tag ${RELEASE_TAG} to ${GITHUB_SHA}" | |
| fi | |
| fi | |
| - name: Start builder container | |
| run: | | |
| BUILDER_CONTAINER=infinity_build_$(od -An -N4 -t u8 < /dev/urandom | tr -d ' ') | |
| echo "BUILDER_CONTAINER=${BUILDER_CONTAINER}" >> ${GITHUB_ENV} | |
| TZ=$(readlink -f /etc/localtime | awk -F '/zoneinfo/' '{print $2}') | |
| sudo docker rm -f ${BUILDER_CONTAINER} && sudo docker run -d --name ${BUILDER_CONTAINER} -e TZ=${TZ} -e UV_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple -v ${PWD}:/infinity infiniflow/infinity_builder:ubuntu22_clang20 | |
| - name: Build release version | |
| run: | | |
| sudo docker exec ${BUILDER_CONTAINER} bash -c "git config --global safe.directory \"*\" && cd /infinity && rm -fr cmake-build-reldeb && mkdir -p cmake-build-reldeb && cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCPACK_PACKAGE_VERSION=${RELEASE_TAG} -DCPACK_DEBIAN_PACKAGE_ARCHITECTURE=amd64 -S /infinity -B /infinity/cmake-build-reldeb && cmake --build /infinity/cmake-build-reldeb --target infinity && cd /infinity/cmake-build-reldeb && cpack" | |
| - name: Create or overwrite a release | |
| # https://github.com/actions/upload-release-asset has been replaced by https://github.com/softprops/action-gh-release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} # Use the secret as an environment variable | |
| prerelease: ${{ env.PRERELEASE }} | |
| tag_name: ${{ env.RELEASE_TAG }} | |
| # The body field does not support environment variable substitution directly. | |
| body_path: release_body.md | |
| files: | | |
| cmake-build-reldeb/infinity-*.deb | |
| cmake-build-reldeb/infinity-*.rpm | |
| cmake-build-reldeb/infinity-*.tar.gz | |
| - name: Build and push image | |
| run: | | |
| sudo docker login --username infiniflow --password-stdin <<< ${{ secrets.DOCKERHUB_TOKEN }} | |
| sudo docker build -t infiniflow/infinity:${RELEASE_TAG} -f scripts/Dockerfile_infinity . | |
| sudo docker push infiniflow/infinity:${RELEASE_TAG} | |
| - name: Build and push infinity-sdk | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: | | |
| uv run --python 3.11 python/infinity_sdk/prepare_huqie.py && uv build && uv publish --token ${{ secrets.PYPI_API_TOKEN }} | |
| - name: Destroy builder container | |
| if: always() # always run this step even if previous steps failed | |
| run: | | |
| if [ -n "${BUILDER_CONTAINER}" ]; then | |
| sudo docker rm -f -v ${BUILDER_CONTAINER} | |
| fi |