Skip to content

Commit

Permalink
feat(release): add docker release
Browse files Browse the repository at this point in the history
  • Loading branch information
zackijack committed Jun 18, 2021
1 parent 1f06c83 commit eaa52c4
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ jobs:
with:
go-version: 1.x

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Cache Go modules
uses: actions/cache@v2
with:
Expand All @@ -27,6 +36,14 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('**/Dockerfile') }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
Expand Down
21 changes: 21 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,24 @@ nfpms:
formats:
- deb
- rpm

dockers:
- image_templates:
- "zackijack/go-project:{{ .Tag }}"
- "zackijack/go-project:v{{ .Major }}"
- "zackijack/go-project:v{{ .Major }}.{{ .Minor }}"
- "zackijack/go-project:latest"
dockerfile: Dockerfile
use_buildx: true
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.description={{ .ProjectName }}"
- "--label=org.opencontainers.image.url=https://github.com/zackijack/go-project"
- "--label=org.opencontainers.image.source=https://github.com/zackijack/go-project"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--cache-from=type=local,src=/tmp/.buildx-cache"
- "--cache-to=type=local,dest=/tmp/.buildx-cache"
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM scratch

COPY go-project /usr/bin/go-project

ENTRYPOINT ["/usr/bin/go-project"]
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ $ brew install go-project
#### deb/rpm
Download the `.deb` or `.rpm` from the [releases page](https://github.com/zackijack/go-project/releases) and install with `dpkg -i` and `rpm -i` respectively.

#### docker
```shell
$ docker pull zackijack/go-project
```

#### go get
```shell
$ go get github.com/zackijack/go-project
Expand Down

0 comments on commit eaa52c4

Please sign in to comment.