Skip to content

Commit

Permalink
Update caddy.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
smxl authored Oct 13, 2024
1 parent c46e8eb commit b83cc4b
Showing 1 changed file with 25 additions and 41 deletions.
66 changes: 25 additions & 41 deletions .github/workflows/caddy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,66 +13,50 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64] # 支持多架构的构建

steps:
- name: Checkout code
uses: actions/checkout@v4

# Setup Go environment
- name: Setup Go
uses: actions/setup-go@v5
with:
check-latest: true

- name: Initialize Go module
run: |
if [ ! -f go.mod ]; then
go mod init github.com/${{ github.repository }}
fi
- name: Generate go.sum
run: go mod tidy
check-latest: true # Ensure the latest Go version is used

# Install xcaddy
- name: Install xcaddy
env:
GOPATH: ${{ github.workspace }}/go # Use GITHUB_WORKSPACE for GOPATH
PATH: ${{ github.workspace }}/go/bin:${{ runner.home }}/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/usr/local/go/bin:$PATH
run: go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest

# Build Caddy with plugins
- name: Build Caddy with plugins
env:
GOPATH: ${{ github.workspace }}/go # Use GITHUB_WORKSPACE for GOPATH
PATH: ${{ github.workspace }}/go/bin:${{ runner.home }}/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/usr/local/go/bin:$PATH
run: |
CaddyVer=$(curl -s "https://api.github.com/repos/caddyserver/caddy/releases/latest" | jq -r .tag_name)
echo "CaddyVer=${CaddyVer}" >> $GITHUB_ENV
xcaddy build ${CaddyVer} \
--with github.com/imgk/caddy-trojan \
--with github.com/caddyserver/forwardproxy@caddy2=github.com/klzgrad/forwardproxy@naive \
--output caddy_linux-${{ matrix.arch }}
zstd -k -19 caddy_linux-${{ matrix.arch }} -o caddy_linux-${{ matrix.arch }}.zst
version=$(curl -s "https://api.github.com/repos/caddyserver/caddy/releases/latest" | jq -r .tag_name)
echo "CaddyVer=${version}" >> $GITHUB_ENV
for arch in amd64 arm64; do
xcaddy build latest \
--with github.com/imgk/caddy-trojan \
--with github.com/caddyserver/forwardproxy@caddy2=github.com/klzgrad/forwardproxy@naive \
--output caddy_linux-${arch}
zstd -k -19 caddy_linux-${arch} -o caddy_linux-${arch}.zst
done
# Upload built artifacts
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: caddy-${{ matrix.arch }}
path: ./caddy_linux-${{ matrix.arch }}.zst

release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Get current date
id: date
run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
name: caddy
path: ./caddy_linux-*.zst

# Upload release
- name: Upload release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.CaddyVer }}
body: Caddy ${{ env.CaddyVer }} with Trojan and Forwardproxy
file: artifacts/caddy-*/caddy_linux-*.zst
file: ./caddy_linux-*.zst
overwrite: true
file_glob: true

0 comments on commit b83cc4b

Please sign in to comment.