commit e922074ba0530b091d06840c69ac0227737dac76 Author: paltovkone Date: Sat Mar 7 18:32:45 2026 +0400 feature test diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..fc5859c --- /dev/null +++ b/.gitea/workflows/build.yml @@ -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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..a383fcb --- /dev/null +++ b/README.md @@ -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 `/` +2. Add `nfpm.yaml` +3. Add `scripts/postinstall.sh` and `scripts/preremove.sh` +4. Add job to `.gitea/workflows/build.yml` diff --git a/packages.yml b/packages.yml new file mode 100644 index 0000000..72c4276 --- /dev/null +++ b/packages.yml @@ -0,0 +1,4 @@ +packages: + - name: v2ray + upstream: "https://github.com/v2fly/v2ray-core/releases/download/v{VERSION}/v2ray-linux-64.zip" + binary: v2ray diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100644 index 0000000..aaa85fc --- /dev/null +++ b/scripts/publish.sh @@ -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 [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}" diff --git a/v2ray/.DS_Store b/v2ray/.DS_Store new file mode 100644 index 0000000..8541510 Binary files /dev/null and b/v2ray/.DS_Store differ diff --git a/v2ray/VERSION b/v2ray/VERSION new file mode 100644 index 0000000..2df82a0 --- /dev/null +++ b/v2ray/VERSION @@ -0,0 +1 @@ +5.46.0 \ No newline at end of file diff --git a/v2ray/nfpm.yaml b/v2ray/nfpm.yaml new file mode 100644 index 0000000..500e99e --- /dev/null +++ b/v2ray/nfpm.yaml @@ -0,0 +1,35 @@ +name: v2ray +version: ${VERSION} +arch: amd64 +platform: linux +maintainer: nakolenke +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 diff --git a/v2ray/scripts/download.sh b/v2ray/scripts/download.sh new file mode 100644 index 0000000..2423abc --- /dev/null +++ b/v2ray/scripts/download.sh @@ -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 diff --git a/v2ray/scripts/postinstall.sh b/v2ray/scripts/postinstall.sh new file mode 100644 index 0000000..e90e95e --- /dev/null +++ b/v2ray/scripts/postinstall.sh @@ -0,0 +1,3 @@ +#!/bin/bash +systemctl daemon-reload +systemctl enable v2ray diff --git a/v2ray/scripts/preremove.sh b/v2ray/scripts/preremove.sh new file mode 100644 index 0000000..1542565 --- /dev/null +++ b/v2ray/scripts/preremove.sh @@ -0,0 +1,3 @@ +#!/bin/bash +systemctl stop v2ray || true +systemctl disable v2ray || true