From 1843bfea5fefb2d0834465ef60957bac37e43ea3 Mon Sep 17 00:00:00 2001 From: Xida Ren Date: Thu, 27 Jun 2024 19:16:02 -0700 Subject: [PATCH 1/2] fix problem in new ci --- .github/workflows/nightly-release.yml | 25 ++++++++++++++++--------- .github/workflows/release.yml | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index 7e87e4c..fcee3b9 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -28,18 +28,25 @@ jobs: - name: Determine nightly version id: version + env: + GITHUB_RUN_NUMBER: ${{ github.run_number }} run: | current_version=$(python -c " - import re - with open('uniclip/__init__.py', 'r') as f: - content = f.read() - match = re.search(r\"__version__\s*=\s*['\\\"]([^'\\\"]*)['\\\"]\", content) - if match: - print(match.group(1)) - else: - print('0.0.0') # fallback version +import re +with open('uniclip/__init__.py', 'r') as f: + content = f.read() +match = re.search(r\"__version__\s*=\s*['\\\"]([^'\\\"]*)['\\\"]\", content) +if match: + print(match.group(1)) +else: + print('0.0.0') # fallback version + ") + nightly_version=$(python -c " +import semver +import os +v = semver.VersionInfo.parse('$current_version') +print(f'{v.major}.{v.minor}.{v.patch}-nightly.{os.environ['GITHUB_RUN_NUMBER']}') ") - nightly_version=$(python -c "import semver; v = semver.VersionInfo.parse('$current_version'); print(f'{v.major}.{v.minor}.{v.patch}-nightly.{github.run_number}')") echo "nightly_version=$nightly_version" >> "$GITHUB_OUTPUT" - name: Create Nightly Release diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 47a69ee..29e4c8e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -70,4 +70,4 @@ jobs: git config --local user.name "GitHub Action" git add README.md git commit -m "Update version in README to ${{ steps.version.outputs.official_version }}" - git push + git push \ No newline at end of file From c68bfebd2b6ff4ec8bba5cbe3749eb597aedeaa0 Mon Sep 17 00:00:00 2001 From: Xida Ren Date: Thu, 27 Jun 2024 19:23:29 -0700 Subject: [PATCH 2/2] use bash instead of janky python --- .github/workflows/nightly-release.yml | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index fcee3b9..187360e 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -28,26 +28,15 @@ jobs: - name: Determine nightly version id: version - env: - GITHUB_RUN_NUMBER: ${{ github.run_number }} run: | - current_version=$(python -c " -import re -with open('uniclip/__init__.py', 'r') as f: - content = f.read() -match = re.search(r\"__version__\s*=\s*['\\\"]([^'\\\"]*)['\\\"]\", content) -if match: - print(match.group(1)) -else: - print('0.0.0') # fallback version - ") - nightly_version=$(python -c " -import semver -import os -v = semver.VersionInfo.parse('$current_version') -print(f'{v.major}.{v.minor}.{v.patch}-nightly.{os.environ['GITHUB_RUN_NUMBER']}') - ") + current_version=$(grep -oP "__version__\s*=\s*['\"]?\K[^'\"']+" uniclip/__init__.py || echo "0.0.0") + IFS='.' read -r major minor patch <<< "$current_version" + prerelease=$(echo "$patch" | grep -oP '[-+].*$' || echo "") + patch=$(echo "$patch" | grep -oP '^\d+' || echo "0") + nightly_version="${major}.${minor}.${patch}-nightly.${GITHUB_RUN_NUMBER}${prerelease}" echo "nightly_version=$nightly_version" >> "$GITHUB_OUTPUT" + echo "Current version: $current_version" + echo "Nightly version: $nightly_version" - name: Create Nightly Release id: create_release @@ -58,4 +47,4 @@ print(f'{v.major}.{v.minor}.{v.patch}-nightly.{os.environ['GITHUB_RUN_NUMBER']}' tag_name: nightly-v${{ steps.version.outputs.nightly_version }} release_name: Nightly Release ${{ steps.version.outputs.nightly_version }} draft: false - prerelease: true \ No newline at end of file + prerelease: true