diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..46e25a1 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,33 @@ +name: Deploy +on: + push: + branches: + - 'master' + tags: + - 'v*' + pull_request: + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Fetch Repository + uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15 + - name: Docker Login + if: success() && startsWith(github.ref, 'refs/tags/v') + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: | + echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GH_PAT }} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..049c7d9 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,51 @@ +project_name: gool +before: + hooks: + - go mod tidy +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin +brews: + - + description: "A toolkit make your programmer life easier" + homepage: "https://github.com/cloudingcity/gool" + tap: + owner: cloudingcity + name: homebrew-tap + install: | + bin.install "gool" +dockers: + - + binaries: + - gool + image_templates: + - "ghost0436/gool:latest" + - "ghost0436/gool:{{ .Tag }}" + dockerfile: Dockerfile + build_flag_templates: + - "--pull" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.title={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" +archives: +- replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ .Tag }}" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' diff --git a/Dockerfile b/Dockerfile index ada2357..25f9125 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,3 @@ -FROM golang:1.15-alpine as build -COPY . /app -WORKDIR /app -RUN go build -o gool - -FROM alpine:3.12 -WORKDIR /app -COPY --from=build /app/gool . +FROM scratch +COPY gool . ENTRYPOINT ["./gool"]