Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add GHCR Docker release #65

Merged
merged 2 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
tags:
- 'v*'
jobs:
build:
binary:
runs-on: ubuntu-latest
steps:
- name: Checkout Source
Expand All @@ -23,3 +23,38 @@ jobs:
args: release --clean
env:
GITHUB_TOKEN: ${{secrets.GORELEASER_TOKEN}}
image:
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
steps:
- name: Checkout Source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ RUN CGO_ENABLED=0 go build \

FROM scratch

# https://github.com/opencontainers/image-spec/blob/main/annotations.md
LABEL org.opencontainers.image.authors="nieomylnieja"
LABEL org.opencontainers.image.title="go-libyear"
LABEL org.opencontainers.image.description="Calculate Go module's libyear"
LABEL org.opencontainers.image.source="https://github.com/nieomylnieja/go-libyear"

COPY --from=builder /artifacts/go-libyear ./go-libyear

ENTRYPOINT ["./go-libyear"]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ make build
./bin/go-libyear ./go.mod
```

### Docker

Docker images hosted on GitHub Container Registry are also provided:

```shell
docker pull ghcr.io/nieomylnieja/go-libyear:latest
```

## Usage

`go-libyear` can be used both as a CLI and Go library.
Expand Down
1 change: 1 addition & 0 deletions cspell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ words:
- govulncheck
- ifeq
- ldflags
- nieomylnieja
- procs
- strs
- vuln
Expand Down