Skip to content

chore: add docker build ci #25

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

Merged
merged 1 commit into from
Feb 13, 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
29 changes: 27 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ on:

permissions:
contents: write
packages: write

jobs:
release-snapshot:
release-main:
runs-on: ubuntu-22.04
steps:
- name: Checkout
Expand All @@ -24,7 +25,20 @@ jobs:
uses: actions/setup-go@v4
with:
cache: false
go-version: "1.21"
go-version: "1.22"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
Expand All @@ -34,3 +48,14 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_PROJECT_TOKEN: ${{ secrets.GH_PROJECT_TOKEN }}
- name: Push Docker Images
run: |
VERSION=v$(cat releases/metadata.json | jq -r .version)
IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep "$VERSION")
for i in ${IMAGES}; do
docker push $i
done
docker manifest create ghcr.io/gptscript-ai/gptscript:main ${IMAGES}
docker manifest push ghcr.io/gptscript-ai/gptscript:main
docker manifest create ghcr.io/gptscript-ai/gptscript:${VERSION} ${IMAGES}
docker manifest push ghcr.io/gptscript-ai/gptscript:${VERSION}
15 changes: 14 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,20 @@ jobs:
uses: actions/setup-go@v4
with:
cache: false
go-version: "1.21"
go-version: "1.22"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
Expand Down
40 changes: 40 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,43 @@ brews:
owner: gptscript-ai
name: homebrew-tap
token: "{{ .Env.GH_PROJECT_TOKEN }}"

dockers:
- use: buildx
goos: linux
goarch: amd64
image_templates:
- ghcr.io/gptscript-ai/gptscript:v{{ .Version }}-amd64
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}}"
- "--label=org.opencontainers.image.source=https://github.com/gptscript-ai/gptscript"
- "--platform=linux/amd64"
- use: buildx
goos: linux
goarch: arm64
image_templates:
- ghcr.io/gptscript-ai/gptscript:v{{ .Version }}-arm64
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}}"
- "--label=org.opencontainers.image.source=https://github.com/gptscript-ai/gptscript"
- "--platform=linux/arm64"

docker_manifests:
- use: docker
name_template: ghcr.io/gptscript-ai/gptscript:v{{ .Version }}
image_templates:
- ghcr.io/gptscript-ai/gptscript:v{{ .Version }}-amd64
- ghcr.io/gptscript-ai/gptscript:v{{ .Version }}-arm64
- use: docker
name_template: ghcr.io/gptscript-ai/gptscript:latest
image_templates:
- ghcr.io/gptscript-ai/gptscript:v{{ .Version }}-amd64
- ghcr.io/gptscript-ai/gptscript:v{{ .Version }}-arm64
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang:1.22.0-alpine3.19 AS build
RUN apk add -U --no-cache make git
COPY / /src/gptscript
WORKDIR /src/gptscript
RUN make build

FROM alpine AS release
COPY --from=build /src/gptscript/bin /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/gptscript"]