From 21d63ad99fb2ae80205b0367c978c88352d19e2c Mon Sep 17 00:00:00 2001 From: "Schmieder, Jacob" Date: Thu, 30 May 2024 11:46:20 +0000 Subject: [PATCH 1/6] updated and added semver CI --- .github/workflows/check_semver.yaml | 75 +++++++++++++++++++++++++++++ .github/workflows/semver.yml | 75 ++++++++++++++++++++++++----- 2 files changed, 137 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/check_semver.yaml diff --git a/.github/workflows/check_semver.yaml b/.github/workflows/check_semver.yaml new file mode 100644 index 0000000..ccfd2b8 --- /dev/null +++ b/.github/workflows/check_semver.yaml @@ -0,0 +1,75 @@ +name: Check and Add Version in Changelog + +on: + pull_request: + branches: + - main + - develop + +jobs: + check-and-add-version: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Extract and Determine Version + id: extract_version + run: | + # Fetch the latest tags from the remote + git fetch --tags + + # Get the latest tag, or initialize to v0.0.0 if no tags are found + latest_tag=$(git describe --tags `git rev-list --tags --max-count=1` 2>/dev/null || echo "v0.0.0") + + # Extract version from PR title or body + pr_body="${{ github.event.pull_request.body }}" + pr_title="${{ github.event.pull_request.title }}" + version_regex="v([0-9]+)\.([0-9]+)\.([0-9]+)" + + if [[ $pr_body =~ $version_regex ]]; then + major=${BASH_REMATCH[1]} + minor=${BASH_REMATCH[2]} + patch=${BASH_REMATCH[3]} + new_tag="v$major.$minor.$patch" + elif [[ $pr_title =~ $version_regex ]]; then + major=${BASH_REMATCH[1]} + minor=${BASH_REMATCH[2]} + patch=${BASH_REMATCH[3]} + new_tag="v$major.$minor.$patch" + else + # Split the latest tag into parts + IFS='.' read -r -a parts <<< "${latest_tag#v}" + major=${parts[0]} + minor=${parts[1]} + patch=${parts[2]} + patch=$((patch + 1)) + new_tag="v$major.$minor.$patch" + fi + + clean_version="${new_tag#v}" + echo "version=$clean_version" >> $GITHUB_ENV + echo "Version determined: $clean_version" + + - name: Check if Version Already Exists in Tags + run: | + version="${{ env.version }}" + if git tag --list | grep -q "^$version$"; then + echo "Version $version already exists in tags." + exit 1 + else + echo "Version $version does not exist in tags." + fi + + - name: Check Version in CHANGELOG + id: check_version + run: | + version="${{ env.version }}" + if ! grep -q "^## \[$version\]" CHANGELOG.md; then + echo "Version $version not found in CHANGELOG.md." + exit 1 + else + echo "Version $version found in CHANGELOG.md." + fi diff --git a/.github/workflows/semver.yml b/.github/workflows/semver.yml index c6d5fb1..a4f97d3 100644 --- a/.github/workflows/semver.yml +++ b/.github/workflows/semver.yml @@ -8,7 +8,7 @@ on: jobs: bump-version: - if: ${{ github.event.pull_request.merged == true $$ github.event.pull_request.base.ref == 'main' }} + if: ${{ github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' }} runs-on: ubuntu-latest steps: - name: Checkout Repository @@ -17,27 +17,46 @@ jobs: fetch-depth: 0 - name: Bump Version and Tag + id: bump_version + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} run: | # Fetch the latest tags from the remote git fetch --tags - # Get the latest tag - latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) + # Get the latest tag, or initialize to v0.0.0 if no tags are found + latest_tag=$(git describe --tags `git rev-list --tags --max-count=1` 2>/dev/null || echo "v0.0.0") - # Split the latest tag into parts - IFS='.' read -r -a parts <<< "${latest_tag#v}" + # Extract version from PR title or body + pr_body="${{ github.event.pull_request.body }}" + pr_title="${{ github.event.pull_request.title }}" + version_regex="v([0-9]+)\.([0-9]+)\.([0-9]+)" - # Increment the patch version - major=${parts[0]} - minor=${parts[1]} - patch=${parts[2]} - new_patch=$((patch + 1)) - - # Create a new tag - new_tag="v$major.$minor.$new_patch" + if [[ $pr_body =~ $version_regex ]]; then + major=${BASH_REMATCH[1]} + minor=${BASH_REMATCH[2]} + patch=${BASH_REMATCH[3]} + new_tag="v$major.$minor.$patch" + elif [[ $pr_title =~ $version_regex ]]; then + major=${BASH_REMATCH[1]} + minor=${BASH_REMATCH[2]} + patch=${BASH_REMATCH[3]} + new_tag="v$major.$minor.$patch" + else + # Split the latest tag into parts + IFS='.' read -r -a parts <<< "${latest_tag#v}" + major=${parts[0]} + minor=${parts[1]} + patch=${parts[2]} + patch=$((patch + 1)) + new_tag="v$major.$minor.$patch" + fi echo "Bumping version from $latest_tag to $new_tag" + # Set the new tag as an environment variable + echo "new_tag=$new_tag" >> $GITHUB_ENV + # Tag the new version git tag $new_tag @@ -46,3 +65,33 @@ jobs: # Push the new tag to the remote repository git push origin $new_tag + + - name: Extract Release Notes + id: extract_notes + run: | + version="${{ env.new_tag }}" + clean_version="${version#v}" + release_notes=$(awk -v version="$clean_version" ' + BEGIN { flag=0 } + # Start flagging when the version section is found + /^## \[.*\]/ { + if (flag) exit # Exit when the next section starts + } + /^## \['"$clean_version"'\]/ { flag=1; next } # Start printing after the header + flag { print } # Print lines while flag is 1 + ' CHANGELOG.md) + echo "RELEASE_NOTES<> $GITHUB_ENV + echo "$release_notes" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + + - name: Create Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + with: + tag_name: ${{ env.new_tag }} + release_name: Release ${{ env.new_tag }} + body: ${{ env.RELEASE_NOTES }} + draft: false + prerelease: false + \ No newline at end of file From 0ae39c1167a7665d3faae8cf10074e69f5d62695 Mon Sep 17 00:00:00 2001 From: "Schmieder, Jacob" Date: Fri, 31 May 2024 08:29:25 +0000 Subject: [PATCH 2/6] ruff runs just on push --- .github/workflows/ruff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index 271e0b4..1e5c277 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -1,5 +1,5 @@ name: Ruff -on: [ push, pull_request ] +on: push jobs: ruff: runs-on: ubuntu-latest From 7451cc5346bbb31851134fa2cb404dcc4d432c8c Mon Sep 17 00:00:00 2001 From: "Schmieder, Jacob" Date: Fri, 31 May 2024 10:35:30 +0000 Subject: [PATCH 3/6] changed branch to develop --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b850f63..cadc678 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,7 +47,7 @@ strict = true format-jinja = """ {%- if distance == 0 -%} {{ serialize_pep440(base) }} - {%- elif branch == 'pyproject.toml' -%} + {%- elif branch == 'develop' -%} {{ serialize_pep440(bump_version(base), dev = distance) }} {%- else -%} {{ serialize_pep440(bump_version(base), dev=distance, metadata=[commit]) }} From 1ef2db3442f80f21e7c4b52cd34cbbfba683fc20 Mon Sep 17 00:00:00 2001 From: "Schmieder, Jacob" Date: Fri, 31 May 2024 10:38:23 +0000 Subject: [PATCH 4/6] added whisperx --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index cadc678..9dbf2c0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ python = "^3.9" tqdm = "^4.66.4" numpy = "^1.26.4" openai-whisper = "^20231117" +whisperx = "^3.1.3" "pyannote.audio" = "^3.2.0" torch = "^2.3.0" From 740629b83ab136103d455c00eda2390e1314a949 Mon Sep 17 00:00:00 2001 From: "Schmieder, Jacob" Date: Fri, 31 May 2024 10:40:11 +0000 Subject: [PATCH 5/6] make whisperx happy --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9dbf2c0..6c9fa08 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ tqdm = "^4.66.4" numpy = "^1.26.4" openai-whisper = "^20231117" whisperx = "^3.1.3" -"pyannote.audio" = "^3.2.0" +pyannote.audio = "^3.1.1" torch = "^2.3.0" [tool.poetry.group.dev.dependencies] From a9cf43cd2db1a1b9978667e6e8c0d8f916ece546 Mon Sep 17 00:00:00 2001 From: "Schmieder, Jacob" Date: Fri, 31 May 2024 10:40:54 +0000 Subject: [PATCH 6/6] make pypi happy --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6c9fa08..8c46bdb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ tqdm = "^4.66.4" numpy = "^1.26.4" openai-whisper = "^20231117" whisperx = "^3.1.3" -pyannote.audio = "^3.1.1" +"pyannote.audio" = "^3.1.1" torch = "^2.3.0" [tool.poetry.group.dev.dependencies]