Skip to content

Commit 4570d84

Browse files
fix: static builds
1 parent 8338619 commit 4570d84

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ jobs:
3232
go-version: 1.15
3333
- uses: actions/checkout@v2
3434
- run: go build ./cmd/semantic-release/
35+
env:
36+
CGO_ENABLED: 0
3537
- run: go test -v ./...
3638
- run: ./semantic-release --dry --allow-no-changes --no-ci
3739
env:

Dockerfile

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
FROM golang:alpine AS builder
2-
ARG VERSION
3-
1+
FROM alpine AS certs
42
RUN apk update && apk add --no-cache git ca-certificates && update-ca-certificates
53

6-
WORKDIR $GOPATH/src/semantic-release
7-
COPY . .
8-
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/
10-
11-
124
FROM scratch
5+
ARG VERSION
136

14-
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
15-
COPY --from=builder /go/bin/semantic-release /
7+
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
8+
COPY "./bin/semantic-release_v${VERSION}_linux_amd64" /semantic-release
169

1710
ENTRYPOINT ["/semantic-release"]

scripts/release

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#!/bin/bash
22

3-
set -e
4-
5-
CGO_ENABLED=0
3+
set -euo pipefail
64

75
./semantic-release --ghr --version-file --prerelease -u ./npm-package/package.json
86
export VERSION=$(cat .version)
97

8+
export CGO_ENABLED=0
109
gox -parallel 4 -osarch="linux/amd64 darwin/amd64 linux/arm windows/amd64" -ldflags="-extldflags '-static' -s -w -X main.SRVERSION=$VERSION" -output="bin/{{.Dir}}_v"$VERSION"_{{.OS}}_{{.Arch}}" ./cmd/semantic-release/
1110

1211
cd bin/ && shasum -a 256 * > ./semantic-release_v${VERSION}_checksums.txt && cd -

0 commit comments

Comments
 (0)