Build and Release #4
This file contains hidden or 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 and Release | |
| on: | |
| push: | |
| tags: ['v*'] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Release version (e.g., v1.0.0)' | |
| required: true | |
| type: string | |
| env: | |
| DOTNET_VERSION: '9.0.x' | |
| NODE_VERSION: '20.x' | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build-frontend: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Build frontend | |
| working-directory: ./web | |
| run: | | |
| rm -rf package-lock.json node_modules | |
| npm i | |
| npm run build | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: frontend-dist | |
| path: web/dist/ | |
| build-backend: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| runtime: [linux-x64, win-x64, osx-arm64] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Publish backend | |
| run: | | |
| dotnet publish src/ClaudeCodeProxy.Host/ClaudeCodeProxy.Host.csproj \ | |
| --configuration Release \ | |
| --runtime ${{ matrix.runtime }} \ | |
| --self-contained true \ | |
| --output ./publish/${{ matrix.runtime }} | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: backend-${{ matrix.runtime }} | |
| path: ./publish/${{ matrix.runtime }}/ | |
| build-docker: | |
| runs-on: ubuntu-latest | |
| needs: build-frontend | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: frontend-dist | |
| path: web/dist/ | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: docker/metadata-action@v5 | |
| id: meta | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=raw,value=latest | |
| - uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| create-release: | |
| runs-on: ubuntu-latest | |
| needs: [build-frontend, build-backend, build-docker] | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: ./artifacts/ | |
| - name: Package releases | |
| run: | | |
| VERSION="${{ github.event.inputs.version || github.ref_name }}" | |
| mkdir -p release-packages | |
| for runtime in linux-x64 win-x64 osx-arm64; do | |
| mkdir -p "temp/$runtime" | |
| cp -r "artifacts/backend-$runtime"/* "temp/$runtime/" | |
| mkdir -p "temp/$runtime/wwwroot" | |
| cp -r "artifacts/frontend-dist"/* "temp/$runtime/wwwroot/" | |
| if [[ "$runtime" == win-* ]]; then | |
| cd "temp/$runtime" && zip -r "../../release-packages/ClaudeCodeProxy-${VERSION}-${runtime}.zip" . | |
| else | |
| tar -czf "release-packages/ClaudeCodeProxy-${VERSION}-${runtime}.tar.gz" -C "temp/$runtime" . | |
| fi | |
| rm -rf "temp/$runtime" | |
| done | |
| cd release-packages && sha256sum * > SHA256SUMS.txt | |
| - uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ github.event.inputs.version || github.ref_name }} | |
| name: ClaudeCodeProxy ${{ github.event.inputs.version || github.ref_name }} | |
| body: | | |
| ## Release ${{ github.event.inputs.version || github.ref_name }} | |
| Download the appropriate package for your platform and extract it. | |
| ### Docker | |
| ```bash | |
| docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.event.inputs.version || github.ref_name }} | |
| ``` | |
| files: release-packages/* |