Skip to content

Commit

Permalink
Apply new versioning scheme
Browse files Browse the repository at this point in the history
This implements a new versioning scheme, similar to the one recently
proposed with iree-org#18938 and applies it to `iree-compiler`, `iree-runtime`
and the `iree-dist` tarball. The TF and TFLite compiler tools use the
(legacy) versioning and need to be updated with a follow up commit. The
common version number is determined based on the versions of the
compiler and the runtime and the higher version is picked as the common
on. In contrast to the proposed versioning scheme, version numbers of
development releases are in the format `X.Y.Z.dev0+${gitcommithash}` as
discussed in iree-org#19003 and not `X.Y.Z.dev` as originally proposed.

Not yet addressed is the refactoring of the workflows thus that the
`version-local.json` files get only written once (and not for every OS)
and to provide then to subsequent steps as artifacts.
  • Loading branch information
marbre committed Nov 5, 2024
1 parent 9650bfe commit 5b3e3a7
Show file tree
Hide file tree
Showing 13 changed files with 302 additions and 28 deletions.
66 changes: 63 additions & 3 deletions .github/workflows/build_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,19 @@ on:
description: "Suffix to append to package names"
required: false
default: ""
package_version:
legacy_package_version:
description: "Version of the package"
required: true
default: "0.1a1"
package_version:
description: "Version of the package"
required: true
compiler_package_version:
description: "Version of the iree-compiler package"
required: true
runtime_package_version:
description: "Version of the iree-runtime package"
required: true
release_id:
description: "Release id to upload artifacts to"
default: ""
Expand Down Expand Up @@ -131,30 +140,81 @@ jobs:
if: "matrix.build-family != 'windows'"
shell: bash
run: |
# Note: `version_info.json` holds the CalVer version and is still used
# for iree-tools-tf and iree-tools-tflite.
cat << EOF > ./c/version_info.json
{
"package-suffix": "${{ github.event.inputs.package_suffix }}",
"package-version": "${{ github.event.inputs.package_version }}",
"package-version": "${{ github.event.inputs.legacy_package_version }}",
"iree-revision": "$(cd ./c && git rev-parse HEAD)"
}
EOF
cat ./c/version_info.json
echo "iree-dist"
cat << EOF > ./c/version-local.json
{
"package-suffix": "${{ github.event.inputs.package_suffix }}",
"package-version": "${{ github.event.inputs.package_version }}",
"iree-revision": "$(cd ./c && git rev-parse HEAD)"
}
EOF
cat ./c/version-local.json
echo "iree-compiler"
cat << EOF > ./c/compiler/version-local.json
{
"package-suffix": "${{ github.event.inputs.package_suffix }}",
"package-version": "${{ github.event.inputs.compiler_package_version }}",
"iree-revision": "$(cd ./c && git rev-parse HEAD)"
}
EOF
cat ./c/compiler/version-local.json
echo "iree-runtime"
cat << EOF > ./c/runtime/version-local.json
{
"package-suffix": "${{ github.event.inputs.package_suffix }}",
"package-version": "${{ github.event.inputs.runtime_package_version }}",
"iree-revision": "$(cd ./c && git rev-parse HEAD)"
}
EOF
cat ./c/runtime/version-local.json
- name: Write version info Windows (release)
if: "matrix.build-family == 'windows'"
shell: powershell
run: |
cd c
$verinfoprop = @{
'package-suffix'= "${{ github.event.inputs.package_suffix }}"
'package-version'= "${{ github.event.inputs.package_version }}"
'iree-revision'= $(git rev-parse HEAD)
}
$info = New-Object -TypeName PSObject -Prop $verinfoprop
$info = $info | ConvertTo-JSON
$info | Out-File "version_info.json" -Encoding "ASCII"
$compilerverinfoprop = @{
'package-suffix'= "${{ github.event.inputs.package_suffix }}"
'package-version'= "${{ github.event.inputs.compiler_package_version }}"
'iree-revision'= $(git rev-parse HEAD)
}
$info = New-Object -TypeName PSObject -Prop $compilerverinfoprop
$info = $info | ConvertTo-JSON
$info | Out-File "compiler/version_info.json" -Encoding "ASCII"
$runtimeverinfoprop = @{
'package-suffix'= "${{ github.event.inputs.package_suffix }}"
'package-version'= "${{ github.event.inputs.runtime_package_version }}"
'iree-revision'= $(git rev-parse HEAD)
}
$info = New-Object -TypeName PSObject -Prop $runtimeverinfoprop
$info = $info | ConvertTo-JSON
$info | Out-File "runtime/version_info.json" -Encoding "ASCII"
##########################################################################
# Build the main distribution tarball.
# The main distribution consists of the project being built, installed
Expand Down
28 changes: 25 additions & 3 deletions .github/workflows/oneshot_candidate_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,25 @@ jobs:
- name: Compute version
run: |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
package_version="$(printf '%(%Y%m%d)T.${{ github.run_number }}')"
tag_name="candidate-${package_version}"
# common version + tag
package_version="$(python3 build_tools/scripts/compute_common_version.py -rc)"
tag_name="iree-${package_version}"
echo "package_version=${package_version}" >> $GITHUB_ENV
echo "tag_name=${tag_name}" >> $GITHUB_ENV
# legacy package version (for iree-tools-{tf,tflite})
legacy_package_version="$(printf '%(%Y%m%d)T.${{ github.run_number }}')"
echo "legacy_package_version=${legacy_package_version}" >> $GITHUB_ENV
# iree-compiler version
compiler_package_version="$(python3 build_tools/scripts/compute_local_version.py compiler -rc)"
echo "compiler_package_version=${compiler_package_version}" >> $GITHUB_ENV
# iree-runtime version
runtime_package_version="$(python3 build_tools/scripts/compute_local_version.py runtime -rc)"
echo "runtime_package_version=${runtime_package_version}" >> $GITHUB_ENV
- name: Updating candidate tag
run: |
git tag "${tag_name}"
Expand Down Expand Up @@ -51,4 +65,12 @@ jobs:
workflow: Build Release Packages
token: ${{ secrets.WRITE_ACCESS_TOKEN }}
ref: "${{ env.tag_name }}"
inputs: '{"package_suffix": "", "package_version": "${{ env.package_version }}", "release_id": "${{ steps.create_release.outputs.id }}"}'
inputs: |
{
"package_suffix": "",
"legacy_package_version": "${{ env.legacy_package_version }}",
"package_version": "${{ env.package_version }}",
"compiler_package_version": "${{ env.compiler_package_version }}",
"runtime_package_version": "${{ env.runtime_package_version }}",
"release_id": "${{ steps.create_release.outputs.id }}"
}
21 changes: 20 additions & 1 deletion .github/workflows/pkgci_build_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,30 @@ jobs:
{
"package-suffix": "${PACKAGE_SUFFIX}",
"package-version": "${{ inputs.package_version }}",
"iree-revision": "$(cd ../iree && git rev-parse HEAD)"
"iree-revision": "$(cd ./c && git rev-parse HEAD)"
}
EOF
realpath version_info.json
cat version_info.json
compiler_package_version="$(python3 build_tools/scripts/compute_local_version.py compiler --custom-string=${{ inputs.package_version }})"
cat << EOF > compiler/version-local.json
{
"package-suffix": "${PACKAGE_SUFFIX}",
"package-version": "${compiler_package_version}",
"iree-revision": "$(cd ./c && git rev-parse HEAD)"
}
EOF
runtime_package_version="$(python3 build_tools/scripts/compute_local_version.py runtime --custom-string=${{ inputs.package_version }})"
cat << EOF > runtime/version-local.json
{
"package-suffix": "${PACKAGE_SUFFIX}",
"package-version": "${runtime_package_version}",
"iree-revision": "$(cd ./c && git rev-parse HEAD)"
}
EOF
- name: Enable cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
Expand Down
20 changes: 18 additions & 2 deletions .github/workflows/schedule_candidate_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,24 @@ jobs:
- name: Compute version
run: |
package_version="$(printf '%(%Y%m%d)T.${{ github.run_number }}')"
tag_name="candidate-${package_version}"
# common version + tag
package_version="$(python3 build_tools/scripts/compute_common_version.py -rc)"
tag_name="iree-${package_version}"
echo "package_version=${package_version}" >> $GITHUB_ENV
echo "tag_name=${tag_name}" >> $GITHUB_ENV
# legacy package version (for iree-tools-{tf,tflite})
legacy_package_version="$(printf '%(%Y%m%d)T.${{ github.run_number }}')"
echo "legacy_package_version=${legacy_package_version}" >> $GITHUB_ENV
# iree-compiler version
compiler_package_version="$(python3 build_tools/scripts/compute_local_version.py compiler -rc)"
echo "compiler_package_version=${compiler_package_version}" >> $GITHUB_ENV
# iree-runtime version
runtime_package_version="$(python3 build_tools/scripts/compute_local_version.py runtime -rc)"
echo "runtime_package_version=${runtime_package_version}" >> $GITHUB_ENV
- name: Updating candidate tag
run: |
git tag "${tag_name}"
Expand Down Expand Up @@ -72,7 +85,10 @@ jobs:
inputs: |
{
"package_suffix": "",
"legacy_package_version": "${{ env.legacy_package_version }}",
"package_version": "${{ env.package_version }}",
"compiler_package_version": "${{ env.compiler_package_version }}",
"runtime_package_version": "${{ env.runtime_package_version }}",
"release_id": "${{ steps.create_release.outputs.id }}",
"commit": "${{ steps.last_green_commit.outputs.release-commit }}"
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Testing/
configured.bazelrc
user.bazelrc
version_info.json
version-local.json
CMakeUserPresets.json

# Dear ImGui Ini files
Expand Down
7 changes: 4 additions & 3 deletions build_tools/github_actions/build_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
following sub-directories:
- c/ : Main IREE repository checkout.
- bindist/ : Directory where binary distribution artifacts are written.
- c/version_info.json : Version config information.
- c/version_info.json : Version config information (legacy).
- c/version-local.json : Version config information.
Within the build environment (which may be the naked runner or a docker image):
- iree-build/ : The build tree.
Expand Down Expand Up @@ -80,14 +81,14 @@

# Load version info.
def load_version_info():
with open(os.path.join(IREESRC_DIR, "version_info.json"), "rt") as f:
with open(os.path.join(IREESRC_DIR, "version-local.json"), "rt") as f:
return json.load(f)


try:
version_info = load_version_info()
except FileNotFoundError:
print("version_info.json not found. Using defaults")
print("version-local.json not found. Using version.json defaults")
version_info = {
"package-version": "0.1dev1",
"package-suffix": "-dev",
Expand Down
1 change: 1 addition & 0 deletions build_tools/github_actions/ci_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
# Ensure a recent cmake
cmake>=3.18.4
ninja
packaging
63 changes: 63 additions & 0 deletions build_tools/scripts/compute_common_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright 2024 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# This scripts grabs the X.Y.Z[.dev]` version identifier from the
# compiler's and runtime's `version.json` files and computes the
# shared version.

import argparse
from pathlib import Path
import json
from datetime import datetime
import subprocess

from packaging.version import Version


parser = argparse.ArgumentParser()
release_type = parser.add_mutually_exclusive_group()
release_type.add_argument("-rc", "--nightly-release", action="store_true")
release_type.add_argument("-dev", "--development-release", action="store_true")
release_type.add_argument("--custom-string", action="store", type=str)
args = parser.parse_args()

THIS_DIR = Path(__file__).parent.resolve()

VERSION_FILE_COMPILER = THIS_DIR / "../../compiler/version.json"
VERSION_FILE_RUNTIME = THIS_DIR / "../../runtime/version.json"


def load_version_info(version_file):
with open(version_file, "rt") as f:
return json.load(f)


compiler_version = load_version_info(VERSION_FILE_COMPILER)
COMPILER_PACKAGE_VERSION = compiler_version.get("package-version")
COMPILER_BASE_VERSION = Version(COMPILER_PACKAGE_VERSION).base_version

runtime_version = load_version_info(VERSION_FILE_RUNTIME)
RUNTIME_PACKAGE_VERSION = runtime_version.get("package-version")
RUNTIME_BASE_VERSION = Version(RUNTIME_PACKAGE_VERSION).base_version

if RUNTIME_BASE_VERSION > COMPILER_BASE_VERSION:
CURRENT_VERSION = RUNTIME_BASE_VERSION
else:
CURRENT_VERSION = COMPILER_BASE_VERSION

if args.nightly_release:
CURRENT_VERSION += "rc" + datetime.today().strftime("%Y%m%d")

if args.development_release:
CURRENT_VERSION += (
".dev+"
+ subprocess.check_output(["git", "rev-parse", "HEAD"]).decode("ascii").strip()
)

if args.custom_string:
CURRENT_VERSION += args.custom_string

print(CURRENT_VERSION)
Loading

0 comments on commit 5b3e3a7

Please sign in to comment.