Skip to content

Commit

Permalink
Create caddy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
lxhao61 authored Dec 2, 2024
1 parent 7ea464c commit 2ad5b9c
Showing 1 changed file with 155 additions and 0 deletions.
155 changes: 155 additions & 0 deletions .github/workflows/caddy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
name: Build caddy

on:
workflow_dispatch:

release:
types:
- 'prereleased'
- 'published'
- 'released'

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
config:
- {
name: "windows-386",
GOARCH: 386,
GOOS: windows,
release: true
}
- {
name: "windows-amd64",
GOARCH: amd64,
GOOS: windows,
release: true
}
- {
name: "linux-amd64",
GOARCH: amd64,
GOOS: linux,
release: true
}
- {
name: "linux-arm64",
GOARCH: arm64,
GOOS: linux,
release: true
}
- {
name: "linux-armv5",
GOARCH: arm,
GOARM: 5,
GOOS: linux,
release: true
}
- {
name: "linux-s390x",
GOARCH: s390x,
GOOS: linux,
release: true
}
- {
name: "freebsd-amd64",
GOARCH: amd64,
GOOS: freebsd,
release: true
}
- {
name: "freebsd-arm64",
GOARCH: arm64,
GOOS: linux,
release: true
}
- {
name: "darwin-amd64",
GOARCH: amd64,
GOOS: darwin,
release: true
}
- {
name: "darwin-arm64",
GOARCH: arm64,
GOOS: darwin,
release: true
}

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

- name: Install go
uses: actions/setup-go@v5
with:
go-version: '1.23'
check-latest: true

- name: Install xcaddy
run: go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest

- name: Build caddy
run: |
mkdir release-tmp
export GOARCH=${{ matrix.config.GOARCH }}
export GOOS=${{ matrix.config.GOOS }}
~/go/bin/xcaddy build \
--with github.com/mholt/caddy-l4 \
--with github.com/caddy-dns/duckdns \
--with github.com/mholt/caddy-events-exec \
--with github.com/WeidiDeng/caddy-cloudflare-ip \
--with github.com/caddyserver/forwardproxy=github.com/klzgrad/forwardproxy@naive \
--with github.com/imgk/caddy-trojan \
--with github.com/mholt/caddy-webdav \
--output ./release-tmp/caddy
- name: Rename for Windows
if: matrix.config.GOOS == 'windows'
run: |
mv ./release-tmp/caddy ./release-tmp/caddy.exe
- name: Calculate Hash
run: |
cd ./release-tmp || exit 1
sha256sum * > sha256
- name: Generate zip for Windows
if: matrix.config.GOOS == 'windows'
run: |
mkdir release-ready
cd ./release-tmp
zip -r ../release-ready/caddy-${{ matrix.config.name }}.zip *
- name: Generate tar for other platform
if: matrix.config.GOOS != 'windows'
run: |
mkdir release-ready
cd ./release-tmp
tar -zcvf ../release-ready/caddy-${{ matrix.config.name }}.tar.gz *
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
with:
name: caddy-${{ github.sha }}-${{ matrix.config.name }}
path: ./release-ready/*

- name: Upload to GitHub Release for Windows
uses: svenstaro/upload-release-action@v2
if: github.event_name == 'release' && matrix.config.release && matrix.config.GOOS == 'windows'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./release-ready/caddy-${{ matrix.config.name }}.zip
tag: ${{ github.ref }}
overwrite: true

- name: Upload to GitHub Release for other platform
uses: svenstaro/upload-release-action@v2
if: github.event_name == 'release' && matrix.config.release && matrix.config.GOOS != 'windows'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./release-ready/caddy-${{ matrix.config.name }}.tar.gz
tag: ${{ github.ref }}
overwrite: true

0 comments on commit 2ad5b9c

Please sign in to comment.