Skip to content

fix: streamline build process by executing PyInstaller from project r… #26

fix: streamline build process by executing PyInstaller from project r…

fix: streamline build process by executing PyInstaller from project r… #26

Workflow file for this run

name: Create Tag and Release
on:
pull_request:
types: [closed, synchronize]
branches:
- main
- 1.2.0-release-2
concurrency:
group: create-tag-and-release-${{ github.ref }}
cancel-in-progress: true
jobs:
# Job 1: Validate the PR and extract version
validate_and_tag:
# if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
outputs:
version: ${{ steps.validate_title.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT_TOKEN }}
submodules: "recursive"
- name: Validate branch name and extract version
id: validate_title
run: |
branch_name="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
echo "Branch name: $branch_name"
if [[ "$branch_name" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9-]+)?$ ]]; then
version=$(echo "$branch_name" | grep -oE '^v[0-9]+\.[0-9]+\.[0-9]+')
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Matched version: $version"
else
echo "Branch name does not match the required format (vX.X.X or vX.X.X-suffix)."
exit 1 # Exit with failure
fi
shell: bash
- name: Create a tag
if: ${{ steps.validate_title.outputs.version != '' }}
run: |
version=${{ steps.validate_title.outputs.version }}
# 检查本地是否存在该 Tag
tag_exists=$(git tag -l "$version")
if [ -z "$tag_exists" ]; then
# 本地不存在该 Tag,创建 Tag
git tag "$version"
# 检查远程是否存在该 Tag
remote_tag_exists=$(git ls-remote --tags origin | grep "refs/tags/$version" || true)
if [ -z "$remote_tag_exists" ]; then
# 如果远程也不存在,推送 Tag
git push origin "$version"
echo "Tag $version created and pushed successfully."
else
echo "Tag $version already exists in remote. Skipping push."
fi
else
echo "Tag $version already exists locally. Skipping tag creation and push."
fi
shell: bash
- name: List all files in the workspace
run: |
echo "Workspace directory: $GITHUB_WORKSPACE"
ls -la $GITHUB_WORKSPACE
echo "Listing all files recursively:"
find $GITHUB_WORKSPACE
- name: Create release assets archive
run: |
output_zip="sub-adjust_${{ steps.validate_title.outputs.version }}.zip"
assets_file="$GITHUB_WORKSPACE/.github/workflows/PackageAssets.txt"
# 创建包含指定文件的压缩包
while IFS= read -r asset; do
echo "Adding asset: $asset"
zip -r "$output_zip" "$GITHUB_WORKSPACE/$asset"
done < "$assets_file"
shell: bash
# Create a release and upload the zip file
- name: Create GitHub release
id: create_release
if: ${{ steps.validate_title.outputs.version != '' }}
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.validate_title.outputs.version }}
release_name: ${{ steps.validate_title.outputs.version }}
body: |
Automatically created release for version ${{ steps.validate_title.outputs.version }}.
### PR Description:
${{ github.event.pull_request.body }}
draft: false
prerelease: false
commitish: ${{ github.sha }}
# Upload the zip file as the release asset
- name: Upload zip file to release
if: ${{ steps.validate_title.outputs.version != '' }}
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./sub-adjust_${{ steps.validate_title.outputs.version }}.zip
asset_name: sub-adjust_${{ steps.validate_title.outputs.version }}.zip
asset_content_type: application/zip