From fe3eb986def103f53795eddb0ea9169f845e9542 Mon Sep 17 00:00:00 2001 From: Golumpa Date: Tue, 23 Jun 2026 15:46:37 +0100 Subject: [PATCH] all non main releases all non main releases will be marked as a pre release so we can build releases that do not get sent out as an update notification to everyone just yet --- .github/workflows/release.yml | 32 ++++++++++++++++-------- src/nte_history_exporter/update_check.py | 3 +++ tests/test_boundary_export.py | 9 +++++++ 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c995162..37cd713 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,7 +9,6 @@ permissions: jobs: validate-release: name: Validate Release - if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps: @@ -23,7 +22,12 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | version="$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")" - tag="v${version}" + if [ "${{ github.ref }}" = "refs/heads/main" ]; then + tag="v${version}" + else + safe_ref="$(echo "${{ github.ref_name }}" | tr '/_' '--' | tr -cd '[:alnum:].-')" + tag="v${version}-${safe_ref}.${GITHUB_RUN_NUMBER}" + fi if git rev-parse -q --verify "refs/tags/${tag}" >/dev/null; then echo "::error title=Release tag already exists::${tag} already exists. Bump project.version in pyproject.toml before running the release workflow." @@ -37,7 +41,6 @@ jobs: build-windows: name: Build Windows - if: github.ref == 'refs/heads/main' needs: validate-release runs-on: windows-latest @@ -72,7 +75,6 @@ jobs: build-linux: name: Build Linux - if: github.ref == 'refs/heads/main' needs: validate-release runs-on: ubuntu-latest @@ -110,7 +112,6 @@ jobs: build-macos: name: Build Macos - if: github.ref == 'refs/heads/main' needs: validate-release runs-on: macos-15-intel @@ -145,7 +146,6 @@ jobs: release: name: Release - if: github.ref == 'refs/heads/main' needs: [build-windows, build-linux, build-macos] runs-on: ubuntu-latest @@ -164,9 +164,14 @@ jobs: - name: Build Release Notes run: | version="${{ steps.package-version.outputs.version }}" - tag="v${version}" + if [ "${{ github.ref }}" = "refs/heads/main" ]; then + tag="v${version}" + else + safe_ref="$(echo "${{ github.ref_name }}" | tr '/_' '--' | tr -cd '[:alnum:].-')" + tag="v${version}-${safe_ref}.${GITHUB_RUN_NUMBER}" + fi repo_url="${{ github.server_url }}/${{ github.repository }}" - previous_tag="$(git tag --merged HEAD --sort=-v:refname | grep -E '^v[0-9]+(\.[0-9]+)*' | grep -vx "$tag" | head -n 1 || true)" + previous_tag="$(git tag --merged HEAD --sort=-v:refname | grep -E '^v[0-9]+(\.[0-9]+)*$' | grep -vx "$tag" | head -n 1 || true)" { echo "Release ${tag}" @@ -216,7 +221,14 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | version="${{ steps.package-version.outputs.version }}" - tag="v${version}" + if [ "${{ github.ref }}" = "refs/heads/main" ]; then + tag="v${version}" + prerelease_args=() + else + safe_ref="$(echo "${{ github.ref_name }}" | tr '/_' '--' | tr -cd '[:alnum:].-')" + tag="v${version}-${safe_ref}.${GITHUB_RUN_NUMBER}" + prerelease_args=(--prerelease) + fi files=( nte-history-exporter.exe nte-history-exporter-linux @@ -236,4 +248,4 @@ jobs: exit 1 fi - gh release create "$tag" "${files[@]}" --title "${tag} Release" --notes-file release-notes.md + gh release create "$tag" "${files[@]}" --title "${tag} Release" --notes-file release-notes.md "${prerelease_args[@]}" diff --git a/src/nte_history_exporter/update_check.py b/src/nte_history_exporter/update_check.py index 53b484f..79f79eb 100644 --- a/src/nte_history_exporter/update_check.py +++ b/src/nte_history_exporter/update_check.py @@ -29,6 +29,9 @@ def check_for_update(current_version: str, *, timeout: float = 1.5) -> UpdateInf except Exception: return None + if latest.get("prerelease"): + return None + latest_version = str(latest.get("tag_name", "")).strip() release_url = str(latest.get("html_url", "")).strip() or RELEASES_URL if not latest_version or not is_newer_version(latest_version, current_version): diff --git a/tests/test_boundary_export.py b/tests/test_boundary_export.py index 9e1c925..4979583 100644 --- a/tests/test_boundary_export.py +++ b/tests/test_boundary_export.py @@ -225,6 +225,15 @@ class BoundaryExportTests(unittest.TestCase): ), ) + def test_update_check_ignores_prerelease(self): + latest = { + "tag_name": "v0.1.8-dev-branch.123", + "html_url": "https://github.com/Golumpa/nte-exporter/releases/tag/v0.1.8-dev-branch.123", + "prerelease": True, + } + with patch("nte_history_exporter.update_check.fetch_latest_release", return_value=latest): + self.assertIsNone(check_for_update("0.1.7", timeout=0.1)) + def test_update_check_is_quiet_when_unavailable_or_current(self): with patch("nte_history_exporter.update_check.fetch_latest_release", side_effect=OSError("offline")): self.assertIsNone(check_for_update("0.1.6", timeout=0.1))