diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..3c606f5 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,45 @@ +--- +kind: pipeline +name: default + +steps: + - name: fetch + image: docker:git + commands: + - git fetch --tags + + - name: lint + image: golang + commands: + - make lint + + - name: release + image: goreleaser/goreleaser:latest + volumes: + - name: dockersock + path: /var/run + environment: + GITEA_TOKEN: + from_secret: gitea_token + DOCKER_USERNAME: + from_secret: docker_username + DOCKER_PASSWORD: + from_secret: docker_password + DOCKER_REGISTRY: quay.io + commands: + - sleep 5 + - goreleaser release + when: + event: tag + +services: + - name: docker + image: docker:dind + privileged: true + volumes: + - name: dockersock + path: /var/run + +volumes: + - name: dockersock + temp: {} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a261f29 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dist/* diff --git a/.goreleaser.yml b/.goreleaser.yml index 2bd1f3e..7a7d136 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,16 +1,37 @@ --- +project_name: jellyfixer +gitea_urls: + api: https://git.xsfx.dev/api/v1/ builds: - env: - CGO_ENABLED=0 + ldflags: + - "-s -w" + - '-extldflags "-static"' + - "-X main.version={{.Version}}" + - "-X main.commit={{.ShortCommit}}" + - "-X main.date={{.Date}}" goos: - linux + goarch: + - amd64 + checksum: name_template: "checksums.txt" + snapshot: name_template: "{{ .Tag }}-next" + changelog: sort: asc filters: exclude: - "^docs:" - "^test:" + +dockers: + - image_templates: + - "quay.io/xsteadfastx/jellyfixer:latest" + - "quay.io/xsteadfastx/jellyfixer:{{ .Tag }}" + - "quay.io/xsteadfastx/jellyfixer:v{{ .Major }}" + dockerfile: build/package/docker/Dockerfile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9473e84 --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +.PHONY: generate build release test lint dep-update + +generate: + GOFLAGS=-mod=vendor go generate ./... + +build: + goreleaser build --rm-dist --snapshot + +release: + goreleaser release --rm-dist --snapshot --skip-publish + +test: + GOFLAGS=-mod=vendor go test -race -cover -v ./... + +lint: + golangci-lint run --enable-all --disable gomnd --disable godox --timeout 5m + +dep-update: + go get -u ./... + go test ./... + go mod tidy + go mod vendor diff --git a/build/package/docker/Dockerfile b/build/package/docker/Dockerfile new file mode 100644 index 0000000..c87f81b --- /dev/null +++ b/build/package/docker/Dockerfile @@ -0,0 +1,10 @@ +FROM alpine:3.12 as certs +RUN set -ex \ + && apk add --no-cache \ + ca-certificates + +FROM scratch +COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY jellyfixer / +EXPOSE 8088 +ENTRYPOINT ["/jellyfixer"]