v0.0.1 #7
Workflow file for this run
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: | |
| branches: [ main, master ] | |
| pull_request: | |
| branches: [ main, master ] | |
| release: | |
| types: [ published ] | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| test: | |
| name: Run Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.21' | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| - name: Cache Go modules | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - name: Cache Node modules | |
| uses: actions/cache@v3 | |
| with: | |
| path: web/node_modules | |
| key: ${{ runner.os }}-node-${{ hashFiles('web/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node- | |
| - name: Install Node.js dependencies | |
| run: cd web && npm ci | |
| - name: Run tests | |
| run: make test | |
| build-native: | |
| name: Build Native Binary | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| goos: linux | |
| goarch: amd64 | |
| - os: ubuntu-latest | |
| goos: linux | |
| goarch: arm64 | |
| - os: macos-latest | |
| goos: darwin | |
| goarch: amd64 | |
| - os: macos-latest | |
| goos: darwin | |
| goarch: arm64 | |
| runs-on: ${{ matrix.os }} | |
| needs: test | |
| if: github.event_name == 'push' || github.event_name == 'release' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.21' | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| - name: Install Node.js dependencies | |
| run: cd web && npm ci | |
| - name: Build dashboard | |
| run: | | |
| cd web | |
| npm run build | |
| mkdir -p ../internal/dashboard/web | |
| cp -r dist ../internal/dashboard/web/ | |
| - name: Build Lambda function | |
| run: | | |
| mkdir -p cmd/lambda-nat-proxy/assets | |
| cd lambda | |
| GOOS=linux GOARCH=amd64 go build -o ../cmd/lambda-nat-proxy/assets/bootstrap . | |
| chmod +x ../cmd/lambda-nat-proxy/assets/bootstrap | |
| - name: Build binary for ${{ matrix.goos }}/${{ matrix.goarch }} | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| run: | | |
| mkdir -p build | |
| CGO_ENABLED=0 go build -a -installsuffix cgo -o build/lambda-nat-proxy ./cmd/lambda-nat-proxy | |
| # Copy bootstrap to build directory | |
| cp cmd/lambda-nat-proxy/assets/bootstrap build/ | |
| - name: Create archive | |
| run: | | |
| cd build | |
| tar -czf lambda-nat-proxy-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz lambda-nat-proxy bootstrap | |
| mv lambda-nat-proxy-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz ../ | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: lambda-nat-proxy-${{ matrix.goos }}-${{ matrix.goarch }} | |
| path: lambda-nat-proxy-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz | |
| retention-days: 30 | |
| release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| needs: build-native | |
| if: github.event_name == 'release' | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Display structure of downloaded files | |
| run: ls -la artifacts/ | |
| - name: Upload release assets | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: artifacts/**/*.tar.gz | |
| fail_on_unmatched_files: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| docker: | |
| name: Build and Push Docker Image | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=ref,event=branch | |
| type=sha,prefix={{branch}}- | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile.build | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |