diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml new file mode 100644 index 000000000..36046611d --- /dev/null +++ b/.github/workflows/beta-release.yml @@ -0,0 +1,47 @@ +name: Create Pre-Release on Version Change + +on: + push: + branches: + - v3-alpha + +jobs: + check-version-and-create-release: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '14' + + - name: Install dependencies + run: npm install + + - name: Get previous package version + id: get_prev_version + run: echo "::set-output name=prev_version::$(git show HEAD^:package.json | jq -r '.version')" + + - name: Get current package version + id: get_current_version + run: echo "::set-output name=current_version::$(jq -r '.version' package.json)" + + - name: Compare versions + id: compare_versions + run: | + if [[ "${{ steps.get_prev_version.outputs.prev_version }}" != "${{ steps.get_current_version.outputs.current_version }}" ]]; then + echo "Version changed. Creating Pre-Release." + echo "::set-output name=version_changed::true" + else + echo "Version unchanged. No Pre-Release needed." + echo "::set-output name=version_changed::false" + fi + + - name: Create Pre-Release + if: steps.compare_versions.outputs.version_changed == 'true' + run: | + # Create a new Pre-Release using GitHub API + curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/:owner/:repo/releases -d '{"tag_name": "v${{ steps.get_current_version.outputs.current_version }}", "prerelease": true, "draft": false}' diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 78b746a00..d5ab7c02d 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -1,7 +1,9 @@ name: Build and push Docker image on: - push: + push: + branches: + - v3-alpha env: REGISTRY: ghcr.io diff --git a/app/scheduler.py b/app/scheduler.py index ad9aab854..b186b83ce 100644 --- a/app/scheduler.py +++ b/app/scheduler.py @@ -57,6 +57,17 @@ def scan_users(): info("Scanning for new users") global_sync_users() +@schedule.task("interval", id="checkForUpdates", minutes=10, misfire_grace_time=900) +def check_for_updates(): + # Import the function here to avoid circular imports + from app.utils.software_lifecycle import need_update + from app import app + + info("Checking for updates") + + # Update jinja global variable + app.jinja_env.globals.update(APP_UPDATE=need_update()) + # Ignore these helper functions they need to be moved to a different file diff --git a/app/security.py b/app/security.py index 4670d7e0d..a59b982b1 100644 --- a/app/security.py +++ b/app/security.py @@ -72,8 +72,11 @@ def user_identity_lookup(user): def user_lookup_callback(_jwt_header, jwt_data): identity = jwt_data["sub"] - user = Accounts.get_by_id(identity) - return model_to_dict(user, recurse=True, backrefs=True, exclude=[Accounts.password]) + try: + user = Accounts.get_by_id(identity) + return model_to_dict(user, recurse=True, backrefs=True, exclude=[Accounts.password]) + except Exception: + return None def is_setup_required(): return not server_verified() diff --git a/app/templates/admin.html b/app/templates/admin.html index 0e2d917cd..11f59059b 100644 --- a/app/templates/admin.html +++ b/app/templates/admin.html @@ -6,10 +6,6 @@ {% block main %} -{% if APP_UPDATE %} -{% include 'templates/update.html' %} -{% endif %} - {% include 'templates/menu.html' %}
diff --git a/app/templates/base.template.html b/app/templates/base.template.html index 4e36b6e59..a0c47f4a3 100644 --- a/app/templates/base.template.html +++ b/app/templates/base.template.html @@ -54,6 +54,8 @@ Please wait...
+ {% include 'templates/update.html' %} + \ No newline at end of file diff --git a/app/templates/templates/base.html b/app/templates/templates/base.html index cb00108ed..19c1d946b 100644 --- a/app/templates/templates/base.html +++ b/app/templates/templates/base.html @@ -54,6 +54,8 @@ Please wait... + {% include 'templates/update.html' %} + \ No newline at end of file diff --git a/app/templates/templates/update.html b/app/templates/templates/update.html index b39f38328..c729dc930 100644 --- a/app/templates/templates/update.html +++ b/app/templates/templates/update.html @@ -1,23 +1,23 @@ -
- -
-
-
- - - - - -
-
{{ - _("Attention!") }}
- {{ _("Update available. Click here.") }} -
+
+ \ No newline at end of file diff --git a/app/utils/software_lifecycle.py b/app/utils/software_lifecycle.py index 17293ff15..b07af0095 100644 --- a/app/utils/software_lifecycle.py +++ b/app/utils/software_lifecycle.py @@ -8,6 +8,13 @@ def get_latest_version(): response = get(url, timeout=10) return parse(response.content.decode("utf-8")) +def get_latest_beta_version(): + url = "https://api.github.com/repos/wizarrrr/wizarr/releases" + response = get(url, timeout=10) + releases = response.json() + latest_beta = [release["tag_name"] for release in releases if release["prerelease"]][0] + return parse(latest_beta) + def get_current_version(): package = path.abspath(path.join(path.dirname(__file__), "../", "../", "package.json")) with open(package, "r", encoding="utf-8") as f: @@ -40,7 +47,7 @@ def is_stable(): def need_update(): current_version = get_current_version() - latest_version = get_latest_version() + latest_version = is_beta() and get_latest_beta_version() or get_latest_version() update = False try: diff --git a/package.json b/package.json index a96f75eba..66d6f6f64 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Wizarr", - "version": "3.0.0", + "version": "3.0.2", "description": "Wizarr is a web application that allows you to share your media library with your friends and family with ease.", "scripts": { "server:start": "APP_URL=127.0.0.1:5000 flask run",