Skip to content

Conversation

@asterwyx
Copy link
Contributor

@asterwyx asterwyx commented Jun 12, 2025

Use VERSION file to manage DTK version.
Add auto release workflow.

Signed-off-by: Yixue Wang [email protected]

Summary by Sourcery

Use a dedicated VERSION file for project version management in CMake and introduce an automated GitHub Actions workflow for releasing new versions.

Enhancements:

  • Externalize DTK version into a VERSION file and load it dynamically in CMakeLists.txt.

CI:

  • Add call-auto-release.yml GitHub Actions workflow to dispatch and invoke the centralized auto-release process with configurable inputs.

Use VERSION file to manage DTK version.
Add auto release workflow.

Signed-off-by: Yixue Wang <[email protected]>
@deepin-ci-robot
Copy link
Contributor

deepin pr auto review

代码审查意见:

  1. .github/workflows/call-auto-release.yml文件中,workflow_dispatchworkflow_callinputs部分重复了,可以考虑将公共部分提取出来,减少代码冗余。

  2. CMakeLists.txt文件中,读取VERSION文件并设置DTK_VERSION的步骤是正确的,但是建议在读取文件后添加错误处理,以防止文件不存在或读取失败的情况。

  3. .reuse/dep5文件中,新增的.syncexclude文件和VERSION文件被排除在外,这可能是为了防止版本文件被同步到其他地方。但是,如果这些文件是项目的一部分,应该考虑是否需要同步。

  4. CMakeLists.txt文件中,使用file(READ)读取VERSION文件,然后使用string(STRIP)去除首尾空白字符,这是一个好的做法,可以确保版本号的一致性。

  5. CMakeLists.txt文件中,project命令的VERSION参数使用了${DTK_VERSION},这是一个好的做法,可以确保版本号的一致性。

  6. VERSION.in文件中,@version@是一个占位符,应该确保在构建过程中被替换为实际的版本号。

  7. CMakeLists.txt文件中,set(DTK_VERSION "5.6.23" CACHE STRING "Define project version")这一行被注释掉了,如果不再需要,应该删除这一行。

  8. CMakeLists.txt文件中,set(DTK_VERSION "${DTK_FILE_VERSION}" CACHE STRING "Define project version")这一行是新添加的,应该确保VERSION文件存在并且内容正确。

总体来说,代码改动看起来是合理的,但是需要注意一些细节问题,以提高代码的可维护性和可读性。

@asterwyx asterwyx requested a review from zccrs June 12, 2025 07:34
@sourcery-ai
Copy link

sourcery-ai bot commented Jun 12, 2025

Reviewer's Guide

This PR refactors project version management to use an external VERSION file instead of a hardcoded value and introduces an automated GitHub Actions workflow for releasing new versions.

Sequence Diagram: Auto Release Workflow Execution

sequenceDiagram
    actor User_Event as "User / Triggering Event"
    participant WF_Call_Auto_Release as "call-auto-release.yml (This PR)"
    participant WF_Reusable_Auto_Release as "Reusable auto-release.yml (linuxdeepin/.github)"

    User_Event->>+WF_Call_Auto_Release: Trigger (workflow_dispatch or workflow_call) with inputs (version, name, email, timezone)
    WF_Call_Auto_Release->>+WF_Reusable_Auto_Release: Call with resolved inputs and secrets
    WF_Reusable_Auto_Release-->>-WF_Call_Auto_Release: (Performs release steps)
    WF_Call_Auto_Release-->>-User_Event: (Workflow completes)
Loading

Flow Diagram: CMake Project Version Retrieval from VERSION file

graph TD
    A[Build Process Starts] --> B{Read VERSION file content};
    B --> C[Store content in DTK_FILE_VERSION];
    C --> D{Strip leading/trailing whitespace from DTK_FILE_VERSION};
    D --> E[Set DTK_VERSION project variable from cleaned DTK_FILE_VERSION];
    E --> F[Continue Build Process];
Loading

File-Level Changes

Change Details Files
Externalize project version to VERSION file
  • Remove hardcoded DTK_VERSION in CMakeLists
  • Read and strip VERSION file content into DTK_FILE_VERSION
  • Set CMake project version from DTK_FILE_VERSION
  • Add VERSION and VERSION.in template files
CMakeLists.txt
VERSION
VERSION.in
Introduce GitHub Actions auto-release workflow
  • Add reusable workflow call with dispatch inputs for version, name, email, timezone
  • Define workflow_dispatch and workflow_call interfaces
  • Inherit secrets and pass parameters to shared auto-release template
.github/workflows/call-auto-release.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @asterwyx - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.


jobs:
auto_release:
uses: linuxdeepin/.github/.github/workflows/auto-release.yml@master
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Pin reusable workflow reference

Use a commit SHA or tag instead of 'master' to avoid unexpected changes and ensure consistent workflow runs.

Suggested implementation:

  auto_release:
    uses: linuxdeepin/.github/.github/workflows/auto-release.yml@<COMMIT_SHA>
    secrets: inherit
    with:

Replace <COMMIT_SHA> with the actual commit SHA or a specific tag from the linuxdeepin/.github repository that you want to pin to. This ensures the workflow always uses the intended version.

Comment on lines +3 to +5
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" DTK_FILE_VERSION)
string(STRIP "${DTK_FILE_VERSION}" DTK_FILE_VERSION)
set(DTK_VERSION "${DTK_FILE_VERSION}" CACHE STRING "Define project version")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider documenting the management of the new version files.

Please add a brief note on how the VERSION file should be managed, either as a comment in CMakeLists.txt or in the developer documentation.

Suggested change
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" DTK_FILE_VERSION)
string(STRIP "${DTK_FILE_VERSION}" DTK_FILE_VERSION)
set(DTK_VERSION "${DTK_FILE_VERSION}" CACHE STRING "Define project version")
# The project version is read from the VERSION file in the source directory.
# To update the project version, edit the VERSION file and commit the change.
# The VERSION file should contain only the version string (e.g., 5.6.23) with no extra whitespace.
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" DTK_FILE_VERSION)
string(STRIP "${DTK_FILE_VERSION}" DTK_FILE_VERSION)
set(DTK_VERSION "${DTK_FILE_VERSION}" CACHE STRING "Define project version")

@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: asterwyx, zccrs

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@zccrs zccrs merged commit 14ebbe1 into linuxdeepin:master Jun 12, 2025
7 of 10 checks passed
@deepin-bot deepin-bot bot mentioned this pull request Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants