feature test
This commit is contained in:
79
.gitea/workflows/build.yml
Normal file
79
.gitea/workflows/build.yml
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
name: Build packages
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
paths:
|
||||||
|
- '*/VERSION'
|
||||||
|
- '*/nfpm.yaml'
|
||||||
|
- '.gitea/workflows/build.yml'
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
package:
|
||||||
|
description: 'Package name (leave empty for all)'
|
||||||
|
required: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
discover:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Build matrix
|
||||||
|
id: set-matrix
|
||||||
|
run: |
|
||||||
|
if [ -n "${{ github.event.inputs.package }}" ]; then
|
||||||
|
# Ручной запуск — конкретный пакет
|
||||||
|
MATRIX=$(echo '["${{ github.event.inputs.package }}"]')
|
||||||
|
else
|
||||||
|
# Авто — только изменённые пакеты
|
||||||
|
CHANGED=$(git diff --name-only HEAD~1 HEAD | grep -oP '^[^/]+(?=/)' | sort -u | \
|
||||||
|
while read dir; do [ -f "$dir/nfpm.yaml" ] && echo "$dir"; done)
|
||||||
|
MATRIX=$(echo "$CHANGED" | jq -R . | jq -sc .)
|
||||||
|
fi
|
||||||
|
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
build:
|
||||||
|
needs: discover
|
||||||
|
if: ${{ needs.discover.outputs.matrix != '[]' }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
package: ${{ fromJson(needs.discover.outputs.matrix) }}
|
||||||
|
fail-fast: false
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Read version
|
||||||
|
run: |
|
||||||
|
VERSION=$(cat ${{ matrix.package }}/VERSION | tr -d '[:space:]')
|
||||||
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Download upstream
|
||||||
|
run: |
|
||||||
|
cd ${{ matrix.package }}
|
||||||
|
bash scripts/download.sh $VERSION # ← каждый пакет знает как скачать себя
|
||||||
|
|
||||||
|
- name: Build deb
|
||||||
|
run: |
|
||||||
|
docker run --rm \
|
||||||
|
-v $PWD/${{ matrix.package }}:/work \
|
||||||
|
-w /work \
|
||||||
|
-e VERSION=${{ env.VERSION }} \
|
||||||
|
goreleaser/nfpm package \
|
||||||
|
--config nfpm.yaml \
|
||||||
|
--target /work \
|
||||||
|
--packager deb
|
||||||
|
|
||||||
|
- name: Publish
|
||||||
|
run: |
|
||||||
|
DEB=$(ls ${{ matrix.package }}/*.deb | head -1)
|
||||||
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||||
|
--user "andrew:${{ secrets.GITEA_TOKEN }}" \
|
||||||
|
--upload-file "$DEB" \
|
||||||
|
"https://git.nakolenke.org/api/packages/nakolenke-pub/debian/pool/trixie/main/upload")
|
||||||
|
echo "HTTP: $HTTP_CODE"
|
||||||
|
[ "$HTTP_CODE" = "201" ] || exit 1
|
||||||
52
README.md
Normal file
52
README.md
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# packages
|
||||||
|
|
||||||
|
Gitea Actions-based Debian package builder for custom apt repository.
|
||||||
|
|
||||||
|
## Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
packages/
|
||||||
|
├── .gitea/workflows/build.yml # CI pipeline
|
||||||
|
├── scripts/publish.sh # manual publish helper
|
||||||
|
└── v2ray/
|
||||||
|
├── nfpm.yaml # package definition
|
||||||
|
└── scripts/
|
||||||
|
├── postinstall.sh
|
||||||
|
└── preremove.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Automatic build
|
||||||
|
|
||||||
|
Push changes to `v2ray/` directory → triggers build automatically.
|
||||||
|
|
||||||
|
### Manual build with specific version
|
||||||
|
|
||||||
|
Gitea → Actions → Build packages → Run workflow → specify version.
|
||||||
|
|
||||||
|
### Add repository on servers
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl https://git.nakolenke.org/api/packages/nakolenke-pub/debian/repository.key \
|
||||||
|
-o /etc/apt/keyrings/nakolenke.asc
|
||||||
|
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/nakolenke.asc] \
|
||||||
|
https://git.nakolenke.org/api/packages/nakolenke-pub/debian trixie main" \
|
||||||
|
> /etc/apt/sources.list.d/nakolenke.list
|
||||||
|
|
||||||
|
apt update
|
||||||
|
apt install v2ray
|
||||||
|
```
|
||||||
|
|
||||||
|
## Secrets
|
||||||
|
|
||||||
|
Set `GITEA_TOKEN` in repository secrets (Settings → Secrets).
|
||||||
|
Token needs `package` scope.
|
||||||
|
|
||||||
|
## Adding new package
|
||||||
|
|
||||||
|
1. Create directory `<package>/`
|
||||||
|
2. Add `nfpm.yaml`
|
||||||
|
3. Add `scripts/postinstall.sh` and `scripts/preremove.sh`
|
||||||
|
4. Add job to `.gitea/workflows/build.yml`
|
||||||
4
packages.yml
Normal file
4
packages.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
packages:
|
||||||
|
- name: v2ray
|
||||||
|
upstream: "https://github.com/v2fly/v2ray-core/releases/download/v{VERSION}/v2ray-linux-64.zip"
|
||||||
|
binary: v2ray
|
||||||
32
scripts/publish.sh
Normal file
32
scripts/publish.sh
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DEB=$1
|
||||||
|
GITEA_URL="https://git.nakolenke.org"
|
||||||
|
OWNER="nakolenke-pub"
|
||||||
|
DISTRO="${2:-trixie}"
|
||||||
|
COMPONENT="${3:-main}"
|
||||||
|
|
||||||
|
if [ -z "$DEB" ]; then
|
||||||
|
echo "Usage: $0 <file.deb> [distro] [component]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$GITEA_TOKEN" ]; then
|
||||||
|
echo "Error: GITEA_TOKEN not set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||||
|
--user "andrew:${GITEA_TOKEN}" \
|
||||||
|
--upload-file "$DEB" \
|
||||||
|
"${GITEA_URL}/api/packages/${OWNER}/debian/pool/${DISTRO}/${COMPONENT}/upload")
|
||||||
|
|
||||||
|
echo "HTTP status: $HTTP_CODE"
|
||||||
|
|
||||||
|
if [ "$HTTP_CODE" != "201" ]; then
|
||||||
|
echo "Failed to publish $DEB (HTTP $HTTP_CODE)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Published $DEB → ${DISTRO}/${COMPONENT}"
|
||||||
BIN
v2ray/.DS_Store
vendored
Normal file
BIN
v2ray/.DS_Store
vendored
Normal file
Binary file not shown.
1
v2ray/VERSION
Normal file
1
v2ray/VERSION
Normal file
@ -0,0 +1 @@
|
|||||||
|
5.46.0
|
||||||
35
v2ray/nfpm.yaml
Normal file
35
v2ray/nfpm.yaml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
name: v2ray
|
||||||
|
version: ${VERSION}
|
||||||
|
arch: amd64
|
||||||
|
platform: linux
|
||||||
|
maintainer: nakolenke <apt@nakolenke.org>
|
||||||
|
description: V2Ray proxy tool (v2fly/v2ray-core)
|
||||||
|
license: MIT
|
||||||
|
depends:
|
||||||
|
- systemd
|
||||||
|
|
||||||
|
contents:
|
||||||
|
- src: dist/v2ray
|
||||||
|
dst: /usr/bin/v2ray
|
||||||
|
file_info:
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
- src: dist/geoip.dat
|
||||||
|
dst: /usr/share/v2ray/geoip.dat
|
||||||
|
|
||||||
|
- src: dist/geosite.dat
|
||||||
|
dst: /usr/share/v2ray/geosite.dat
|
||||||
|
|
||||||
|
- src: dist/config.json
|
||||||
|
dst: /etc/v2ray/config.json
|
||||||
|
type: config|noreplace
|
||||||
|
|
||||||
|
- src: dist/systemd/system/v2ray.service
|
||||||
|
dst: /lib/systemd/system/v2ray.service
|
||||||
|
|
||||||
|
- src: dist/systemd/system/v2ray@.service
|
||||||
|
dst: /lib/systemd/system/v2ray@.service
|
||||||
|
|
||||||
|
scripts:
|
||||||
|
postinstall: scripts/postinstall.sh
|
||||||
|
preremove: scripts/preremove.sh
|
||||||
7
v2ray/scripts/download.sh
Normal file
7
v2ray/scripts/download.sh
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# v2ray/scripts/download.sh
|
||||||
|
#!/bin/bash
|
||||||
|
VERSION=$1
|
||||||
|
wget -q "https://github.com/v2fly/v2ray-core/releases/download/v${VERSION}/v2ray-linux-64.zip"
|
||||||
|
mkdir -p dist
|
||||||
|
unzip -q v2ray-linux-64.zip -d dist/
|
||||||
|
chmod +x dist/v2ray
|
||||||
3
v2ray/scripts/postinstall.sh
Normal file
3
v2ray/scripts/postinstall.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable v2ray
|
||||||
3
v2ray/scripts/preremove.sh
Normal file
3
v2ray/scripts/preremove.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
systemctl stop v2ray || true
|
||||||
|
systemctl disable v2ray || true
|
||||||
Reference in New Issue
Block a user