diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 734ab9d..95c1150 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,10 @@ name: Build +# This workflow compiles the application for Windows platform using PyInstaller, and +# archives the built artifacts as 'AutoLibrary.-windows-x86_64.zip'. +# +# It is triggered when called by the release workflow. + on: workflow_call: inputs: @@ -19,6 +24,10 @@ on: description: 'The tag name' value: ${{ jobs.build-windows.outputs.tag_name }} +# +# Build Windows +# + jobs: build-windows: runs-on: windows-latest @@ -31,6 +40,14 @@ jobs: with: 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 id: get_version run: | diff --git a/.github/workflows/commit-release.yml b/.github/workflows/commit-release.yml index c72d830..f92ee02 100644 --- a/.github/workflows/commit-release.yml +++ b/.github/workflows/commit-release.yml @@ -1,5 +1,10 @@ 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: workflow_call: inputs: @@ -35,10 +40,12 @@ jobs: ref: main 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 with: - name: updated-version-info + name: updated-version-info-for-commit path: downloaded-file/ - name: Replace file with updated version diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8ae48e2..6abfa9d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,32 @@ 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.-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: push: tags: @@ -53,7 +80,7 @@ jobs: # # Build : - # this job builds the application and archives them + # this job builds the application artifacts and archives them build: needs: diff --git a/.github/workflows/update-version.yml b/.github/workflows/update-version.yml index a1616b6..d6c717d 100644 --- a/.github/workflows/update-version.yml +++ b/.github/workflows/update-version.yml @@ -1,5 +1,13 @@ 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: workflow_call: inputs: @@ -59,16 +67,23 @@ jobs: echo "✓ Commit SHA: $COMMIT_SHA" 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 run: | VERSION="${{ steps.get_version.outputs.VERSION }}" TAG_NAME="${{ steps.get_version.outputs.TAG_NAME }}" COMMIT_SHA="${{ steps.get_version.outputs.COMMIT_SHA }}" 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') - echo "Updating $APP_INFO_FILE with build information..." + echo "Updating ALVersionInfo.py files with build information..." { echo '# -*- coding: utf-8 -*-' echo '' @@ -86,12 +101,38 @@ jobs: echo "AL_COMMIT_DATE = \"${COMMIT_DATE}\" # time zone : UTC" echo "AL_BUILD_DATE = \"${BUILD_DATE}\" # time zone : UTC" 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 "Updated ALVersionInfo.py ===============" - cat "$APP_INFO_FILE" + echo "Build version file location: $VER_INFO_BUILDFILE" + 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 "========================================" - name: Check if ALVersionInfo.py was modified @@ -105,10 +146,18 @@ jobs: echo "✓ ALVersionInfo.py has been modified" fi - - name: Upload modified ALVersionInfo.py + - name: Upload modified ALVersionInfo.py ready for build if: steps.check_changes.outputs.has_changes == 'true' uses: actions/upload-artifact@v4 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 retention-days: 1 \ No newline at end of file