-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #546 from modoboa/feature/versioning
Added version check
- Loading branch information
Showing
4 changed files
with
88 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Update version file | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
|
||
jobs: | ||
update-version: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. | ||
ref: ${{ github.head_ref }} | ||
- name: Overwrite file | ||
uses: "DamianReeves/write-file-action@master" | ||
with: | ||
path: version.txt | ||
write-mode: overwrite | ||
contents: ${{ github.sha }} | ||
|
||
- name: Commit & Push | ||
uses: Andro999b/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: ${{ github.ref_name }} | ||
force: true | ||
message: '[GitHub Action] Updated version file' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"""Checks to be performed before any install or upgrade""" | ||
|
||
import sys | ||
from urllib.request import urlopen | ||
|
||
from modoboa_installer import utils | ||
|
||
|
||
def check_version(): | ||
local_version = "" | ||
with open("version.txt", "r") as version: | ||
local_version = version.readline() | ||
remote_version = "" | ||
with urlopen("https://raw.githubusercontent.com/modoboa/modoboa-installer/master/version.txt") as r_version: | ||
remote_version = r_version.read().decode() | ||
if local_version == "" or remote_version == "": | ||
utils.printcolor( | ||
"Could not check that your installer is up-to-date: " | ||
f"local version: {local_version}, " | ||
f"remote version: {remote_version}", | ||
utils.YELLOW | ||
) | ||
if remote_version != local_version: | ||
utils.error( | ||
"Your installer seems outdated.\n" | ||
"Check README file for instructions about how to update.\n" | ||
"No support will be provided without an up-to-date installer!" | ||
) | ||
answer = utils.user_input("Continue anyway? (Y/n) ") | ||
if not answer.lower().startswith("y"): | ||
sys.exit(0) | ||
else: | ||
utils.success("Installer seems up to date!") | ||
|
||
|
||
def handle(): | ||
check_version() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters