mirror of
https://github.com/awfufu/frp-pkgs.git
synced 2026-03-01 04:49:44 +08:00
ci: consolidate workflows to build_publish for atomic cloudflare deployment
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
name: build deb packages
|
||||
name: build and publish packages
|
||||
|
||||
"on":
|
||||
workflow_dispatch:
|
||||
@@ -28,10 +28,8 @@ jobs:
|
||||
- name: Check for updates
|
||||
id: check
|
||||
run: |
|
||||
# If version is provided via input, use it
|
||||
if [ -n "${{ inputs.version }}" ]; then
|
||||
INPUT_VERSION="${{ inputs.version }}"
|
||||
# Strip v prefix if present
|
||||
VERSION=${INPUT_VERSION#v}
|
||||
echo "Using input version: $VERSION"
|
||||
echo "build=true" >> $GITHUB_OUTPUT
|
||||
@@ -42,7 +40,7 @@ jobs:
|
||||
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"
|
||||
@@ -50,7 +48,7 @@ jobs:
|
||||
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
|
||||
@@ -60,7 +58,57 @@ jobs:
|
||||
echo "version=$LATEST_VERSION" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
build:
|
||||
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
|
||||
|
||||
- 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/
|
||||
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
|
||||
@@ -76,8 +124,6 @@ jobs:
|
||||
run: |
|
||||
VERSION=${{ needs.check_version.outputs.version }}
|
||||
ARCH=${{ matrix.arch }}
|
||||
|
||||
# Download FRP binary
|
||||
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
|
||||
@@ -92,12 +138,10 @@ jobs:
|
||||
mkdir -p frpc_pkg/lib/systemd/system
|
||||
mkdir -p frpc_pkg/etc/frp
|
||||
|
||||
# Install files
|
||||
cp frp_bin/frpc frpc_pkg/usr/bin/
|
||||
cp frp_bin/frpc.toml frpc_pkg/etc/frp/
|
||||
cp frpc@.service frpc_pkg/lib/systemd/system/
|
||||
|
||||
# Create control file
|
||||
cat > frpc_pkg/DEBIAN/control <<EOF
|
||||
Package: frpc
|
||||
Version: ${VERSION}-1
|
||||
@@ -122,12 +166,10 @@ jobs:
|
||||
mkdir -p frps_pkg/lib/systemd/system
|
||||
mkdir -p frps_pkg/etc/frp
|
||||
|
||||
# Install files
|
||||
cp frp_bin/frps frps_pkg/usr/bin/
|
||||
cp frp_bin/frps.toml frps_pkg/etc/frp/
|
||||
cp frps@.service frps_pkg/lib/systemd/system/
|
||||
|
||||
# Create control file
|
||||
cat > frps_pkg/DEBIAN/control <<EOF
|
||||
Package: frps
|
||||
Version: ${VERSION}-1
|
||||
@@ -149,7 +191,7 @@ jobs:
|
||||
path: "*.deb"
|
||||
|
||||
release:
|
||||
needs: [check_version, build]
|
||||
needs: [check_version, build_rpm, build_deb]
|
||||
if: needs.check_version.outputs.build == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -164,14 +206,14 @@ jobs:
|
||||
tag_name: v${{ needs.check_version.outputs.version }}
|
||||
name: v${{ needs.check_version.outputs.version }}
|
||||
body: |
|
||||
Auto DEB build for frp v${{ needs.check_version.outputs.version }}
|
||||
Auto release for frp v${{ needs.check_version.outputs.version }}
|
||||
files: |
|
||||
artifacts/**/*.deb
|
||||
artifacts/**/*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
repo:
|
||||
needs: [check_version, build]
|
||||
deploy:
|
||||
needs: [check_version, release]
|
||||
if: needs.check_version.outputs.build == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -183,26 +225,46 @@ jobs:
|
||||
with:
|
||||
path: artifacts
|
||||
|
||||
- name: Setup Repo Structure
|
||||
- name: Setup Output Structure
|
||||
run: |
|
||||
mkdir -p deb
|
||||
mkdir -p output/repo
|
||||
mkdir -p output/deb
|
||||
|
||||
# Flatten artifacts
|
||||
find artifacts -name "*.deb" -exec cp {} deb/ \;
|
||||
- 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/repo/$arch
|
||||
cp $dir/*.rpm output/repo/$arch/
|
||||
done
|
||||
|
||||
echo "[go-frp]
|
||||
name=FRP Packages for Fedora - \$basearch
|
||||
baseurl=https://go-frp.awfufu.com/\$basearch/
|
||||
enabled=1
|
||||
gpgcheck=0" > output/repo/go-frp.repo
|
||||
|
||||
echo "<html><body><h1>FRP RPM Repository</h1><p>Use the following command to configure this repository:</p><pre>sudo dnf config-manager --add-repo https://go-frp.awfufu.com/go-frp.repo</pre></body></html>" > output/repo/index.html
|
||||
|
||||
# Install dpkg-dev for scanpackages
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y createrepo-c
|
||||
for dir in output/repo/*; do
|
||||
if [ -d "$dir" ]; then
|
||||
createrepo_c "$dir"
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Setup DEB Repo
|
||||
run: |
|
||||
find artifacts -name "*.deb" -exec cp {} output/deb/ \;
|
||||
|
||||
sudo apt-get install -y dpkg-dev apt-utils
|
||||
|
||||
cd deb
|
||||
|
||||
# Generate Packages file
|
||||
cd output/deb
|
||||
dpkg-scanpackages . > Packages
|
||||
|
||||
# Compress
|
||||
gzip -k -f Packages
|
||||
|
||||
# Generate Release file
|
||||
cat > apt-ftparchive.conf <<EOF
|
||||
APT::FTPArchive::Release::Origin "FRP";
|
||||
APT::FTPArchive::Release::Label "FRP";
|
||||
@@ -212,18 +274,14 @@ jobs:
|
||||
APT::FTPArchive::Release::Components "main";
|
||||
APT::FTPArchive::Release::Description "FRP Packages";
|
||||
EOF
|
||||
|
||||
apt-ftparchive release . -c apt-ftparchive.conf > Release
|
||||
|
||||
# Do NOT remove .deb files, so they are published to gh-pages
|
||||
cd ..
|
||||
cd ../..
|
||||
|
||||
- name: Deploy to Cloudflare Pages
|
||||
uses: cloudflare/pages-action@v1
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
projectName: frp-pkgs
|
||||
directory: deb
|
||||
# Optional: Enable this if you want to have a default branch deployment (production)
|
||||
projectName: go-frp
|
||||
directory: output
|
||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
218
.github/workflows/build_rpm.yml
vendored
218
.github/workflows/build_rpm.yml
vendored
@@ -1,218 +0,0 @@
|
||||
name: build rpm 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
|
||||
|
||||
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 version is provided via input, use it
|
||||
if [ -n "${{ inputs.version }}" ]; then
|
||||
INPUT_VERSION="${{ inputs.version }}"
|
||||
# Strip v prefix if present
|
||||
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:
|
||||
needs: check_version
|
||||
if: needs.check_version.outputs.build == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [x86_64, aarch64]
|
||||
container:
|
||||
image: fedora:latest # Build on latest Fedora as base for universal package
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: dnf install -y rpm-build rpmdevtools wget git systemd-rpm-macros
|
||||
|
||||
- name: Download sources
|
||||
run: |
|
||||
VERSION=${{ needs.check_version.outputs.version }}
|
||||
ARCH=${{ matrix.arch }}
|
||||
if [ "$ARCH" == "x86_64" ]; then
|
||||
GOARCH="amd64"
|
||||
elif [ "$ARCH" == "aarch64" ]; then
|
||||
GOARCH="arm64"
|
||||
fi
|
||||
|
||||
mkdir -p ~/rpmbuild/SOURCES
|
||||
|
||||
# Download FRP binary
|
||||
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
|
||||
|
||||
# Copy service files to SOURCES
|
||||
cp frpc@.service ~/rpmbuild/SOURCES/
|
||||
cp frps@.service ~/rpmbuild/SOURCES/
|
||||
|
||||
- name: Build RPM
|
||||
run: |
|
||||
VERSION=${{ needs.check_version.outputs.version }}
|
||||
rpmbuild -bb \
|
||||
--define "_version ${VERSION}" \
|
||||
--define "_release 1" \
|
||||
--target ${{ matrix.arch }} \
|
||||
frp.spec
|
||||
|
||||
# Rename artifacts to include version if not already obvious, but rpmbuild naming is standard.
|
||||
# Standard: name-ver-rel.dist.arch.rpm
|
||||
# We'll just list them to be sure
|
||||
ls -l ~/rpmbuild/RPMS/${{ matrix.arch }}/
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: frp-rpm-${{ matrix.arch }}
|
||||
path: /github/home/rpmbuild/RPMS/${{ matrix.arch }}/*.rpm
|
||||
|
||||
release:
|
||||
needs: [check_version, build]
|
||||
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: Display structure of downloaded files
|
||||
run: ls -R 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 RPM build for frp v${{ needs.check_version.outputs.version }}
|
||||
|
||||
Universal RPM packages for x86_64 and aarch64.
|
||||
files: |
|
||||
artifacts/**/*.rpm
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
repo:
|
||||
needs: [check_version, build]
|
||||
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 Repo Structure
|
||||
run: |
|
||||
mkdir -p repo
|
||||
# Artifacts are named frp-rpm-{arch}
|
||||
# We want structure: repo/{arch}/
|
||||
|
||||
for dir in artifacts/*; do
|
||||
dirname=$(basename "$dir")
|
||||
# Extract arch from frp-rpm-<arch>
|
||||
# dirname format: frp-rpm-<arch>
|
||||
arch=$(echo $dirname | sed -E 's/frp-rpm-//')
|
||||
|
||||
mkdir -p repo/$arch
|
||||
cp $dir/*.rpm repo/$arch/
|
||||
done
|
||||
|
||||
# Generate go-frp.repo
|
||||
echo "[go-frp]
|
||||
name=FRP Packages for Fedora - \$basearch
|
||||
baseurl=https://go-frp.awfufu.com/\$basearch/
|
||||
enabled=1
|
||||
gpgcheck=0" > repo/go-frp.repo
|
||||
|
||||
# Generate index.html
|
||||
echo "<html><body><h1>FRP RPM Repository</h1><p>Use the following command to configure this repository:</p><pre>sudo dnf config-manager addrepo --from-repofile=https://go-frp.awfufu.com/go-frp.repo</pre><p>For older DNF versions:</p><pre>sudo dnf config-manager --add-repo https://go-frp.awfufu.com/go-frp.repo</pre></body></html>" > repo/index.html
|
||||
|
||||
- name: Generate Repodata
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y createrepo-c
|
||||
|
||||
for dir in repo/*; do
|
||||
if [ -d "$dir" ]; then
|
||||
echo "Processing $dir..."
|
||||
# Calculate Base URL for this version's release artifacts
|
||||
# GitHub Release structure: https://github.com/<owner>/<repo>/releases/download/<tag>/<filename>
|
||||
# We assume the RPM filename in the repo matches the one in the release.
|
||||
|
||||
BASE_URL="https://github.com/${{ github.repository }}/releases/download/v${{ needs.check_version.outputs.version }}/"
|
||||
|
||||
createrepo_c --baseurl "$BASE_URL" "$dir"
|
||||
|
||||
# Remove RPM files so they are not committed to gh-pages
|
||||
rm "$dir"/*.rpm
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Deploy to Cloudflare Pages
|
||||
uses: cloudflare/pages-action@v1
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
projectName: frp-pkgs-rpm
|
||||
directory: repo
|
||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
|
||||
13
.github/workflows/check_updates.yml
vendored
13
.github/workflows/check_updates.yml
vendored
@@ -40,16 +40,9 @@ jobs:
|
||||
echo "version=$LATEST_VERSION" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Trigger RPM Build
|
||||
- name: Trigger Build
|
||||
if: steps.check.outputs.build == 'true'
|
||||
run: |
|
||||
gh workflow run build_rpm.yml -f version=${{ steps.check.outputs.version }}
|
||||
gh workflow run build_publish.yml -f version=${{ steps.check.outputs.version }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Trigger Deb Build
|
||||
if: steps.check.outputs.build == 'true'
|
||||
run: |
|
||||
gh workflow run build_deb.yml -f version=${{ steps.check.outputs.version }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -9,8 +9,14 @@ Auto RPM build for [fatedier/frp](https://github.com/fatedier/frp) (Fast Reverse
|
||||
Add the repository to your system to receive automatic updates.
|
||||
|
||||
```bash
|
||||
sudo dnf config-manager --add-repo https://go-frp.awfufu.com/go-frp.repo
|
||||
# Add repository
|
||||
sudo dnf config-manager addrepo --from-repofile=https://go-frp.awfufu.com/go-frp.repo
|
||||
|
||||
# For old dnf
|
||||
# sudo dnf config-manager --add-repo https://go-frp.awfufu.com/go-frp.repo
|
||||
|
||||
# Update and install
|
||||
sudo dnf update
|
||||
sudo dnf install frpc frps
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user