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
This commit is contained in:
parent
2188e62d4b
commit
fe3eb986de
3 changed files with 34 additions and 10 deletions
32
.github/workflows/release.yml
vendored
32
.github/workflows/release.yml
vendored
|
|
@ -9,7 +9,6 @@ permissions:
|
||||||
jobs:
|
jobs:
|
||||||
validate-release:
|
validate-release:
|
||||||
name: Validate Release
|
name: Validate Release
|
||||||
if: github.ref == 'refs/heads/main'
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -23,7 +22,12 @@ jobs:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
version="$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")"
|
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
|
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."
|
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:
|
build-windows:
|
||||||
name: Build Windows
|
name: Build Windows
|
||||||
if: github.ref == 'refs/heads/main'
|
|
||||||
needs: validate-release
|
needs: validate-release
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
|
||||||
|
|
@ -72,7 +75,6 @@ jobs:
|
||||||
|
|
||||||
build-linux:
|
build-linux:
|
||||||
name: Build Linux
|
name: Build Linux
|
||||||
if: github.ref == 'refs/heads/main'
|
|
||||||
needs: validate-release
|
needs: validate-release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
|
@ -110,7 +112,6 @@ jobs:
|
||||||
|
|
||||||
build-macos:
|
build-macos:
|
||||||
name: Build Macos
|
name: Build Macos
|
||||||
if: github.ref == 'refs/heads/main'
|
|
||||||
needs: validate-release
|
needs: validate-release
|
||||||
runs-on: macos-15-intel
|
runs-on: macos-15-intel
|
||||||
|
|
||||||
|
|
@ -145,7 +146,6 @@ jobs:
|
||||||
|
|
||||||
release:
|
release:
|
||||||
name: Release
|
name: Release
|
||||||
if: github.ref == 'refs/heads/main'
|
|
||||||
needs: [build-windows, build-linux, build-macos]
|
needs: [build-windows, build-linux, build-macos]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
|
@ -164,9 +164,14 @@ jobs:
|
||||||
- name: Build Release Notes
|
- name: Build Release Notes
|
||||||
run: |
|
run: |
|
||||||
version="${{ steps.package-version.outputs.version }}"
|
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 }}"
|
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}"
|
echo "Release ${tag}"
|
||||||
|
|
@ -216,7 +221,14 @@ jobs:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
version="${{ steps.package-version.outputs.version }}"
|
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=(
|
files=(
|
||||||
nte-history-exporter.exe
|
nte-history-exporter.exe
|
||||||
nte-history-exporter-linux
|
nte-history-exporter-linux
|
||||||
|
|
@ -236,4 +248,4 @@ jobs:
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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[@]}"
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@ def check_for_update(current_version: str, *, timeout: float = 1.5) -> UpdateInf
|
||||||
except Exception:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
if latest.get("prerelease"):
|
||||||
|
return None
|
||||||
|
|
||||||
latest_version = str(latest.get("tag_name", "")).strip()
|
latest_version = str(latest.get("tag_name", "")).strip()
|
||||||
release_url = str(latest.get("html_url", "")).strip() or RELEASES_URL
|
release_url = str(latest.get("html_url", "")).strip() or RELEASES_URL
|
||||||
if not latest_version or not is_newer_version(latest_version, current_version):
|
if not latest_version or not is_newer_version(latest_version, current_version):
|
||||||
|
|
|
||||||
|
|
@ -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):
|
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")):
|
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))
|
self.assertIsNone(check_for_update("0.1.6", timeout=0.1))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue