name: CI Build on: push: pull_request: permissions: contents: read concurrency: group: ci-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: frontend: name: Build frontend runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' cache: npm cache-dependency-path: web/package-lock.json - name: Install frontend dependencies working-directory: web run: npm ci - name: Build frontend working-directory: web run: npm run build - name: Upload frontend artifact uses: actions/upload-artifact@v4 with: name: frontend-dist path: web/dist retention-days: 1 android-apk: name: Build Android debug APK runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Java uses: actions/setup-java@v4 with: distribution: temurin java-version: '17' - name: Setup Android SDK uses: android-actions/setup-android@v3 - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 with: gradle-version: '8.7' - name: Build debug APK working-directory: android run: gradle --no-daemon assembleDebug - name: Upload Android APK artifact uses: actions/upload-artifact@v4 with: name: gotunnel-android-debug-apk path: android/app/build/outputs/apk/debug/app-debug.apk retention-days: 7 build: name: Build ${{ matrix.goos }}/${{ matrix.goarch }} needs: frontend runs-on: ${{ matrix.runner }} strategy: fail-fast: false matrix: include: - runner: ubuntu-latest goos: linux goarch: amd64 - runner: ubuntu-latest goos: linux goarch: arm64 - runner: windows-latest goos: windows goarch: amd64 - runner: windows-latest goos: windows goarch: arm64 - runner: macos-latest goos: darwin goarch: amd64 - runner: macos-latest goos: darwin goarch: arm64 steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Go uses: actions/setup-go@v5 with: go-version-file: go.mod cache: true - name: Download frontend artifact uses: actions/download-artifact@v4 with: name: frontend-dist path: internal/server/app/dist - name: Download Go modules run: go mod download - name: Build server and client shell: bash env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} CGO_ENABLED: 0 run: | mkdir -p build/${GOOS}_${GOARCH} EXT="" if [ "$GOOS" = "windows" ]; then EXT=".exe" fi BUILD_TIME="$(date -u '+%Y-%m-%dT%H:%M:%SZ')" GIT_COMMIT="${GITHUB_SHA::7}" VERSION="${GITHUB_REF_NAME}" if [ "${GITHUB_REF_TYPE}" != "tag" ]; then VERSION="${GITHUB_SHA::7}" fi LDFLAGS="-s -w -X 'main.Version=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}' -X 'main.GitCommit=${GIT_COMMIT}'" go build -trimpath -ldflags "$LDFLAGS" -o "build/${GOOS}_${GOARCH}/server${EXT}" ./cmd/server go build -trimpath -ldflags "$LDFLAGS" -o "build/${GOOS}_${GOARCH}/client${EXT}" ./cmd/client - name: Upload binaries artifact uses: actions/upload-artifact@v4 with: name: gotunnel-${{ matrix.goos }}-${{ matrix.goarch }} path: build/${{ matrix.goos }}_${{ matrix.goarch }}/ retention-days: 7