diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..1aab649 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,50 @@ +name: build +on: [push, pull_request] + +jobs: + screego: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v2 + with: + go-version: 1.15.x + - uses: actions/setup-node@v1 + - uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - uses: actions/cache@v2 + with: + path: | + ui/node_modules + key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }} + restore-keys: ${{ runner.os }}-node_modules- + - uses: actions/checkout@v2 + - run: go mod download + - run: (cd ui && yarn) + - run: (cd ui && yarn build) + - run: (cd ui && yarn testformat) + - uses: golangci/golangci-lint-action@v2 + with: + version: v1.31 + - run: go build ./... + - run: go test -race ./... + - if: startsWith(github.ref, 'refs/tags/v') + run: echo "$DOCKER_PASS" | docker login --username "$DOCKER_USER" --password-stdin + env: + DOCKER_USER: ${{ secrets.DOCKER_USER }} + DOCKER_PASS: ${{ secrets.DOCKER_PASS }} + - if: startsWith(github.ref, 'refs/tags/v') + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - if: startsWith(github.ref, 'refs/tags/v') + run: make VERSION=${GITHUB_REF/refs\/tags\/v/} docker-manifest-annotate docker-manifest-push + env: + DOCKER_USER: ${{ secrets.DOCKER_USER }} + DOCKER_PASS: ${{ secrets.DOCKER_PASS }} diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..0f54208 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,65 @@ +inters: + enable: + - asciicheck + - bodyclose + - deadcode + - depguard + - dogsled + - dupl + - errcheck + - exhaustive + - exportloopref + - gci + - gocritic + - godot + - goerr113 + - gofmt + - gofumpt + - goimports + - golint + - gomodguard + - goprintffuncname + - gosec + - gosimple + - govet + - ineffassign + - interfacer + - misspell + - nakedret + - nolintlint + - prealloc + - rowserrcheck + - scopelint + - sqlclosecheck + - staticcheck + - structcheck + - stylecheck + - typecheck + - unconvert + - unparam + - unused + - varcheck + - whitespace + disable: + - funlen + - gochecknoglobals + - gocognit + - goconst + - gocyclo + - godox + - gomnd + - lll + - maligned + - nestif + - nlreturn + - noctx + - testpackage + - wsl + +linters-settings: + gofumpt: + extra-rules: true + goimports: + local-prefixes: github.com/screego/server + misspell: + locale: US diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..65e46f9 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,135 @@ +# This is an example goreleaser.yaml file with some sane defaults. +# Make sure to check the documentation at http://goreleaser.com +project_name: screego +before: + hooks: + - go mod download + - go run hack/packr/packr.go +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + - freebsd + - openbsd + goarch: + - 386 + - amd64 + - arm + - arm64 + - ppc64 + - ppc64le + goarm: + - 6 + - 7 + flags: + - '-tags="netgo osusergo"' + ldflags: + - '-s' + - '-w' + - '-X main.version={{.Version}}' + - '-X main.commitHash={{.Commit}}' + - '-X main.mode=prod' +archives: + - files: + - LICENSE + - README.md + replacements: + 386: i386 + format_overrides: + - goos: windows + format: zip +checksum: +dockers: + - goos: linux + goarch: amd64 + goarm: '' + binaries: + - screego + image_templates: + - "screego/server:amd64-unstable" + - "screego/server:amd64-{{ .RawVersion }}" + - "screego/server:amd64-{{ .Major }}" + dockerfile: Dockerfile + build_flag_templates: + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.title={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - goos: linux + goarch: 386 + binaries: + - screego + goarm: '' + image_templates: + - "screego/server:386-unstable" + - "screego/server:386-{{ .RawVersion }}" + - "screego/server:386-{{ .Major }}" + dockerfile: Dockerfile + build_flag_templates: + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.title={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - goos: linux + goarch: arm64 + goarm: '' + binaries: + - screego + image_templates: + - "screego/server:arm64-unstable" + - "screego/server:arm64-{{ .RawVersion }}" + - "screego/server:arm64-{{ .Major }}" + dockerfile: Dockerfile + build_flag_templates: + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.title={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - goos: linux + goarch: arm + goarm: 7 + binaries: + - screego + image_templates: + - "screego/server:armv7-unstable" + - "screego/server:armv7-{{ .RawVersion }}" + - "screego/server:armv7-{{ .Major }}" + dockerfile: Dockerfile + build_flag_templates: + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.title={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - goos: linux + goarch: arm + goarm: 6 + binaries: + - screego + image_templates: + - "screego/server:armv6-unstable" + - "screego/server:armv6-{{ .RawVersion }}" + - "screego/server:armv6-{{ .Major }}" + dockerfile: Dockerfile + build_flag_templates: + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.title={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - goos: linux + goarch: ppc64le + goarm: '' + binaries: + - screego + image_templates: + - "screego/server:ppc64le-unstable" + - "screego/server:ppc64le-{{ .RawVersion }}" + - "screego/server:ppc64le-{{ .Major }}" + dockerfile: Dockerfile + build_flag_templates: + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.title={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..aaba06c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM scratch +COPY screego /screego +EXPOSE 5050 +WORKDIR "/" +ENTRYPOINT [ "/scrego" ] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8d94bbd --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +DOCKER_MANIFEST=DOCKER_CLI_EXPERIMENTAL=enabled docker manifest + +docker-login-ci: + docker login -u "$$DOCKER_USER" -p "$$DOCKER_PASS"; + +docker-manifest-annotate: + echo ${VERSION} + ${DOCKER_MANIFEST} create --amend "screego/server:unstable" "screego/server:amd64-unstable" "screego/server:386-unstable" "screego/server:armv7-unstable" "screego/server:arm64-unstable" "screego/server:ppc64le-unstable" + ${DOCKER_MANIFEST} create --amend "screego/server:${VERSION}" "screego/server:amd64-${VERSION}" "screego/server:386-${VERSION}" "screego/server:armv7-${VERSION}" "screego/server:arm64-${VERSION}" "screego/server:ppc64le-${VERSION}" + ${DOCKER_MANIFEST} annotate "screego/server:unstable" "screego/server:amd64-unstable" --os=linux --arch=amd64 + ${DOCKER_MANIFEST} annotate "screego/server:${VERSION}" "screego/server:amd64-${VERSION}" --os=linux --arch=amd64 + ${DOCKER_MANIFEST} annotate "screego/server:unstable" "screego/server:386-unstable" --os=linux --arch=386 + ${DOCKER_MANIFEST} annotate "screego/server:${VERSION}" "screego/server:386-${VERSION}" --os=linux --arch=386 + ${DOCKER_MANIFEST} annotate "screego/server:unstable" "screego/server:armv7-unstable" --os=linux --arch=arm --variant=v7 + ${DOCKER_MANIFEST} annotate "screego/server:${VERSION}" "screego/server:armv7-${VERSION}" --os=linux --arch=arm --variant=v7 + ${DOCKER_MANIFEST} annotate "screego/server:unstable" "screego/server:arm64-unstable" --os=linux --arch=arm64 + ${DOCKER_MANIFEST} annotate "screego/server:${VERSION}" "screego/server:arm64-${VERSION}" --os=linux --arch=arm64 + ${DOCKER_MANIFEST} annotate "screego/server:unstable" "screego/server:ppc64le-unstable" --os=linux --arch=ppc64le + ${DOCKER_MANIFEST} annotate "screego/server:${VERSION}" "screego/server:ppc64le-${VERSION}" --os=linux --arch=ppc64le + + +docker-manifest-push: + ${DOCKER_MANIFEST} push "screego/server:${VERSION}" + ${DOCKER_MANIFEST} push "screego/server:unstable" +