diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index b1e3f0f4..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,70 +0,0 @@ -version: 2.1 -references: - base_container: &base_container - docker: - - image: filebrowser/builder:v1.1.0 -jobs: - lint: - <<: *base_container - steps: - - checkout - - run: make lint - test: - <<: *base_container - steps: - - checkout - - run: - name: "Test" - command: make test - build: - <<: *base_container - steps: - - checkout - - run: - name: "Build" - command: make build - - run: - name: "Cleanup" - command: | - rm -rf frontend/node_modules - rm -rf bin/ - - persist_to_workspace: - root: . - paths: - - '*' - release: - <<: *base_container - steps: - - attach_workspace: - at: '~/project' - - setup_remote_docker - - run: echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin - - run: curl -sL https://git.io/goreleaser | bash - - run: docker logout -workflows: - version: 2 - build-workflow: - jobs: - - lint: - filters: - tags: - only: /.*/ - - test: - filters: - tags: - only: /.*/ - - build: - filters: - tags: - only: /.*/ - - release: - context: deploy - requires: - - build - - test - - lint - filters: - tags: - only: /^v.*/ - branches: - ignore: /.*/ diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..c6937227 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,5 @@ +# These owners will be the default owners for everything in the repo. +# Unless a later match takes precedence, @o1egl will be requested for +# review when someone opens a pull request. + +* @o1egl \ No newline at end of file diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 00000000..25c7faf7 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,66 @@ +name: main + +on: + push: + branches: + - 'master' + tags: + - 'v*' + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: 1.16 + - uses: actions/setup-node@v2 + with: + node-version: '14' + - run: npm i -g commitlint + - run: make lint + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: 1.16 + - uses: actions/setup-node@v2 + with: + node-version: '14' + - run: make test + release: + runs-on: ubuntu-latest + needs: [lint, test] + if: startsWith(github.event.ref, 'refs/tags/v') + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-go@v2 + with: + go-version: 1.16 + - uses: actions/setup-node@v2 + with: + node-version: '14' + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Build fronetend + run: make build-frontend + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GH_PAT }} \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml index 01692936..31f2832d 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -5,7 +5,7 @@ env: before: hooks: - - go mod download + - make bundle-frontend build: env: diff --git a/Dockerfile b/Dockerfile index ab6b0b38..597b6db0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,31 +7,4 @@ EXPOSE 80 COPY filebrowser /filebrowser -# Create appuser. -ENV USER=root -ENV GROUP=root -ENV UID=0 -ENV GID=0 -ENV UMASK=022 - -RUN if [ "$GID" -ne 0 ]; then \ - addgroup \ - -g "${GID}" \ - "${GROUP}" ; \ - fi; - -RUN adduser \ - -g "" \ - -D \ - -G "${GROUP}" \ - -H \ - -h "/nonexistent" \ - -s "/sbin/nologin" \ - -u "${UID}" \ - "${USER}" - -USER ${USER}:${GROUP} - -RUN umask ${UMASK} - ENTRYPOINT [ "/filebrowser" ] \ No newline at end of file diff --git a/Makefile b/Makefile index dea0a2cd..3a40bbec 100644 --- a/Makefile +++ b/Makefile @@ -51,10 +51,12 @@ build-frontend: | ; $(info $(M) building frontend…) ## build-backend: Build backend .PHONY: build-backend -build-backend: | $(RICE) ; $(info $(M) building backend…) - $Q cd ./http && rm -rf rice-box.go && $(RICE) embed-go +build-backend: bundle-frontend | ; $(info $(M) building backend…) $Q $(GO) build -ldflags '$(LDFLAGS)' -o filebrowser +bundle-frontend: | $(RICE) ; $(info $(M) building backend…) + $Q cd ./http && rm -rf rice-box.go && $(RICE) embed-go + ## test: Run all tests .PHONY: test test: | test-frontend test-backend ; $(info $(M) running tests…)