135 lines
4.3 KiB
YAML
135 lines
4.3 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*.*.*'
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
jobs:
|
|
build-frontend:
|
|
name: Build Frontend
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
cache-dependency-path: frontend/package-lock.json
|
|
|
|
- name: Install Dependencies
|
|
working-directory: frontend
|
|
run: npm ci
|
|
|
|
- name: Build
|
|
working-directory: frontend
|
|
run: npm run build
|
|
|
|
- name: Archive Frontend
|
|
working-directory: frontend
|
|
run: tar -czf ../frontend-dist.tar.gz dist/
|
|
|
|
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
|
with:
|
|
name: frontend-dist
|
|
path: frontend-dist.tar.gz
|
|
|
|
build-backend:
|
|
name: Build Backend
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
goos: [linux]
|
|
goarch: [amd64, arm64]
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
|
|
with:
|
|
go-version: '1.23'
|
|
|
|
- name: Build
|
|
working-directory: backend
|
|
env:
|
|
GOOS: ${{ matrix.goos }}
|
|
GOARCH: ${{ matrix.goarch }}
|
|
CGO_ENABLED: 1
|
|
run: |
|
|
# Install dependencies for CGO (sqlite)
|
|
if [ "${{ matrix.goarch }}" = "arm64" ]; then
|
|
sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu
|
|
export CC=aarch64-linux-gnu-gcc
|
|
fi
|
|
|
|
go build -ldflags "-s -w -X github.com/Wikid82/CaddyProxyManagerPlus/backend/internal/version.Version=${{ github.ref_name }}" -o ../cpmp-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/api
|
|
|
|
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
|
with:
|
|
name: backend-${{ matrix.goos }}-${{ matrix.goarch }}
|
|
path: cpmp-${{ matrix.goos }}-${{ matrix.goarch }}
|
|
|
|
build-caddy:
|
|
name: Build Caddy
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
goos: [linux]
|
|
goarch: [amd64, arm64]
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
|
|
with:
|
|
go-version: '1.23'
|
|
|
|
- name: Install xcaddy
|
|
run: go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
|
|
|
|
- name: Build Caddy
|
|
env:
|
|
GOOS: ${{ matrix.goos }}
|
|
GOARCH: ${{ matrix.goarch }}
|
|
run: |
|
|
xcaddy build v2.9.1 \
|
|
--replace github.com/quic-go/quic-go=github.com/quic-go/quic-go@v0.49.1 \
|
|
--replace golang.org/x/crypto=golang.org/x/crypto@v0.35.0 \
|
|
--output caddy-${{ matrix.goos }}-${{ matrix.goarch }}
|
|
|
|
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
|
with:
|
|
name: caddy-${{ matrix.goos }}-${{ matrix.goarch }}
|
|
path: caddy-${{ matrix.goos }}-${{ matrix.goarch }}
|
|
|
|
create-release:
|
|
name: Create Release
|
|
needs: [build-frontend, build-backend, build-caddy]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: Display structure of downloaded files
|
|
run: ls -R artifacts
|
|
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1
|
|
with:
|
|
files: |
|
|
artifacts/frontend-dist/frontend-dist.tar.gz
|
|
artifacts/backend-linux-amd64/cpmp-linux-amd64
|
|
artifacts/backend-linux-arm64/cpmp-linux-arm64
|
|
artifacts/caddy-linux-amd64/caddy-linux-amd64
|
|
artifacts/caddy-linux-arm64/caddy-linux-arm64
|
|
generate_release_notes: true
|
|
prerelease: ${{ contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc') }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }}
|
|
|
|
build-and-publish:
|
|
needs: create-release
|
|
uses: ./.github/workflows/docker-publish.yml
|
|
secrets: inherit
|