mirror of
https://github.com/awfufu/frp-pkgs.git
synced 2026-03-01 04:49:44 +08:00
343 lines
12 KiB
YAML
343 lines
12 KiB
YAML
name: build and publish packages
|
|
|
|
"on":
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: 'Version to build (e.g. 0.38.0)'
|
|
required: false
|
|
force_build:
|
|
description: 'Force build even if exists'
|
|
type: boolean
|
|
required: false
|
|
default: false
|
|
|
|
permissions:
|
|
contents: write
|
|
deployments: write
|
|
|
|
jobs:
|
|
check_version:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
build: ${{ steps.check.outputs.build }}
|
|
version: ${{ steps.check.outputs.version }}
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Check for updates
|
|
id: check
|
|
run: |
|
|
if [ -n "${{ inputs.version }}" ]; then
|
|
INPUT_VERSION="${{ inputs.version }}"
|
|
VERSION=${INPUT_VERSION#v}
|
|
echo "Using input version: $VERSION"
|
|
echo "build=true" >> $GITHUB_OUTPUT
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
exit 0
|
|
fi
|
|
|
|
LATEST_TAG=$(curl -s https://api.github.com/repos/fatedier/frp/releases/latest | jq -r .tag_name)
|
|
LATEST_VERSION=${LATEST_TAG#v}
|
|
echo "Latest upstream version: $LATEST_VERSION"
|
|
|
|
CURRENT_TAG=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
|
|
if [ "$CURRENT_TAG" == "null" ]; then
|
|
CURRENT_VERSION="0.0.0"
|
|
else
|
|
CURRENT_VERSION=${CURRENT_TAG#v}
|
|
fi
|
|
echo "Current repo version: $CURRENT_VERSION"
|
|
|
|
if [ "$LATEST_VERSION" == "$CURRENT_VERSION" ] && [ "${{ github.event_name }}" != "workflow_dispatch" ] && [ "${{ inputs.force_build }}" != "true" ]; then
|
|
echo "Already up to date."
|
|
echo "build=false" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "New version available."
|
|
echo "build=true" >> $GITHUB_OUTPUT
|
|
echo "version=$LATEST_VERSION" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
build_rpm:
|
|
needs: check_version
|
|
if: needs.check_version.outputs.build == 'true'
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
arch: [x86_64, aarch64]
|
|
container:
|
|
image: fedora:latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install dependencies
|
|
run: dnf install -y rpm-build wget systemd-rpm-macros
|
|
|
|
- name: Prepare Sources
|
|
run: |
|
|
VERSION=${{ needs.check_version.outputs.version }}
|
|
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
|
|
|
|
# Download source
|
|
if [ "${{ matrix.arch }}" == "x86_64" ]; then
|
|
GOARCH="amd64"
|
|
else
|
|
GOARCH="arm64"
|
|
fi
|
|
|
|
wget https://github.com/fatedier/frp/releases/download/v${VERSION}/frp_${VERSION}_linux_${GOARCH}.tar.gz -O ~/rpmbuild/SOURCES/frp_${VERSION}_linux_${GOARCH}.tar.gz
|
|
|
|
cp frp.spec ~/rpmbuild/SPECS/
|
|
|
|
# Automate Changelog Date using placeholder in frp.spec
|
|
# Format: * Day Mon DD YYYY Name <Email> - Version-Release
|
|
CURRENT_DATE=$(LC_TIME=en_US.UTF-8 date "+%a %b %d %Y")
|
|
sed -i "s/%{date}/$CURRENT_DATE/" ~/rpmbuild/SPECS/frp.spec
|
|
|
|
cp frpc@.service ~/rpmbuild/SOURCES/
|
|
cp frps@.service ~/rpmbuild/SOURCES/
|
|
cp frpc.service ~/rpmbuild/SOURCES/
|
|
cp frps.service ~/rpmbuild/SOURCES/
|
|
|
|
- name: Build RPM
|
|
run: |
|
|
VERSION=${{ needs.check_version.outputs.version }}
|
|
RELEASE="1"
|
|
rpmbuild -bb ~/rpmbuild/SPECS/frp.spec \
|
|
--define "_version ${VERSION}" \
|
|
--define "_release ${RELEASE}" \
|
|
--target ${{ matrix.arch }}
|
|
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: frp-rpm-${{ matrix.arch }}
|
|
path: ~/rpmbuild/RPMS/${{ matrix.arch }}/*.rpm
|
|
|
|
build_deb:
|
|
needs: check_version
|
|
if: needs.check_version.outputs.build == 'true'
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
arch: [amd64, arm64]
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Download sources
|
|
run: |
|
|
VERSION=${{ needs.check_version.outputs.version }}
|
|
ARCH=${{ matrix.arch }}
|
|
wget https://github.com/fatedier/frp/releases/download/v${VERSION}/frp_${VERSION}_linux_${ARCH}.tar.gz
|
|
tar xzf frp_${VERSION}_linux_${ARCH}.tar.gz
|
|
mv frp_${VERSION}_linux_${ARCH} frp_bin
|
|
|
|
- name: Build frpc package
|
|
run: |
|
|
VERSION=${{ needs.check_version.outputs.version }}
|
|
ARCH=${{ matrix.arch }}
|
|
|
|
mkdir -p frpc_pkg/DEBIAN
|
|
mkdir -p frpc_pkg/usr/bin
|
|
mkdir -p frpc_pkg/usr/lib/systemd/system
|
|
mkdir -p frpc_pkg/etc/frpc
|
|
|
|
cp frp_bin/frpc frpc_pkg/usr/bin/
|
|
cp frp_bin/frpc.toml frpc_pkg/etc/frpc/
|
|
cp frpc@.service frpc_pkg/usr/lib/systemd/system/
|
|
cp frpc.service frpc_pkg/usr/lib/systemd/system/
|
|
|
|
cat > frpc_pkg/DEBIAN/control <<EOF
|
|
Package: frpc
|
|
Version: ${VERSION}-1
|
|
Section: net
|
|
Priority: optional
|
|
Architecture: ${ARCH}
|
|
Depends: systemd
|
|
Maintainer: awfufu <me@awfufu.com>
|
|
Description: Client for frp (Fast Reverse Proxy)
|
|
frp is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.
|
|
EOF
|
|
|
|
dpkg-deb --build frpc_pkg frpc_${VERSION}-1_${ARCH}.deb
|
|
|
|
- name: Build frps package
|
|
run: |
|
|
VERSION=${{ needs.check_version.outputs.version }}
|
|
ARCH=${{ matrix.arch }}
|
|
|
|
mkdir -p frps_pkg/DEBIAN
|
|
mkdir -p frps_pkg/usr/bin
|
|
mkdir -p frps_pkg/usr/lib/systemd/system
|
|
mkdir -p frps_pkg/etc/frps
|
|
|
|
cp frp_bin/frps frps_pkg/usr/bin/
|
|
cp frp_bin/frps.toml frps_pkg/etc/frps/
|
|
cp frps@.service frps_pkg/usr/lib/systemd/system/
|
|
cp frps.service frps_pkg/usr/lib/systemd/system/
|
|
|
|
cat > frps_pkg/DEBIAN/control <<EOF
|
|
Package: frps
|
|
Version: ${VERSION}-1
|
|
Section: net
|
|
Priority: optional
|
|
Architecture: ${ARCH}
|
|
Depends: systemd
|
|
Maintainer: awfufu <me@awfufu.com>
|
|
Description: Server for frp (Fast Reverse Proxy)
|
|
frp is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.
|
|
EOF
|
|
|
|
dpkg-deb --build frps_pkg frps_${VERSION}-1_${ARCH}.deb
|
|
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: frp-deb-${{ matrix.arch }}
|
|
path: "*.deb"
|
|
|
|
release:
|
|
needs: [check_version, build_rpm, build_deb]
|
|
if: needs.check_version.outputs.build == 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: Create Release
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
tag_name: v${{ needs.check_version.outputs.version }}
|
|
name: v${{ needs.check_version.outputs.version }}
|
|
body: |
|
|
Auto release for frp v${{ needs.check_version.outputs.version }}
|
|
files: |
|
|
artifacts/**/*
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
deploy:
|
|
needs: [check_version, release]
|
|
if: needs.check_version.outputs.build == 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: Setup Output Structure
|
|
run: |
|
|
mkdir -p output
|
|
|
|
- name: Setup RPM Repo
|
|
run: |
|
|
# Artifacts: frp-rpm-{arch} in artifacts/
|
|
for dir in artifacts/frp-rpm-*; do
|
|
dirname=$(basename "$dir")
|
|
arch=$(echo $dirname | sed -E 's/frp-rpm-//')
|
|
mkdir -p output/$arch
|
|
cp $dir/*.rpm output/$arch/
|
|
done
|
|
|
|
echo "[go-frp]
|
|
name=FRP Packages for Fedora - \$basearch
|
|
baseurl=https://go-frp.awfufu.com/\$basearch/
|
|
enabled=1
|
|
gpgcheck=0" > output/go-frp.repo
|
|
|
|
sudo apt-get update
|
|
sudo apt-get install -y createrepo-c
|
|
|
|
# Only run createrepo on RPM architecture directories
|
|
for arch in x86_64 aarch64; do
|
|
if [ -d "output/$arch" ]; then
|
|
createrepo_c --database --update "output/$arch"
|
|
fi
|
|
done
|
|
|
|
- name: Setup DEB Repo
|
|
run: |
|
|
# Create standard repository structure
|
|
mkdir -p output/pool/main
|
|
mkdir -p output/dists/stable/main/binary-amd64
|
|
mkdir -p output/dists/stable/main/binary-arm64
|
|
|
|
# Move artifacts to pool
|
|
find artifacts -name "*.deb" -exec cp {} output/pool/main/ \;
|
|
|
|
sudo apt-get install -y dpkg-dev apt-utils
|
|
cd output
|
|
|
|
# Generate Packages indices
|
|
dpkg-scanpackages --arch amd64 pool/main > dists/stable/main/binary-amd64/Packages
|
|
gzip -k -f dists/stable/main/binary-amd64/Packages
|
|
|
|
dpkg-scanpackages --arch arm64 pool/main > dists/stable/main/binary-arm64/Packages
|
|
gzip -k -f dists/stable/main/binary-arm64/Packages
|
|
|
|
# Generate Release file
|
|
cat > apt-ftparchive.conf <<EOF
|
|
APT::FTPArchive::Release::Origin "FRP";
|
|
APT::FTPArchive::Release::Label "FRP";
|
|
APT::FTPArchive::Release::Suite "stable";
|
|
APT::FTPArchive::Release::Codename "stable";
|
|
APT::FTPArchive::Release::Architectures "amd64 arm64";
|
|
APT::FTPArchive::Release::Components "main";
|
|
APT::FTPArchive::Release::Description "FRP Packages";
|
|
EOF
|
|
|
|
apt-ftparchive release -c apt-ftparchive.conf dists/stable > dists/stable/Release
|
|
|
|
# GPG Signing
|
|
echo "${{ secrets.GPG_PRIVATE_KEY }}" | base64 -d > private.key
|
|
gpg --batch --import private.key
|
|
rm private.key
|
|
|
|
# Export public key for users
|
|
gpg --armor --export "me@awfufu.com" > public.gpg
|
|
|
|
# Sign indices
|
|
gpg --batch --yes --pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}" --clearsign -o dists/stable/InRelease dists/stable/Release
|
|
gpg --batch --yes --pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}" -abs -o dists/stable/Release.gpg dists/stable/Release
|
|
env:
|
|
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
|
|
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
|
|
|
|
- name: Generate Index Page
|
|
run: |
|
|
sudo apt-get install -y pandoc
|
|
GITHUB_LINE="\n\n[](https://github.com/awfufu/frp-pkgs) [GitHub](https://github.com/awfufu/frp-pkgs)"
|
|
|
|
# English Version (Index)
|
|
|
|
sed '1d' README.md | sed "s|\[简体中文\](README_cn.md)|[简体中文](cn.html)$GITHUB_LINE|" > README_temp.md
|
|
pandoc README_temp.md -o output/index.html --metadata title="frp packages" -s
|
|
|
|
# Chinese Version
|
|
|
|
sed '1d' README_cn.md | sed "s|简体中文|简体中文$GITHUB_LINE|" | sed 's|\[English\](README.md)|[English](index.html)|' > README_cn_temp.md
|
|
pandoc README_cn_temp.md -o output/cn.html --metadata title="frp packages" -s
|
|
|
|
# Clean up
|
|
rm README_temp.md README_cn_temp.md
|
|
|
|
- name: Deploy to Cloudflare Pages
|
|
uses: cloudflare/pages-action@v1
|
|
with:
|
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
projectName: go-frp
|
|
directory: output
|
|
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|