mirror of
https://github.com/spitkov/ynsrepo.git
synced 2025-01-18 04:24:38 +01:00
Initial commit: Basic repository structure with sample calc package
This commit is contained in:
commit
33315f25fe
7 changed files with 139 additions and 0 deletions
65
.github/workflows/update-repo.yml
vendored
Normal file
65
.github/workflows/update-repo.yml
vendored
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
name: Update Repository JSON
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'packages/**'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-repo-json:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: '3.x'
|
||||||
|
|
||||||
|
- name: Update repo.json
|
||||||
|
run: |
|
||||||
|
python - <<EOF
|
||||||
|
import os
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
def get_raw_url(path):
|
||||||
|
return f"https://raw.githubusercontent.com/spitkov/ynsrepo/main/{path}"
|
||||||
|
|
||||||
|
def update_repo_json():
|
||||||
|
packages_dir = Path('packages')
|
||||||
|
repo_data = {"packages": {}}
|
||||||
|
|
||||||
|
for package_dir in packages_dir.iterdir():
|
||||||
|
if package_dir.is_dir():
|
||||||
|
package_name = package_dir.name
|
||||||
|
version_file = package_dir / "VERSION"
|
||||||
|
|
||||||
|
if version_file.exists():
|
||||||
|
version = version_file.read_text().strip()
|
||||||
|
|
||||||
|
package_data = {
|
||||||
|
"name": package_name,
|
||||||
|
"version": version,
|
||||||
|
"install": get_raw_url(str(package_dir / "install.sh")),
|
||||||
|
"update": get_raw_url(str(package_dir / "update.sh")),
|
||||||
|
"remove": get_raw_url(str(package_dir / "remove.sh"))
|
||||||
|
}
|
||||||
|
|
||||||
|
repo_data["packages"][package_name] = package_data
|
||||||
|
|
||||||
|
with open('repo.json', 'w') as f:
|
||||||
|
json.dump(repo_data, f, indent=2)
|
||||||
|
|
||||||
|
update_repo_json()
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Commit changes
|
||||||
|
run: |
|
||||||
|
git config --local user.email "action@github.com"
|
||||||
|
git config --local user.name "GitHub Action"
|
||||||
|
git add repo.json
|
||||||
|
git diff --quiet && git diff --staged --quiet || git commit -m "Update repo.json"
|
||||||
|
git push
|
47
README.md
Normal file
47
README.md
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
# YNS Package Repository
|
||||||
|
|
||||||
|
This repository hosts packages for the [YNS Package Manager](https://github.com/spitkov/ynspkg). The repository structure is automatically maintained using GitHub Actions.
|
||||||
|
|
||||||
|
## Package Manager
|
||||||
|
|
||||||
|
To use these packages, you'll need to install the [YNS Package Manager](https://github.com/spitkov/ynspkg) first. The package manager will automatically fetch and manage packages from this repository.
|
||||||
|
|
||||||
|
## Repository Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
.
|
||||||
|
├── repo.json # Main package index
|
||||||
|
├── packages/ # Directory containing all packages
|
||||||
|
│ └── package_name/ # Individual package directory
|
||||||
|
│ ├── VERSION # Package version file
|
||||||
|
│ ├── install.sh # Installation script
|
||||||
|
│ ├── update.sh # Update script
|
||||||
|
│ └── remove.sh # Removal script
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Adding a New Package
|
||||||
|
|
||||||
|
1. Create a new directory under `packages/` with your package name
|
||||||
|
2. Add the required files:
|
||||||
|
- `VERSION`: Contains the version number (e.g., "1.0", "2.1")
|
||||||
|
- `install.sh`: Installation script
|
||||||
|
- `update.sh`: Update script
|
||||||
|
- `remove.sh`: Removal script
|
||||||
|
3. Push your changes to the main branch
|
||||||
|
|
||||||
|
The GitHub Actions workflow will automatically update the `repo.json` file with your package information.
|
||||||
|
|
||||||
|
## Package Scripts
|
||||||
|
|
||||||
|
Each package must contain three executable scripts:
|
||||||
|
|
||||||
|
- `install.sh`: Handles package installation
|
||||||
|
- `update.sh`: Handles package updates
|
||||||
|
- `remove.sh`: Handles package removal
|
||||||
|
|
||||||
|
All scripts should:
|
||||||
|
- Be executable
|
||||||
|
- Return 0 on success
|
||||||
|
- Return non-zero on failure
|
||||||
|
- Handle errors appropriately
|
1
packages/calc/VERSION
Normal file
1
packages/calc/VERSION
Normal file
|
@ -0,0 +1 @@
|
||||||
|
1.0
|
5
packages/calc/install.sh
Normal file
5
packages/calc/install.sh
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Installing calc package..."
|
||||||
|
# Add installation logic here
|
||||||
|
exit 0
|
5
packages/calc/remove.sh
Normal file
5
packages/calc/remove.sh
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Removing calc package..."
|
||||||
|
# Add removal logic here
|
||||||
|
exit 0
|
5
packages/calc/update.sh
Normal file
5
packages/calc/update.sh
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Updating calc package..."
|
||||||
|
# Add update logic here
|
||||||
|
exit 0
|
11
repo.json
Normal file
11
repo.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"packages": {
|
||||||
|
"calc": {
|
||||||
|
"name": "calc",
|
||||||
|
"version": "1.0",
|
||||||
|
"install": "https://raw.githubusercontent.com/spitkov/ynsrepo/main/packages/calc/install.sh",
|
||||||
|
"update": "https://raw.githubusercontent.com/spitkov/ynsrepo/main/packages/calc/update.sh",
|
||||||
|
"remove": "https://raw.githubusercontent.com/spitkov/ynsrepo/main/packages/calc/remove.sh"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue