-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation, github actions and a lot more added.
- Loading branch information
1 parent
ba55473
commit bda9df8
Showing
15 changed files
with
489 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# These are supported funding model platforms | ||
github: [hasansezertasan] | ||
# patreon: # Replace with a single Patreon username | ||
# open_collective: # Replace with a single Open Collective username | ||
# ko_fi: # Replace with a single Ko-fi username | ||
# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
# liberapay: # Replace with a single Liberapay username | ||
# issuehunt: # Replace with a single IssueHunt username | ||
# otechie: # Replace with a single Otechie username | ||
# lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry | ||
# custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] |
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,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "pip" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" |
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,33 @@ | ||
name: Github Pages | ||
on: | ||
workflow_dispatch: | ||
release: | ||
types: [ published ] | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Check out repository. | ||
uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
installer-parallel: true | ||
- name: Install dependencies | ||
run: poetry install --no-interaction | ||
- name: Build Docs | ||
run: poetry run mkdocs build | ||
- name: Deploy | ||
uses: peaceiris/actions-gh-pages@v3 | ||
if: github.ref == 'refs/heads/main' | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./site |
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,28 @@ | ||
name: Latest Release | ||
on: | ||
workflow_dispatch: | ||
release: | ||
types: [ published ] | ||
jobs: | ||
publish-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
- name: Set up python 3.11 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
installer-parallel: true | ||
- name: Install dependencies | ||
run: poetry install --no-interaction | ||
- name: Publish to PyPI | ||
shell: bash | ||
run: | | ||
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} | ||
poetry publish --build --no-interaction |
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 |
---|---|---|
@@ -1,16 +1,3 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## Version 0.1.0 - 2023-09-08 | ||
|
||
### Added | ||
|
||
* Project Structure | ||
* Hello World CLI Tool. | ||
* Pre Commit Hooks | ||
* `CHANGELOG.md` | ||
* `README.md` | ||
* `LICENSE` | ||
Please check [this page in the documentation](https://hasansezertasan.github.io/chrome-version/changelog/). |
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 @@ | ||
from chrome_version.resolver import get_chrome_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
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,79 @@ | ||
import os | ||
import re | ||
from sys import platform | ||
|
||
|
||
def extract_version_registry(output): | ||
"""Extracts the Chrome version from the registry output.""" | ||
try: | ||
google_version = "" | ||
for letter in output[output.rindex("DisplayVersion REG_SZ") + 24 :]: | ||
if letter != "\n": | ||
google_version += letter | ||
else: | ||
break | ||
return google_version.strip() | ||
except TypeError: | ||
return | ||
|
||
|
||
def extract_version_folder(): | ||
"""Extracts the Chrome version from the folder name. | ||
Check if the Chrome folder exists in the x32 or x64 Program Files folders. | ||
""" | ||
for i in range(2): | ||
path = ( | ||
"C:\\Program Files" | ||
+ (" (x86)" if i else "") | ||
+ "\\Google\\Chrome\\Application" | ||
) | ||
if os.path.isdir(path): | ||
paths = [f.path for f in os.scandir(path) if f.is_dir()] | ||
for path in paths: | ||
filename = os.path.basename(path) | ||
pattern = "\d+\.\d+\.\d+\.\d+" | ||
match = re.search(pattern, filename) | ||
if match and match.group(): | ||
# Found a Chrome version. | ||
return match.group(0) | ||
|
||
return None | ||
|
||
|
||
def get_chrome_version(): | ||
"""Gets the Chrome version.""" | ||
version = None | ||
install_path = None | ||
|
||
try: | ||
if platform == "linux" or platform == "linux2": | ||
# linux | ||
install_path = "/usr/bin/google-chrome" | ||
elif platform == "darwin": | ||
# OS X | ||
install_path = ( | ||
"/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome" | ||
) | ||
elif platform == "win32": | ||
# Windows... | ||
try: | ||
# Try registry key. | ||
stream = os.popen( | ||
'reg query "HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Google Chrome"' | ||
) | ||
output = stream.read() | ||
version = extract_version_registry(output) | ||
except Exception as ex: | ||
# Try folder path. | ||
version = extract_version_folder() | ||
except Exception as ex: | ||
print(ex) | ||
|
||
version = ( | ||
os.popen(f"{install_path} --version").read().strip("Google Chrome ").strip() | ||
if install_path | ||
else version | ||
) | ||
|
||
return 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog], and this project adheres to [Semantic Versioning]. | ||
|
||
## [Unreleased] | ||
|
||
### Added | ||
|
||
- Module itself with poetry. | ||
- CLI Tool wrapping the module with typer. | ||
- Optional dependency `typer` for CLI Tool. | ||
- MkDocs for documentation. | ||
- GitHub Actions: | ||
- Generate Documentation. | ||
- Publish to PyPI. | ||
- Dependabot for dependency management. | ||
- Funding options for GitHub Sponsors. | ||
|
||
### Changed | ||
|
||
- `README.md` to include installation and usage instructions. | ||
- Dependencies to fit the project. | ||
|
||
## [0.1.0] - 2023-09-08 | ||
|
||
- initial release | ||
|
||
### Added | ||
|
||
- Project Structure | ||
- Hello World CLI Tool. | ||
- Pre Commit Hooks | ||
- `CHANGELOG.md` | ||
- `README.md` | ||
- `LICENSE` | ||
|
||
<!-- Links --> | ||
[keep a changelog]: https://keepachangelog.com/en/1.1.0/ | ||
[semantic versioning]: https://semver.org | ||
|
||
<!-- Versions --> | ||
[unreleased]: https://github.com/hasansezertasan/chrome-version/compare/0.1.0...HEAD | ||
[0.1.0]: https://github.com/hasansezertasan/chrome-version/releases/tag/0.1.0 |
Oops, something went wrong.