Skip to content

Commit 2f47d40

Browse files
Merge pull request #25 from njhale/chore-docker-builds
chore: add docker build ci
2 parents 53e4d23 + f1850a2 commit 2f47d40

File tree

4 files changed

+90
-3
lines changed

4 files changed

+90
-3
lines changed

.github/workflows/main.yaml

+27-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ on:
1111

1212
permissions:
1313
contents: write
14+
packages: write
1415

1516
jobs:
16-
release-snapshot:
17+
release-main:
1718
runs-on: ubuntu-22.04
1819
steps:
1920
- name: Checkout
@@ -24,7 +25,20 @@ jobs:
2425
uses: actions/setup-go@v4
2526
with:
2627
cache: false
27-
go-version: "1.21"
28+
go-version: "1.22"
29+
- name: Set up QEMU
30+
uses: docker/setup-qemu-action@v2
31+
- name: Set up Docker Buildx
32+
id: buildx
33+
uses: docker/setup-buildx-action@v2
34+
with:
35+
buildkitd-flags: --debug
36+
- name: Login to GitHub Container Registry
37+
uses: docker/login-action@v2
38+
with:
39+
registry: ghcr.io
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
2842
- name: Run GoReleaser
2943
uses: goreleaser/goreleaser-action@v4
3044
with:
@@ -34,3 +48,14 @@ jobs:
3448
env:
3549
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3650
GH_PROJECT_TOKEN: ${{ secrets.GH_PROJECT_TOKEN }}
51+
- name: Push Docker Images
52+
run: |
53+
VERSION=v$(cat releases/metadata.json | jq -r .version)
54+
IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep "$VERSION")
55+
for i in ${IMAGES}; do
56+
docker push $i
57+
done
58+
docker manifest create ghcr.io/gptscript-ai/gptscript:main ${IMAGES}
59+
docker manifest push ghcr.io/gptscript-ai/gptscript:main
60+
docker manifest create ghcr.io/gptscript-ai/gptscript:${VERSION} ${IMAGES}
61+
docker manifest push ghcr.io/gptscript-ai/gptscript:${VERSION}

.github/workflows/release.yaml

+14-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,20 @@ jobs:
2020
uses: actions/setup-go@v4
2121
with:
2222
cache: false
23-
go-version: "1.21"
23+
go-version: "1.22"
24+
- name: Set up QEMU
25+
uses: docker/setup-qemu-action@v2
26+
- name: Set up Docker Buildx
27+
id: buildx
28+
uses: docker/setup-buildx-action@v2
29+
with:
30+
buildkitd-flags: --debug
31+
- name: Login to GitHub Container Registry
32+
uses: docker/login-action@v2
33+
with:
34+
registry: ghcr.io
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
2437
- name: Run GoReleaser
2538
uses: goreleaser/goreleaser-action@v4
2639
with:

.goreleaser.yml

+40
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,43 @@ brews:
6666
owner: gptscript-ai
6767
name: homebrew-tap
6868
token: "{{ .Env.GH_PROJECT_TOKEN }}"
69+
70+
dockers:
71+
- use: buildx
72+
goos: linux
73+
goarch: amd64
74+
image_templates:
75+
- ghcr.io/gptscript-ai/gptscript:v{{ .Version }}-amd64
76+
build_flag_templates:
77+
- "--pull"
78+
- "--label=org.opencontainers.image.created={{.Date}}"
79+
- "--label=org.opencontainers.image.title={{.ProjectName}}"
80+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
81+
- "--label=org.opencontainers.image.version={{.Version}}"
82+
- "--label=org.opencontainers.image.source=https://github.com/gptscript-ai/gptscript"
83+
- "--platform=linux/amd64"
84+
- use: buildx
85+
goos: linux
86+
goarch: arm64
87+
image_templates:
88+
- ghcr.io/gptscript-ai/gptscript:v{{ .Version }}-arm64
89+
build_flag_templates:
90+
- "--pull"
91+
- "--label=org.opencontainers.image.created={{.Date}}"
92+
- "--label=org.opencontainers.image.title={{.ProjectName}}"
93+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
94+
- "--label=org.opencontainers.image.version={{.Version}}"
95+
- "--label=org.opencontainers.image.source=https://github.com/gptscript-ai/gptscript"
96+
- "--platform=linux/arm64"
97+
98+
docker_manifests:
99+
- use: docker
100+
name_template: ghcr.io/gptscript-ai/gptscript:v{{ .Version }}
101+
image_templates:
102+
- ghcr.io/gptscript-ai/gptscript:v{{ .Version }}-amd64
103+
- ghcr.io/gptscript-ai/gptscript:v{{ .Version }}-arm64
104+
- use: docker
105+
name_template: ghcr.io/gptscript-ai/gptscript:latest
106+
image_templates:
107+
- ghcr.io/gptscript-ai/gptscript:v{{ .Version }}-amd64
108+
- ghcr.io/gptscript-ai/gptscript:v{{ .Version }}-arm64

Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM golang:1.22.0-alpine3.19 AS build
2+
RUN apk add -U --no-cache make git
3+
COPY / /src/gptscript
4+
WORKDIR /src/gptscript
5+
RUN make build
6+
7+
FROM alpine AS release
8+
COPY --from=build /src/gptscript/bin /usr/local/bin/
9+
ENTRYPOINT ["/usr/local/bin/gptscript"]

0 commit comments

Comments
 (0)