name: CI on: push: pull_request: workflow_dispatch: permissions: contents: read concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true env: GOFLAGS: -mod=readonly GOTOOLCHAIN: local jobs: quality: name: Go quality and UI runs-on: ubuntu-24.04 timeout-minutes: 15 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 persist-credentials: false - uses: ./.github/actions/setup-go - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: '24' - name: Check formatting of changed Go files env: FORMAT_BASE: ${{ github.event.pull_request.base.sha || github.event.before }} FORMAT_HEAD: ${{ github.sha }} DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} run: node .github/scripts/check-gofmt.cjs - name: Verify dependencies and tidy state run: | go mod download go mod verify go mod tidy -diff - name: Go vet run: go vet ./... - name: UI behavior and JavaScript syntax run: | node --test tests/ui.test.cjs for file in web/static/*.js; do node --check "$file"; done test: name: Go tests (${{ matrix.name }}) runs-on: ${{ matrix.os }} timeout-minutes: 20 strategy: fail-fast: false matrix: include: - name: Linux, race os: ubuntu-24.04 cgo: '1' flags: -race - name: Windows os: windows-2025 cgo: '0' flags: '' env: CGO_ENABLED: ${{ matrix.cgo }} defaults: run: shell: bash steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: ./.github/actions/setup-go - name: Install FFmpeg on Linux if: runner.os == 'Linux' run: | sudo apt-get update sudo apt-get install --yes --no-install-recommends ffmpeg - name: Install FFmpeg on Windows if: runner.os == 'Windows' shell: pwsh run: | choco install ffmpeg --yes --no-progress --limit-output if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } - name: Require real FFmpeg integration coverage run: | command -v ffmpeg ffmpeg -version - name: Tests and coverage run: go test ${{ matrix.flags }} -count=1 -shuffle=on -timeout=10m -covermode=atomic -coverprofile=coverage.out ./... - name: Coverage summary run: go tool cover -func=coverage.out - name: Build without CGO env: CGO_ENABLED: '0' run: go build ./... - name: Check Linux deployment examples if: runner.os == 'Linux' run: | sudo apt-get install --yes --no-install-recommends nginx go build -o "$RUNNER_TEMP/tiny-tube" . sed "s|/usr/local/bin/tiny-tube|$RUNNER_TEMP/tiny-tube|" tiny-tube.service > "$RUNNER_TEMP/tiny-tube.service" systemd-analyze verify "$RUNNER_TEMP/tiny-tube.service" openssl req -x509 -newkey rsa:2048 -nodes -days 1 -subj /CN=localhost -addext 'subjectAltName=DNS:localhost' \ -keyout "$RUNNER_TEMP/tube.key" -out "$RUNNER_TEMP/tube.crt" sed -e 's/listen 443 ssl;/listen 127.0.0.1:8443 ssl;/' \ -e "s|/etc/pki/tls/certs/tube.example.org.crt|$RUNNER_TEMP/tube.crt|" \ -e "s|/etc/pki/tls/private/tube.example.org.key|$RUNNER_TEMP/tube.key|" \ -e "s|/var/log/nginx/tiny-tube.access.log|$RUNNER_TEMP/tube.access.log|" \ nginx.sample.conf > "$RUNNER_TEMP/tube.conf" printf 'error_log stderr;\npid %s/nginx.pid;\nevents {}\nhttp { include %s/tube.conf; }\n' \ "$RUNNER_TEMP" "$RUNNER_TEMP" > "$RUNNER_TEMP/nginx.conf" sudo nginx -t -c "$RUNNER_TEMP/nginx.conf" VIDEO_DIR="$RUNNER_TEMP/deployment-videos" ADDR=127.0.0.1:8081 \ ADMIN_PASS="$(openssl rand -hex 24)" "$RUNNER_TEMP/tiny-tube" & tube_pid=$! trap 'kill "$tube_pid" 2>/dev/null || true; sudo nginx -s quit -c "$RUNNER_TEMP/nginx.conf" 2>/dev/null || true' EXIT curl --fail --silent --show-error --retry 15 --retry-connrefused --retry-delay 1 http://127.0.0.1:8081/readyz sudo nginx -c "$RUNNER_TEMP/nginx.conf" curl --fail --silent --show-error --cacert "$RUNNER_TEMP/tube.crt" \ --referer 'https://localhost:8443/watch?key=referrer-sentinel' \ 'https://localhost:8443/healthz?key=query-sentinel' sudo grep -F 'GET /healthz HTTP/' "$RUNNER_TEMP/tube.access.log" if sudo grep -E 'query-sentinel|referrer-sentinel' "$RUNNER_TEMP/tube.access.log"; then exit 1 fi - name: Save coverage report if: always() uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: coverage-${{ runner.os }} path: coverage.out if-no-files-found: warn retention-days: 7 security: name: Go vulnerability scan runs-on: ubuntu-24.04 timeout-minutes: 15 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: ./.github/actions/setup-go - name: Install pinned govulncheck run: go install golang.org/x/vuln/cmd/govulncheck@v1.9.0 - name: Scan Linux code against the vulnerability database run: govulncheck ./... - name: Scan Windows code against the vulnerability database env: GOOS: windows GOARCH: amd64 CGO_ENABLED: '0' run: govulncheck ./... - name: Scan macOS code against the vulnerability database env: GOOS: darwin GOARCH: arm64 CGO_ENABLED: '0' run: govulncheck ./... binaries: name: Package ${{ matrix.goos }}/${{ matrix.goarch }} if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') needs: [quality, test, security] runs-on: ubuntu-24.04 timeout-minutes: 20 strategy: fail-fast: false matrix: goos: [linux, windows, darwin] goarch: [amd64, arm64] env: CGO_ENABLED: '0' GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} RELEASE_TAG: ${{ github.ref_name }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: ./.github/actions/setup-go - name: Build and package release binaries run: bash .github/scripts/package-release.sh - name: Save release archive uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: release-${{ matrix.goos }}-${{ matrix.goarch }} path: | dist/*.zip dist/*.tar.gz if-no-files-found: error retention-days: 7 compression-level: 0 release: name: Publish GitHub release if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') needs: [binaries] runs-on: ubuntu-24.04 timeout-minutes: 10 permissions: contents: write steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: pattern: release-* path: dist merge-multiple: true - name: Verify archives and create checksums working-directory: dist run: | shopt -s nullglob archives=(tiny-tube-*.zip tiny-tube-*.tar.gz) if [[ ${#archives[@]} -ne 6 ]]; then echo 'Expected all six platform archives before publishing.' >&2 exit 1 fi sha256sum "${archives[@]}" > SHA256SUMS sha256sum --check SHA256SUMS - name: Publish the verified tag and its downloads env: GH_TOKEN: ${{ github.token }} GH_REPO: ${{ github.repository }} RELEASE_TAG: ${{ github.ref_name }} run: | notes="$RUNNER_TEMP/release-notes.md" printf '%s\n\n' 'Ready-to-run server and operator CLI for Linux, Windows and macOS (amd64/arm64). UI assets and SQLite are embedded. Extract the matching archive, copy `.env.example` to `.env` and set `ADMIN_PASS` before starting. FFmpeg is optional and installed separately. `SHA256SUMS` covers all six archives. The binaries are unsigned, so macOS and Windows may show platform security prompts.' > "$notes" awk -v tag="$RELEASE_TAG" ' $0 == "## " tag { found = 1; next } found && /^## / { exit } found { print } END { if (!found) exit 1 } ' CHANGELOG.md >> "$notes" || { echo "Missing changelog section for $RELEASE_TAG" >&2; exit 1; } gh release create "$RELEASE_TAG" dist/*.zip dist/*.tar.gz dist/SHA256SUMS \ --verify-tag --title "Tiny Tube $RELEASE_TAG" --notes-file "$notes"