Build caddy #334
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.22' | |
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 |