mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-31 02:25:57 +08:00
Use custom versioning system
We already had to customize to much, it isn't worth the effort to continue with GitVersion The script still has some issues when a tag is pushed Contributes to CURA-9365
This commit is contained in:
parent
913d9b8ed7
commit
36c4c56abb
171
.github/workflows/conan-recipe-version.yml
vendored
171
.github/workflows/conan-recipe-version.yml
vendored
@ -10,15 +10,23 @@ on:
|
|||||||
outputs:
|
outputs:
|
||||||
recipe_id_full:
|
recipe_id_full:
|
||||||
description: "The full Conan recipe id: <name>/<version>@<user>/<channel>"
|
description: "The full Conan recipe id: <name>/<version>@<user>/<channel>"
|
||||||
value: ${{ jobs.get-semver.outputs.recipe_id_full }}
|
value: ${{ jobs.get-conan-broadcast-data.outputs.recipe_id_full }}
|
||||||
|
|
||||||
recipe_id_latest:
|
recipe_id_latest:
|
||||||
description: "The full Conan recipe aliased (latest) id: <name>/(latest)@<user>/<channel>"
|
description: "The full Conan recipe aliased (latest) id: <name>/(latest)@<user>/<channel>"
|
||||||
value: ${{ jobs.get-semver.outputs.recipe_id_latest }}
|
value: ${{ jobs.get-conan-broadcast-data.outputs.recipe_id_latest }}
|
||||||
|
|
||||||
recipe_semver_full:
|
recipe_semver_full:
|
||||||
description: "The full semver <Major>.<Minor>.<Patch>-<PreReleaseTag>+<BuildMetaData>"
|
description: "The full semver <Major>.<Minor>.<Patch>-<PreReleaseTag>+<BuildMetaData>"
|
||||||
value: ${{ jobs.get-semver.outputs.semver_full }}
|
value: ${{ jobs.get-conan-broadcast-data.outputs.semver_full }}
|
||||||
|
|
||||||
|
recipe_user:
|
||||||
|
description: "The conan user"
|
||||||
|
value: ${{ jobs.get-conan-broadcast-data.outputs.user }}
|
||||||
|
|
||||||
|
recipe_channel:
|
||||||
|
description: "The conan channel"
|
||||||
|
value: ${{ jobs.get-conan-broadcast-data.outputs.channel }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
get-semver:
|
get-semver:
|
||||||
@ -26,10 +34,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
recipe_id_full: ${{ inputs.project_name }}/${{ steps.get-conan-broadcast-data.outputs.version }}@${{ steps.get-conan-broadcast-data.outputs.user }}/${{ steps.get-conan-broadcast-data.outputs.channel }}
|
recipe_id_full: ${{ steps.get-conan-broadcast-data.outputs.recipe_id_full }}
|
||||||
recipe_id_latest: ${{ steps.latest-alias.outputs.recipe_id_latest }}
|
recipe_id_latest: ${{ steps.get-conan-broadcast-data.outputs.recipe_id_latest }}
|
||||||
recipe_id_pr: ${{ steps.pr-alias.outputs.recipe_id_pr }}
|
semver_full: ${{ steps.get-conan-broadcast-data.outputs.semver_full }}
|
||||||
semver_full: ${{ steps.get-conan-broadcast-data.outputs.version }}
|
|
||||||
user: ${{ steps.get-conan-broadcast-data.outputs.user }}
|
user: ${{ steps.get-conan-broadcast-data.outputs.user }}
|
||||||
channel: ${{ steps.get-conan-broadcast-data.outputs.channel }}
|
channel: ${{ steps.get-conan-broadcast-data.outputs.channel }}
|
||||||
|
|
||||||
@ -40,69 +47,99 @@ jobs:
|
|||||||
ref: ${{ github.head_ref }}
|
ref: ${{ github.head_ref }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Install GitVersion
|
- name: Setup Python and pip
|
||||||
uses: gittools/actions/gitversion/setup@v0.9.13
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
versionSpec: '5.x'
|
python-version: "3.10.x"
|
||||||
|
cache: 'pip'
|
||||||
|
cache-dependency-path: .github/workflows/requirements-conan-package.txt
|
||||||
|
|
||||||
- name: GitTools
|
- name: Install Python requirements and Create default Conan profile
|
||||||
id: git-tool
|
run: pip install -r .github/workflows/requirements-conan-package.txt
|
||||||
uses: gittools/actions/gitversion/execute@v0.9.13
|
|
||||||
|
|
||||||
- id: get-conan-broadcast-data
|
- id: get-conan-broadcast-data
|
||||||
name: Get Conan broadcast data
|
name: Get Conan broadcast data
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ github.ref_type == 'tag' && github.ref_name == '${{ steps.git-tool.outputs.Major }}.${{ steps.git-tool.outputs.Minor }}.${{ steps.git-tool.outputs.Patch }}' }}" = "true" ]; then
|
from conans import tools
|
||||||
# tagged commits on a release branch matching the major.minor.patch are actual released version and should have no user and channel
|
from conans.errors import ConanException
|
||||||
# name/major.minor.patch@_/_
|
from git import Repo
|
||||||
echo '::set-output name=user::_'
|
|
||||||
echo '::set-output name=channel::_'
|
repo = Repo('.')
|
||||||
echo '::set-output name=version::${{ steps.git-tool.outputs.Major }}.${{ steps.git-tool.outputs.Minor }}.${{ steps.git-tool.outputs.Patch }}'
|
user = "${{ github.repository_owner }}"
|
||||||
elif [ "${{ github.ref_type == 'tag' && github.ref_name == '${{ steps.git-tool.outputs.Major }}.${{ steps.git-tool.outputs.Minor }}.${{ steps.git-tool.outputs.Patch }}-BETA' }}" = "true" ]; then
|
project_name = "test"
|
||||||
# tagged commits with major.minor.patch-BETA on a release branch are actual released version and should have no user and channel
|
event_name = "${{ github.event_name }}"
|
||||||
# name/major.minor.patch-beta@_/_
|
issue_number = "${{ github.event.issue.number }}"
|
||||||
echo '::set-output name=user::_'
|
is_tag = "${{ github.ref_type }}" == "tag"
|
||||||
echo '::set-output name=channel::_'
|
|
||||||
echo '::set-output name=version::${{ steps.git-tool.outputs.Major }}.${{ steps.git-tool.outputs.Minor }}.${{ steps.git-tool.outputs.Patch }}-${{ steps.git-tool.outputs.PreReleaseLabel }}'
|
# FIXME: for when we push a tag (such as an release)
|
||||||
elif [ "${{ github.ref_name == 'main' || github.ref_name == 'master' }}" = "true" ]; then
|
if is_tag:
|
||||||
# commits on main/master are alpha's (nightlies) and are considered testing
|
branch_version = tools.Version("2.3.5")
|
||||||
# name/major.minor.patch-alpha+build@ultimaker/testing
|
else:
|
||||||
echo ${{ github.repository_owner }} | awk '{print "::set-output name=user::"tolower($0)}'
|
try:
|
||||||
echo '::set-output name=channel::testing'
|
branch_version = tools.Version(repo.active_branch.name)
|
||||||
echo '::set-output name=version::${{ steps.git-tool.outputs.Major }}.${{ steps.git-tool.outputs.Minor }}.${{ steps.git-tool.outputs.Patch }}-${{ steps.git-tool.outputs.PreReleaseLabel }}+${{ steps.git-tool.outputs.BuildMetaData }}'
|
channel = "stable"
|
||||||
elif [ "${{ github.ref_name == '5.1' }}" = "true" ]; then
|
except ConanException:
|
||||||
# commits on release branches are beta's and are considered stable
|
branch_version = tools.Version('0.0.0')
|
||||||
# name/major.minor.patch-beta+build@ultimaker/stable
|
if repo.active_branch.name == f"{branch_version.major}.{branch_version.minor}":
|
||||||
# FIXME: For release branches: maybe rename the branch to release/**
|
channel = 'stable'
|
||||||
echo ${{ github.repository_owner }} | awk '{print "::set-output name=user::"tolower($0)}'
|
elif repo.active_branch.name == "main" or repo.active_branch.name == "master":
|
||||||
echo '::set-output name=channel::stable'
|
channel = 'testing'
|
||||||
echo '::set-output name=version::${{ steps.git-tool.outputs.Major }}.${{ steps.git-tool.outputs.Minor }}.${{ steps.git-tool.outputs.Patch }}-${{ steps.git-tool.outputs.PreReleaseLabel }}+${{ steps.git-tool.outputs.BuildMetaData }}'
|
else:
|
||||||
else
|
channel = repo.active_branch.name.split("_").replace("-", "_").lower()
|
||||||
# commits on other branches are considered unstable and for development purposes only
|
|
||||||
# Use the Cura branch naming scheme CURA-1234_foo_bar
|
if event_name == "pull_request":
|
||||||
# we use the first 9 characters of the branch name
|
channel = f"pr_{issue_number}"
|
||||||
# name/major.minor.patch-beta+build@ultimaker/cura_<jira_number>
|
|
||||||
echo ${{ github.repository_owner }} | awk '{print "::set-output name=user::"tolower($0)}'
|
# %% Get the actual version
|
||||||
branch=${{ github.ref_name }}
|
latest_branch_version = tools.Version("0.0.0")
|
||||||
sanitized_branch="${branch//-/_}"
|
latest_branch_tag = None
|
||||||
echo $sanitized_branch | awk '{print "::set-output name=channel::"substr(tolower($0),0,9)}'
|
for tag in repo.git.tag(merged = True).splitlines():
|
||||||
echo '::set-output version=${{ steps.git-tool.outputs.Major }}.${{ steps.git-tool.outputs.Minor }}.${{ steps.git-tool.outputs.Patch }}-${{ steps.git-tool.outputs.PreReleaseLabel }}+${{ steps.git-tool.outputs.BuildMetaData }}'
|
try:
|
||||||
fi
|
version = tools.Version(tag)
|
||||||
|
except ConanException:
|
||||||
- name: Get pull request alias
|
continue
|
||||||
id: pr-alias
|
if version > latest_branch_version:
|
||||||
run: |
|
latest_branch_version = version
|
||||||
if [ "${{ github.event_name == 'pull_request' }}" = "true" ]; then
|
latest_branch_tag = repo.tag(tag)
|
||||||
# pull request events are considered unstable and are for testing purposes
|
|
||||||
# name/latest@ultimaker/pr_<number>
|
# %% Get the actual version
|
||||||
echo "::set-output name=recipe_id_pr::${{ inputs.project_name }}/latest@${{ steps.get-conan-broadcast-data.outputs.user }}/pr_$PR_NUMBER"
|
no_commits = 0
|
||||||
else
|
for commit in repo.iter_commits("HEAD"):
|
||||||
echo "::set-output name=recipe_id_pr::''"
|
if commit == latest_branch_tag.commit:
|
||||||
fi
|
break
|
||||||
env:
|
no_commits += 1
|
||||||
PR_NUMBER: ${{ github.event.issue.number }}
|
|
||||||
|
if no_commits == 0:
|
||||||
- name: Get latest alias
|
# This is a release
|
||||||
id: latest-alias
|
actual_version = f"{latest_branch_version.major}.{latest_branch_version.minor}.{latest_branch_version.patch}"
|
||||||
run: |
|
if channel == "stable":
|
||||||
echo "::set-output name=recipe_id_latest::${{ inputs.project_name }}/latest@${{ steps.get-conan-broadcast-data.outputs.user }}/${{ steps.get-conan-broadcast-data.outputs.channel }}"
|
user = "_"
|
||||||
|
channel = "_"
|
||||||
|
else:
|
||||||
|
if event_name == "pull_request":
|
||||||
|
actual_version = f"{latest_branch_version.major}.{latest_branch_version.minor}.{latest_branch_version.patch}-{latest_branch_version.prerelease.lower()}+pr_{issue_number}_{no_commits}"
|
||||||
|
else:
|
||||||
|
if latest_branch_version.prerelease == "":
|
||||||
|
actual_version = f"{latest_branch_version.major}.{latest_branch_version.minor}.{latest_branch_version.patch}-alpha+{no_commits}"
|
||||||
|
else:
|
||||||
|
actual_version = f"{latest_branch_version.major}.{latest_branch_version.minor}.{latest_branch_version.patch}-{latest_branch_version.prerelease.lower()}+{no_commits}"
|
||||||
|
|
||||||
|
# %% print to output
|
||||||
|
print(f"::set-output name=name::{project_name}")
|
||||||
|
print(f"::set-output name=version::{actual_version}")
|
||||||
|
print(f"::set-output name=user::{user}")
|
||||||
|
print(f"::set-output name=channel::{channel}")
|
||||||
|
print(f"::set-output name=recipe_id_full::{project_name}/{actual_version}@{user}/{channel}")
|
||||||
|
print(f"::set-output name=recipe_id_latest::{project_name}/latest@{user}/{channel}")
|
||||||
|
print(f"::set-output name=semver_full::{actual_version}")
|
||||||
|
|
||||||
|
print("::group::Conan Recipe Information")
|
||||||
|
print(f"name = {project_name}")
|
||||||
|
print(f"version = {actual_version}")
|
||||||
|
print(f"user = {user}")
|
||||||
|
print(f"channel = {channel}")
|
||||||
|
print(f"recipe_id_full = {project_name}/{actual_version}@{user}/{channel}")
|
||||||
|
print(f"recipe_id_latest = {project_name}/latest@{user}/{channel}")
|
||||||
|
print(f"semver_full = {actual_version}")
|
||||||
|
print("::endgroup::")
|
||||||
|
shell: python
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
conan
|
conan
|
||||||
sip==6.5.1
|
sip==6.5.1
|
||||||
|
gitpython
|
||||||
|
Loading…
x
Reference in New Issue
Block a user