mirror of
https://github.com/GradienceTeam/Community.git
synced 2024-06-29 01:19:59 +00:00
feat: Automatic preset list generation
This commit is contained in:
parent
86f7670931
commit
be5b57a240
31
.github/workflows/check.yml
vendored
31
.github/workflows/check.yml
vendored
|
@ -1,31 +0,0 @@
|
|||
# This is a basic workflow to help you get started with Actions
|
||||
|
||||
name: Check json
|
||||
|
||||
# Controls when the workflow will run
|
||||
on:
|
||||
# Triggers the workflow on push or pull request events but only for the "main" branch
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
# This workflow contains a single job called "build"
|
||||
check:
|
||||
# The type of runner that the job will run on
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Check json files
|
||||
uses: ValentinVignal/action-json-keys@v0.5
|
||||
with:
|
||||
file-matcher: 'presets/**/*.json'
|
64
.github/workflows/update.yml
vendored
64
.github/workflows/update.yml
vendored
|
@ -1,32 +1,54 @@
|
|||
name: Update from gradience-presets org
|
||||
# Change the look of Adwaita, with ease
|
||||
# Copyright (C) 2022 Gradience Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# Scripts are created by @dominichayesferen for Gradience Team
|
||||
|
||||
|
||||
name: Generate preset lists
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "next" ]
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
paths: scripts/update-curated.py
|
||||
paths: scripts/update-official.py
|
||||
schedule:
|
||||
- cron: '0 * * * *'
|
||||
|
||||
- cron: '0 0,12 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
update:
|
||||
# The type of runner that the job will run on
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
# Runs a single command using the runners shell
|
||||
- name: Run a one-line script
|
||||
run: ./scripts/update.sh
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
- name: Commmit
|
||||
run: |
|
||||
git config user.name "GradienceBot"
|
||||
git config user.email "AdwCustomizerTeam@proton.me"
|
||||
git add .
|
||||
# added | true so, the worklow will not fail if there is nothing to committ
|
||||
git commit -m "ci: update presets for their repo" | true
|
||||
- name: Run the script
|
||||
run: python3 scripts/update-curated.py && python3 scripts/update-official.py
|
||||
|
||||
- name: Generate preset lists
|
||||
uses: peter-evans/create-pull-request@v4
|
||||
with:
|
||||
title: "ci: Generate preset lists"
|
||||
copyright: "Gradience Team"
|
||||
license: "GNU GPLv3"
|
||||
author: "Gradience Team"
|
||||
commiter: "Gradience Bot"
|
||||
commiter_email: "AdwCustomizerTeam@proton.me"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
|
@ -144,3 +144,7 @@ Add a link to your `repo` in `Preferences` > `Repo`
|
|||
}
|
||||
}
|
||||
```
|
||||
|
||||
# Credits
|
||||
|
||||
Special thanks to [@dominichayesferen](https://github.com/dominichayesferen) for creating script for automatic preset list generation
|
||||
|
|
35
curated.json
35
curated.json
|
@ -5,29 +5,34 @@
|
|||
"Alpha Mac": "https://github.com/GradienceTeam/Community/raw/next/curated/alpha-mac.json",
|
||||
"Alpha Tritanopia": "https://github.com/GradienceTeam/Community/raw/next/curated/alpha-tritanopia.json",
|
||||
"Apprentice": "https://github.com/GradienceTeam/Community/raw/next/curated/apprentice.json",
|
||||
"Catppuccin Frappé": "https://github.com/GradienceTeam/Community/raw/next/curated/catppuccin-frappe.json",
|
||||
"Breeze Dark": "https://github.com/GradienceTeam/Community/raw/next/curated/breeze-dark.json",
|
||||
"Breeze Light": "https://github.com/GradienceTeam/Community/raw/next/curated/breeze-light.json",
|
||||
"Catppuccin Frapp\u00e9": "https://github.com/GradienceTeam/Community/raw/next/curated/catppuccin-frappe.json",
|
||||
"Catppuccin Latte": "https://github.com/GradienceTeam/Community/raw/next/curated/catppuccin-latte.json",
|
||||
"Crystal Clear": "https://github.com/GradienceTeam/Community/raw/next/curated/crystal-clear.json",
|
||||
"Cyberhack": "https://github.com/GradienceTeam/Community/raw/next/curated/cyberhack.json",
|
||||
"CyberHack": "https://github.com/GradienceTeam/Community/raw/next/curated/cyberhack.json",
|
||||
"Dracula": "https://github.com/GradienceTeam/Community/raw/next/curated/dracula.json",
|
||||
"Dracula Dark": "https://github.com/GradienceTeam/Community/raw/next/curated/dracula-dark.json",
|
||||
"Everforest Medium Dark": "https://github.com/GradienceTeam/Community/raw/next/curated/everforest.json",
|
||||
"Feren OS (2020)": "https://github.com/GradienceTeam/Community/raw/next/curated/feren-os-2020.json",
|
||||
"Feren OS Dark (2020)": "https://github.com/GradienceTeam/Community/raw/next/curated/feren-os-dark-2020.json",
|
||||
"Gruvbox": "https://github.com/GradienceTeam/Community/raw/next/curated/gruvbox.json",
|
||||
"Jungle Jaunt": "https://github.com/GradienceTeam/Community/raw/next/curated/jungle-jaunt.json",
|
||||
"Kanagawa": "https://github.com/GradienceTeam/Community/raw/next/curated/kanagawa.json",
|
||||
"Layan": "https://github.com/GradienceTeam/Community/raw/next/curated/layan.json",
|
||||
"Layan Dark": "https://github.com/GradienceTeam/Community/raw/next/curated/layan-dark.json",
|
||||
"Matcha Sea": "https://github.com/GradienceTeam/Community/raw/next/curated/matcha-sea.json",
|
||||
"Nord": "https://github.com/GradienceTeam/Community/raw/next/curated/nord-semi-light.json",
|
||||
"Nord": "https://github.com/GradienceTeam/Community/raw/next/curated/nord.json",
|
||||
"Nord Dark": "https://github.com/GradienceTeam/Community/raw/next/curated/nord-dark.json",
|
||||
"Nord Light": "https://github.com/GradienceTeam/Community/raw/next/curated/nord.json",
|
||||
"Nord Semi-Light": "https://github.com/GradienceTeam/Community/raw/next/curated/nord-light.json",
|
||||
"Nord Light": "https://github.com/GradienceTeam/Community/raw/next/curated/nord-light.json",
|
||||
"Nord Semi-Light": "https://github.com/GradienceTeam/Community/raw/next/curated/nord-semi-light.json",
|
||||
"Norway": "https://github.com/GradienceTeam/Community/raw/next/curated/norway.json",
|
||||
"One Dark Pro": "https://github.com/GradienceTeam/Community/raw/next/curated/one-dark-pro.json",
|
||||
"Pop": "https://github.com/GradienceTeam/Community/raw/next/curated/pop.json",
|
||||
"Pop Dark": "https://github.com/GradienceTeam/Community/raw/next/curated/pop-dark.json",
|
||||
"Rosé Pine": "https://github.com/GradienceTeam/Community/raw/next/curated/rose-pine-moon.json",
|
||||
"Rosé Pine Dawn": "https://github.com/GradienceTeam/Community/raw/next/curated/rose-pine-dawn.json",
|
||||
"Rosé Pine Moon": "https://github.com/GradienceTeam/Community/raw/next/curated/rose-pine.json",
|
||||
"Ros\u00e9 Pine": "https://github.com/GradienceTeam/Community/raw/next/curated/rose-pine.json",
|
||||
"Ros\u00e9 Pine Dawn": "https://github.com/GradienceTeam/Community/raw/next/curated/rose-pine-dawn.json",
|
||||
"Ros\u00e9 Pine Moon": "https://github.com/GradienceTeam/Community/raw/next/curated/rose-pine-moon.json",
|
||||
"Solarized": "https://github.com/GradienceTeam/Community/raw/next/curated/solarized.json",
|
||||
"Solarized Dark": "https://github.com/GradienceTeam/Community/raw/next/curated/solarized-dark.json",
|
||||
"SurGubbe": "https://github.com/GradienceTeam/Community/raw/next/curated/surgubbe.json",
|
||||
|
@ -36,5 +41,17 @@
|
|||
"Windows 95": "https://github.com/GradienceTeam/Community/raw/next/curated/windows-95.json",
|
||||
"Yaru": "https://github.com/GradienceTeam/Community/raw/next/curated/yaru.json",
|
||||
"Yaru Dark": "https://github.com/GradienceTeam/Community/raw/next/curated/yaru-dark.json",
|
||||
"Zenburn": "https://github.com/GradienceTeam/Community/raw/next/curated/zenburn.json"
|
||||
"Zenburn": "https://github.com/GradienceTeam/Community/raw/next/curated/zenburn.json",
|
||||
"Zorin OS 16 Blue": "https://github.com/GradienceTeam/Community/raw/next/curated/zorin-os-16-blue.json",
|
||||
"Zorin OS 16 Blue Dark": "https://github.com/GradienceTeam/Community/raw/next/curated/zorin-os-16-blue-dark.json",
|
||||
"Zorin OS 16 Green": "https://github.com/GradienceTeam/Community/raw/next/curated/zorin-os-16-green.json",
|
||||
"Zorin OS 16 Green Dark": "https://github.com/GradienceTeam/Community/raw/next/curated/zorin-os-16-green-dark.json",
|
||||
"Zorin OS 16 Grey": "https://github.com/GradienceTeam/Community/raw/next/curated/zorin-os-16-grey.json",
|
||||
"Zorin OS 16 Grey Dark": "https://github.com/GradienceTeam/Community/raw/next/curated/zorin-os-16-grey-dark.json",
|
||||
"Zorin OS 16 Orange": "https://github.com/GradienceTeam/Community/raw/next/curated/zorin-os-16-orange.json",
|
||||
"Zorin OS 16 Orange Dark": "https://github.com/GradienceTeam/Community/raw/next/curated/zorin-os-16-orange-dark.json",
|
||||
"Zorin OS 16 Purple": "https://github.com/GradienceTeam/Community/raw/next/curated/zorin-os-16-purple.json",
|
||||
"Zorin OS 16 Purple Dark": "https://github.com/GradienceTeam/Community/raw/next/curated/zorin-os-16-purple-dark.json",
|
||||
"Zorin OS 16 Red": "https://github.com/GradienceTeam/Community/raw/next/curated/zorin-os-16-red.json",
|
||||
"Zorin OS 16 Red Dark": "https://github.com/GradienceTeam/Community/raw/next/curated/zorin-os-16-red-dark.json"
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"Crystal Clear": "https://github.com/GradienceTeam/Community/raw/next/curated/crystal-clear.json",
|
||||
"with-variants": {
|
||||
"solarized": "https://github.com/GradienceTeam/preset.solarized/raw/main/preset.json"
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"Builder": "https://github.com/GradienceTeam/Community/raw/next/official/builder.json",
|
||||
"Builder Dark": "https://github.com/GradienceTeam/Community/raw/next/official/builder-dark.json",
|
||||
"Catppuccin Frappé": "https://github.com/GradienceTeam/Community/raw/next/official/catppuccin-frappé.json",
|
||||
"Catppuccin Frapp\u00e9": "https://github.com/GradienceTeam/Community/raw/next/official/catppuccin-frapp\u00e9.json",
|
||||
"Catppuccin Latte": "https://github.com/GradienceTeam/Community/raw/next/official/catppuccin-latte.json",
|
||||
"Catppuccin Macchiato": "https://github.com/GradienceTeam/Community/raw/next/official/catppuccin-macchiato.json",
|
||||
"Catppuccin Mocha": "https://github.com/GradienceTeam/Community/raw/next/official/catppuccin-mocha.json",
|
||||
|
|
42
scripts/update-curated.py
Executable file
42
scripts/update-curated.py
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
# Change the look of Adwaita, with ease
|
||||
# Copyright (C) 2022 Gradience Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# Created by @dominichayesferen for Gradience Team
|
||||
|
||||
import os
|
||||
import json
|
||||
|
||||
themeslist = {} #Dictionaries needs creating before you append to them, otherwise it'll UnboundLocalError
|
||||
|
||||
for i in os.listdir("curated"): #Lists all files (and folders, but it doesn't matter) inside ./curated
|
||||
with open("curated/" + i, 'r') as pa: #Go through each file
|
||||
#NOTE: There is no .json filter in the above code - be aware that if any non-json file were to be added to that folder, json.loads will likely raise an exception
|
||||
palette = json.loads(pa.read()) #Use json module to convert the file's data to a dictionary
|
||||
themeslist[palette["name"]] = "https://github.com/GradienceTeam/Community/raw/next/curated/" + i #We know where they should be located, so we just put their filenames at the end of the link, and put that whole combined string into the themeslist dictionary, with its key being the in-palette-JSON name of the palette
|
||||
|
||||
themenames = [] #Lists needs creating before you append to them, otherwise it'll UnboundLocalError
|
||||
for i in themeslist: #Get the keys of the dictionary in list format
|
||||
themenames.append(i) #Self-explanatory - adds the readable name to the themenames list
|
||||
themenames.sort() #.sort() alphabetically sorts the list it is ran on (note that .sort() cannot do X = X.sort(), as it'll set X to None)
|
||||
|
||||
organisedthemeslist = {} #You get the idea with empty variables.
|
||||
for i in themenames: #For each theme's name, in the order .sort() caused
|
||||
organisedthemeslist[i] = themeslist[i] #Append the appropriate value from themeslist to organisedthemeslist - this essentially alphabetically sorts the dictionary on a key-by-key basis
|
||||
|
||||
with open("curated.json", 'w') as fp: #This opens the file for writing. You might be wondering why there's no .close() - with "with open(...)", the file is automatically closed at the end of the with statement's execution
|
||||
fp.write(json.dumps(organisedthemeslist, indent=4)) #Save changes to curated.json
|
42
scripts/update-official.py
Executable file
42
scripts/update-official.py
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
# Change the look of Adwaita, with ease
|
||||
# Copyright (C) 2022 Gradience Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# Created by @dominichayesferen for Gradience Team
|
||||
|
||||
import os
|
||||
import json
|
||||
|
||||
themeslist = {} #Dictionaries needs creating before you append to them, otherwise it'll UnboundLocalError
|
||||
|
||||
for i in os.listdir("official"): #Lists all files (and folders, but it doesn't matter) inside ./official
|
||||
with open("official/" + i, 'r') as pa: #Go through each file
|
||||
#NOTE: There is no .json filter in the above code - be aware that if any non-json file were to be added to that folder, json.loads will likely raise an exception
|
||||
palette = json.loads(pa.read()) #Use json module to convert the file's data to a dictionary
|
||||
themeslist[palette["name"]] = "https://github.com/GradienceTeam/Community/raw/next/official/" + i #We know where they should be located, so we just put their filenames at the end of the link, and put that whole combined string into the themeslist dictionary, with its key being the in-palette-JSON name of the palette
|
||||
|
||||
themenames = [] #Lists needs creating before you append to them, otherwise it'll UnboundLocalError
|
||||
for i in themeslist: #Get the keys of the dictionary in list format
|
||||
themenames.append(i) #Self-explanatory - adds the readable name to the themenames list
|
||||
themenames.sort() #.sort() alphabetically sorts the list it is ran on (note that .sort() cannot do X = X.sort(), as it'll set X to None)
|
||||
|
||||
organisedthemeslist = {} #You get the idea with empty variables.
|
||||
for i in themenames: #For each theme's name, in the order .sort() caused
|
||||
organisedthemeslist[i] = themeslist[i] #Append the appropriate value from themeslist to organisedthemeslist - this essentially alphabetically sorts the dictionary on a key-by-key basis
|
||||
|
||||
with open("official.json", 'w') as fp: #This opens the file for writing. You might be wondering why there's no .close() - with "with open(...)", the file is automatically closed at the end of the with statement's execution
|
||||
fp.write(json.dumps(organisedthemeslist, indent=4)) #Save changes to official.json
|
|
@ -1,38 +0,0 @@
|
|||
curated=("yaru" "tango" "alpha-black" "alpha-mac" "alpha-dark" "catppuccin-frappe" "catppuccin-latte" "cyberhack" "crystal-clear" "dracula" "nord" "gruvbox" "pop-dark" "pop-light")
|
||||
official=("tango")
|
||||
|
||||
BASE_URL="https://raw.githubusercontent.com/gradience-presets"
|
||||
BRANCH="main"
|
||||
DEFAULT_FILENAME="preset.json"
|
||||
|
||||
mkdir -p curated
|
||||
|
||||
echo "{" > curated.json
|
||||
i=0
|
||||
for preset in "${curated[@]}"; do
|
||||
i=$((i+1))
|
||||
url="$BASE_URL/$preset/$BRANCH/$DEFAULT_FILENAME"
|
||||
wget "$url" -O "curated/${preset}.json"
|
||||
if [[ $i == "${#curated[@]}" ]]; then
|
||||
echo " \"$preset\": \"$url\"" >> curated.json
|
||||
else
|
||||
echo " \"$preset\": \"$url\"," >> curated.json
|
||||
fi
|
||||
done
|
||||
echo "}" >> curated.json
|
||||
|
||||
mkdir -p official
|
||||
|
||||
echo "{" > official.json
|
||||
i=0
|
||||
for preset in "${official[@]}"; do
|
||||
i=$((i+1))
|
||||
url="$BASE_URL/$preset/$BRANCH/$DEFAULT_FILENAME"
|
||||
wget "$url" -O "official/${preset}.json"
|
||||
if [[ $i == "${#official[@]}" ]]; then
|
||||
echo " \"$preset\": \"$url\"" >> official.json
|
||||
else
|
||||
echo " \"$preset\": \"$url\"," >> official.json
|
||||
fi
|
||||
done
|
||||
echo "}" >> official.json
|
Loading…
Reference in a new issue