feat: Update docker-buildimage-caddy.yml #62
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: docker-buildimage-caddy | |
on: | |
push: | |
branches: [ main ] | |
paths: | |
- 'docker/caddy/**' | |
- '.github/workflows/docker-buildimage-caddy.yml' | |
jobs: | |
sematic-version: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.semantic.outputs.new_release_version }} | |
caddy_version: v2.8.4 | |
go_build_flags: "-trimpath -ldflags '-w s'" | |
caddy_with: > | |
--with github.com/caddy-dns/cloudflare | |
--with github.com/caddy-dns/route53 | |
--with github.com/caddy-dns/vultr | |
--with github.com/gsmlg-dev/caddy-storage-s3 | |
--with github.com/gsmlg-dev/caddy-admin-ui@main | |
--with github.com/gsmlg-dev/caddy-oauth2 | |
--with github.com/caddyserver/cache-handler | |
--with github.com/caddyserver/replace-response | |
--with github.com/caddyserver/forwardproxy | |
--with github.com/greenpau/caddy-security | |
--with github.com/mholt/caddy-ratelimit | |
--with github.com/mholt/caddy-webdav | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Create package.json | |
run: | | |
cat <<EOF > docker/caddy/package.json | |
{ | |
"name": "caddy" | |
} | |
EOF | |
- name: 🏗 Run install semantic-release | |
working-directory: docker/caddy | |
run: npm install --save-dev semantic-release-monorepo semantic-release @semantic-release/exec | |
- name: 🚀 Release | |
working-directory: docker/caddy | |
id: semantic | |
run: npx semantic-release --extends semantic-release-monorepo | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GOPRIVATE: github.com/gsmlg-dev/gsmlg-golang | |
build-package: | |
runs-on: ubuntu-latest | |
needs: [ sematic-version ] | |
strategy: | |
matrix: | |
platforms: | |
- os: linux | |
arch: amd64 | |
- os: darwin | |
arch: amd64 | |
- os: freebsd | |
arch: amd64 | |
- os: windows | |
arch: amd64 | |
- os: linux | |
arch: arm64 | |
- os: android | |
arch: arm64 | |
- os: darwin | |
arch: arm64 | |
- os: windows | |
arch: arm64 | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup golang | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '1.21.4' | |
- name: Install xcaddy | |
run: go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest | |
- name: Configure git for private modules | |
env: | |
USER: ${{ secrets.GIT_USER_ID }} | |
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
run: git config --global url."https://${USER}:${TOKEN}@github.com".insteadOf "https://github.com" | |
- name: Build by xcaddy | |
env: | |
GOOS: ${{ matrix.platforms.os }} | |
GOARCH: ${{ matrix.platforms.arch }} | |
CADDY_VERSION: ${{ needs.sematic-version.outputs.caddy_version }} | |
CADDY_WITH: ${{ needs.sematic-version.outputs.caddy_with }} | |
GOPRIVATE: github.com/gsmlg-dev/gsmlg-golang,gsmlg.dev | |
CGO_ENABLED: "0" | |
# XCADDY_GO_BUILD_FLAGS: ${{ needs.sematic-version.outputs.go_build_flags }} | |
run: | | |
xcaddy build ${CADDY_VERSION} --output "caddy_${GOOS}_${GOARCH}" $CADDY_WITH | |
- name: Upload binaries to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: caddy_${{ matrix.platforms.os }}_${{ matrix.platforms.arch }} | |
asset_name: caddy_${{ matrix.platforms.os }}_${{ matrix.platforms.arch }} | |
tag: caddy-v${{ needs.sematic-version.outputs.version }} | |
build-image: | |
runs-on: ubuntu-latest | |
needs: [ sematic-version ] | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- | |
name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USER }} | |
password: ${{ secrets.DOCKERHUB_PASSWD }} | |
- | |
name: Login to ghcr.io | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
- | |
name: Build and push | |
id: build | |
uses: docker/build-push-action@v3 | |
with: | |
context: docker/caddy/ | |
file: docker/caddy/Dockerfile | |
platforms: linux/amd64,linux/arm64/v8 | |
push: true | |
build-args: | | |
CADDY_VERSION=${{ needs.sematic-version.outputs.caddy_version }} | |
CADDY_WITH=${{ needs.sematic-version.outputs.caddy_with }} | |
USER=${{ secrets.GIT_USER_ID }} | |
TOKEN=${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
GOPRIVATE=github.com/gsmlg-dev/gsmlg-golang,gsmlg.dev | |
CGO_ENABLED=0 | |
tags: | | |
docker.io/gsmlg/caddy:v${{ needs.sematic-version.outputs.version }} | |
docker.io/gsmlg/caddy:latest | |
ghcr.io/gsmlg/caddy:v${{ needs.sematic-version.outputs.version }} | |
ghcr.io/gsmlg/caddy:latest |