mirror of
https://github.com/KenanZhu/AutoLibrary.git
synced 2026-06-18 07:23:03 +08:00
ci(workflow): 优化 update-version.yml 中的版本信息更新逻辑
对 ALVersionInfo.py 文件的更新逻辑进行差异化处理,分别为 commit-release 和 build 阶段生成不同的 artifact: * 针对 commit-release 阶段:将所有与构建(build)相关的字段值设置为 'local' 或 'null' * 针对 build 阶段:保留完整的版本信息字段 这种差异化处理确保其后续提交的 release commit 不会包含构建相关的版本信息。
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
name: Build
|
name: Build
|
||||||
|
|
||||||
|
# This workflow compiles the application for Windows platform using PyInstaller, and
|
||||||
|
# archives the built artifacts as 'AutoLibrary.<tag_name>-windows-x86_64.zip'.
|
||||||
|
#
|
||||||
|
# It is triggered when called by the release workflow.
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
@@ -19,6 +24,10 @@ on:
|
|||||||
description: 'The tag name'
|
description: 'The tag name'
|
||||||
value: ${{ jobs.build-windows.outputs.tag_name }}
|
value: ${{ jobs.build-windows.outputs.tag_name }}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Build Windows
|
||||||
|
#
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-windows:
|
build-windows:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
@@ -31,6 +40,14 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
ref: main
|
ref: main
|
||||||
|
|
||||||
|
# here we download the build version of ALVersionInfo.py from artifacts
|
||||||
|
# and replace the committed version
|
||||||
|
- name: Download build version of ALVersionInfo.py
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: updated-version-info-for-build
|
||||||
|
path: src/gui/
|
||||||
|
|
||||||
- name: Get version info
|
- name: Get version info
|
||||||
id: get_version
|
id: get_version
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
name: Commit Release
|
name: Commit Release
|
||||||
|
|
||||||
|
# This workflow commits version changes in 'ALVersionInfo.py' (get from artifacts) and
|
||||||
|
# moves the release tag to this new release commit.
|
||||||
|
#
|
||||||
|
# It is triggered when called by the release workflow.
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
@@ -35,10 +40,12 @@ jobs:
|
|||||||
ref: main
|
ref: main
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Download modified file
|
# here we download the commit version of ALVersionInfo.py from artifacts
|
||||||
|
# and replace the original file with it.
|
||||||
|
- name: Download commit version of ALVersionInfo.py
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: updated-version-info
|
name: updated-version-info-for-commit
|
||||||
path: downloaded-file/
|
path: downloaded-file/
|
||||||
|
|
||||||
- name: Replace file with updated version
|
- name: Replace file with updated version
|
||||||
|
|||||||
@@ -1,5 +1,32 @@
|
|||||||
name: Release
|
name: Release
|
||||||
|
|
||||||
|
# This workflow automates the complete release process for AutoLibrary application
|
||||||
|
# It is triggered when a new version tag (vX.Y.Z) is pushed to the repository
|
||||||
|
#
|
||||||
|
# Workflow Steps:
|
||||||
|
# START >
|
||||||
|
|
||||||
|
# 1. Update Version:
|
||||||
|
# Updates version information in 'ALVersionInfo.py' with build metadata and archives
|
||||||
|
# the updated version file as an artifact.
|
||||||
|
#
|
||||||
|
# for more information, please refer to the comment in the workflow 'update-version.yml'
|
||||||
|
|
||||||
|
# 2. Commit Release:
|
||||||
|
# Commits version changes and moves the release tag to this new release commit.
|
||||||
|
|
||||||
|
# 3. Build:
|
||||||
|
# Compiles the application for Windows platform using PyInstaller, and
|
||||||
|
# archives the built artifacts as 'AutoLibrary.<tag_name>-windows-x86_64.zip'.
|
||||||
|
|
||||||
|
# 4. Release:
|
||||||
|
# Creates GitHub release with generated artifacts and release notes
|
||||||
|
|
||||||
|
# < END
|
||||||
|
#
|
||||||
|
# The workflow ensures version consistency between source code, built artifacts, and GitHub releases
|
||||||
|
# while maintaining proper commit history and tag management.
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
@@ -53,7 +80,7 @@ jobs:
|
|||||||
|
|
||||||
#
|
#
|
||||||
# Build :
|
# Build :
|
||||||
# this job builds the application and archives them
|
# this job builds the application artifacts and archives them
|
||||||
|
|
||||||
build:
|
build:
|
||||||
needs:
|
needs:
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
name: Update Version
|
name: Update Version
|
||||||
|
|
||||||
|
# This workflow updates version information in 'ALVersionInfo.py' with build metadata.
|
||||||
|
# In progress, it will generate two version files, the first one is locate in 'src/gui/ALVersionInfo.py',
|
||||||
|
# and the second one is locate in 'src/gui/temp/ALVersionInfo.py'. The first one is use
|
||||||
|
# in the release process, it only update the version and tag name. The commit and build infomation
|
||||||
|
# is 'local' or 'null'. All of them will finally archive as artifacts.
|
||||||
|
#
|
||||||
|
# It is triggered when called by the release workflow.
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
@@ -59,16 +67,23 @@ jobs:
|
|||||||
echo "✓ Commit SHA: $COMMIT_SHA"
|
echo "✓ Commit SHA: $COMMIT_SHA"
|
||||||
echo "✓ Commit Date: $COMMIT_DATE"
|
echo "✓ Commit Date: $COMMIT_DATE"
|
||||||
|
|
||||||
|
- name: Create 'temp' directory
|
||||||
|
run: |
|
||||||
|
echo "Creating temp directory..."
|
||||||
|
mkdir -p "src/gui/temp"
|
||||||
|
echo "✓ temp directory created successfully"
|
||||||
|
|
||||||
- name: Update ALVersionInfo.py with version info
|
- name: Update ALVersionInfo.py with version info
|
||||||
run: |
|
run: |
|
||||||
VERSION="${{ steps.get_version.outputs.VERSION }}"
|
VERSION="${{ steps.get_version.outputs.VERSION }}"
|
||||||
TAG_NAME="${{ steps.get_version.outputs.TAG_NAME }}"
|
TAG_NAME="${{ steps.get_version.outputs.TAG_NAME }}"
|
||||||
COMMIT_SHA="${{ steps.get_version.outputs.COMMIT_SHA }}"
|
COMMIT_SHA="${{ steps.get_version.outputs.COMMIT_SHA }}"
|
||||||
COMMIT_DATE="${{ steps.get_version.outputs.COMMIT_DATE }}"
|
COMMIT_DATE="${{ steps.get_version.outputs.COMMIT_DATE }}"
|
||||||
APP_INFO_FILE="src/gui/ALVersionInfo.py"
|
VER_INFO_BUILDFILE="src/gui/temp/ALVersionInfo.py"
|
||||||
|
VER_INFO_COMMITFILE="src/gui/ALVersionInfo.py"
|
||||||
BUILD_DATE=$(date -u '+%Y-%m-%d %H:%M:%S UTC')
|
BUILD_DATE=$(date -u '+%Y-%m-%d %H:%M:%S UTC')
|
||||||
|
|
||||||
echo "Updating $APP_INFO_FILE with build information..."
|
echo "Updating ALVersionInfo.py files with build information..."
|
||||||
{
|
{
|
||||||
echo '# -*- coding: utf-8 -*-'
|
echo '# -*- coding: utf-8 -*-'
|
||||||
echo ''
|
echo ''
|
||||||
@@ -86,12 +101,38 @@ jobs:
|
|||||||
echo "AL_COMMIT_DATE = \"${COMMIT_DATE}\" # time zone : UTC"
|
echo "AL_COMMIT_DATE = \"${COMMIT_DATE}\" # time zone : UTC"
|
||||||
echo "AL_BUILD_DATE = \"${BUILD_DATE}\" # time zone : UTC"
|
echo "AL_BUILD_DATE = \"${BUILD_DATE}\" # time zone : UTC"
|
||||||
echo 'AL_VERSION_FULL = f"{AL_VERSION} ({AL_COMMIT_SHA})"'
|
echo 'AL_VERSION_FULL = f"{AL_VERSION} ({AL_COMMIT_SHA})"'
|
||||||
} > "$APP_INFO_FILE"
|
} > "$VER_INFO_BUILDFILE"
|
||||||
|
|
||||||
echo "✓ ALVersionInfo.py updated successfully"
|
echo "Updating ALVersionInfo.py for release commit..."
|
||||||
|
{
|
||||||
|
echo '# -*- coding: utf-8 -*-'
|
||||||
|
echo ''
|
||||||
|
echo '"""'
|
||||||
|
echo ' The contents of this file will automatically be updated by the'
|
||||||
|
echo ' workflow process. Do not edit manually.'
|
||||||
|
echo ''
|
||||||
|
echo ' This file is auto-generated during the workflow process.'
|
||||||
|
echo " Last updated: ${BUILD_DATE}"
|
||||||
|
echo '"""'
|
||||||
|
echo ''
|
||||||
|
echo "AL_VERSION = \"${VERSION}\""
|
||||||
|
echo "AL_TAG = \"${TAG_NAME}\""
|
||||||
|
echo "AL_COMMIT_SHA = \"local\""
|
||||||
|
echo "AL_COMMIT_DATE = \"null\" # time zone : UTC"
|
||||||
|
echo "AL_BUILD_DATE = \"null\" # time zone : UTC"
|
||||||
|
echo 'AL_VERSION_FULL = f"{AL_VERSION} ({AL_COMMIT_SHA})"'
|
||||||
|
} > "$VER_INFO_COMMITFILE"
|
||||||
|
|
||||||
|
echo "✓ ALVersionInfo.py files updated successfully"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Updated ALVersionInfo.py ==============="
|
echo "Build version file location: $VER_INFO_BUILDFILE"
|
||||||
cat "$APP_INFO_FILE"
|
echo "Commit version file location: $VER_INFO_COMMITFILE"
|
||||||
|
echo ""
|
||||||
|
echo "Build version ALVersionInfo.py content ="
|
||||||
|
cat "$VER_INFO_BUILDFILE"
|
||||||
|
echo ""
|
||||||
|
echo "Commit version ALVersionInfo.py content "
|
||||||
|
cat "$VER_INFO_COMMITFILE"
|
||||||
echo "========================================"
|
echo "========================================"
|
||||||
|
|
||||||
- name: Check if ALVersionInfo.py was modified
|
- name: Check if ALVersionInfo.py was modified
|
||||||
@@ -105,10 +146,18 @@ jobs:
|
|||||||
echo "✓ ALVersionInfo.py has been modified"
|
echo "✓ ALVersionInfo.py has been modified"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Upload modified ALVersionInfo.py
|
- name: Upload modified ALVersionInfo.py ready for build
|
||||||
if: steps.check_changes.outputs.has_changes == 'true'
|
if: steps.check_changes.outputs.has_changes == 'true'
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: updated-version-info
|
name: updated-version-info-for-build
|
||||||
|
path: src/gui/temp/ALVersionInfo.py
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
- name: Upload modified ALVersionInfo.py ready for commit
|
||||||
|
if: steps.check_changes.outputs.has_changes == 'true'
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: updated-version-info-for-commit
|
||||||
path: src/gui/ALVersionInfo.py
|
path: src/gui/ALVersionInfo.py
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
Reference in New Issue
Block a user