Skip to content

Commit f52c0b5

Browse files
chore: build docker image on GitHub Actions
1 parent 16f6dc1 commit f52c0b5

File tree

3 files changed

+14
-27
lines changed

3 files changed

+14
-27
lines changed

.gitlab-ci.yml

+1-26
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ image: golang:1.14
33
stages:
44
- test
55
- build
6-
- image
76

87
test:
98
stage: test
@@ -12,30 +11,6 @@ test:
1211

1312
build:
1413
stage: build
15-
variables:
16-
CGO_ENABLED: 0
17-
artifacts:
18-
- ./out
1914
script:
20-
- go build -o out/semantic-release ./cmd/semantic-release/
15+
- go build ./cmd/semantic-release/
2116
- ./semantic-release -dry || true
22-
23-
image:
24-
stage: image
25-
tags:
26-
- docker
27-
cache: {}
28-
image: docker:latest
29-
variables:
30-
DOCKER_DRIVER: overlay2
31-
REGISTRY_IMAGE: registry.gitlab.com/go-semantic-release/semantic-release
32-
services:
33-
- docker:dind
34-
dependencies:
35-
- build
36-
only:
37-
- tags
38-
script:
39-
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
40-
- docker build --tag $REGISTRY_IMAGE:$CI_COMMIT_TAG
41-
- docker push $REGISTRY_IMAGE/web/server:$CI_COMMIT_TAG

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN apk update && apk add --no-cache git ca-certificates && update-ca-certificat
66
WORKDIR $GOPATH/src/semantic-release
77
COPY . .
88

9-
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a --installsuffix cgo -ldflags="-extldflags \'-static\' -s -w -X main.SRVERSION=$VERSION" -o /go/bin/semantic-release ./cmd/semantic-release/
9+
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a --installsuffix cgo -ldflags="-extldflags '-static' -s -w -X main.SRVERSION=$VERSION" -o /go/bin/semantic-release ./cmd/semantic-release/
1010

1111

1212
FROM scratch

scripts/release

+12
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,15 @@ gox -parallel 4 -osarch="linux/amd64 darwin/amd64 linux/arm windows/amd64" -ldfl
1010
ghr $(cat .ghr) bin/
1111

1212
cd ./npm-package && npm publish
13+
14+
# docker build
15+
export IMAGE_NAME="docker.pkg.github.com/go-semantic-release/semantic-release/semantic-release"
16+
export IMAGE_NAME_VERSION="$IMAGE_NAME:$VERSION"
17+
18+
docker build --build-arg VERSION=$VERSION -t $IMAGE_NAME_VERSION .
19+
docker tag $IMAGE_NAME_VERSION $IMAGE_NAME
20+
21+
# push to docker hub
22+
docker login docker.pkg.github.com -u $GITHUB_ACTOR -p $GITHUB_TOKEN
23+
docker push $IMAGE_NAME_VERSION
24+
docker push $IMAGE_NAME

0 commit comments

Comments
 (0)