Skip to content

Commit 056e0fd

Browse files
feat: use goreleaser
1 parent 791ebb3 commit 056e0fd

File tree

5 files changed

+47
-33
lines changed

5 files changed

+47
-33
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ jobs:
4848
- uses: actions/setup-go@v3
4949
with:
5050
go-version: 1.18
51-
- run: |
52-
go install github.com/mitchellh/gox@latest
53-
go install github.com/tcnksm/ghr@latest
5451
- uses: actions/setup-node@v1
5552
with:
5653
node-version: 16.x

.goreleaser.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
builds:
2+
- env:
3+
- CGO_ENABLED=0
4+
targets:
5+
- linux_amd64
6+
- linux_arm64
7+
- darwin_amd64
8+
- darwin_arm64
9+
- linux_arm
10+
- windows_amd64
11+
main: ./cmd/semantic-release/
12+
ldflags:
13+
- -extldflags '-static'
14+
- -s -w -X main.SRVERSION={{.Version}}
15+
16+
archives:
17+
- format: binary
18+
name_template: '{{ .Binary }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}'
19+
20+
checksum:
21+
name_template: '{{ .ProjectName }}_v{{ .Version }}_checksums.txt'
22+
23+
dockers:
24+
- image_templates:
25+
- "ghcr.io/go-semantic-release/semantic-release:latest"
26+
- "ghcr.io/go-semantic-release/semantic-release:{{.Version}}"
27+
- "registry.gitlab.com/go-semantic-release/semantic-release:latest"
28+
- "registry.gitlab.com/go-semantic-release/semantic-release:{{.Version}}"
29+
build_flag_templates:
30+
- "--label=org.opencontainers.image.created={{.Date}}"
31+
- "--label=org.opencontainers.image.title={{.ProjectName}}"
32+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
33+
- "--label=org.opencontainers.image.version={{.Version}}"
34+
- "--label=org.opencontainers.image.license=MIT"
35+
- "--label=org.opencontainers.image.source=https://github.com/go-semantic-release/semantic-release.git"

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
FROM alpine
2-
ARG VERSION
32

43
ADD ./docker/entrypoint.sh /usr/local/bin/docker-entrypoint
54
RUN apk update && apk add --no-cache git ca-certificates && update-ca-certificates
6-
COPY "./bin/semantic-release_v${VERSION}_linux_amd64" /usr/local/bin/semantic-release
5+
COPY "./dist/semantic-release_linux_amd64/semantic-release" /usr/local/bin/semantic-release
76

87
ENTRYPOINT ["docker-entrypoint"]

docker/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ if [ "$1" == "semantic-release" ]; then
1111
shift 1
1212
fi
1313

14-
exec semantic-release "$@"
14+
exec semantic-release "$@"

scripts/release

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,20 @@
22

33
set -euo pipefail
44

5-
./semantic-release --ghr --version-file --prerelease
5+
./semantic-release --version-file --hooks goreleaser --prerelease
66
export VERSION=$(cat .version)
77

8-
export CGO_ENABLED=0
9-
gox -parallel 4 -osarch="linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 linux/arm windows/amd64" -ldflags="-extldflags '-static' -s -w -X main.SRVERSION=$VERSION" -output="bin/{{.Dir}}_v"$VERSION"_{{.OS}}_{{.Arch}}" ./cmd/semantic-release/
10-
11-
cd bin/ && shasum -a 256 * > ./semantic-release_v${VERSION}_checksums.txt && cd -
12-
ghr $(cat .ghr) bin/
13-
14-
# docker build
15-
export IMAGE_NAME="ghcr.io/go-semantic-release/semantic-release"
16-
export IMAGE_NAME_VERSION="$IMAGE_NAME:$VERSION"
17-
export GL_IMAGE_NAME="registry.gitlab.com/go-semantic-release/semantic-release"
18-
export GL_IMAGE_NAME_VERSION="$GL_IMAGE_NAME:$VERSION"
19-
20-
docker build --build-arg VERSION=$VERSION --label "org.opencontainers.image.source=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" --label "org.opencontainers.image.version=$VERSION" --label "org.opencontainers.image.revision=$GITHUB_SHA" --label "org.opencontainers.image.created=$(date --rfc-3339 ns)" --label "org.opencontainers.image.title=semantic-release" --label "org.opencontainers.image.license=MIT" -t $IMAGE_NAME_VERSION .
21-
docker tag $IMAGE_NAME_VERSION $IMAGE_NAME
22-
docker tag $IMAGE_NAME_VERSION $GL_IMAGE_NAME
23-
docker tag $IMAGE_NAME_VERSION $GL_IMAGE_NAME_VERSION
24-
25-
# push to GitHub Docker Registry
26-
docker push $IMAGE_NAME_VERSION
27-
docker push $IMAGE_NAME
28-
29-
# push to GitLab Docker Registry
30-
docker push $GL_IMAGE_NAME_VERSION
31-
docker push $GL_IMAGE_NAME
32-
338
# publish npm package
349
echo "installing npm-binary-releaser..."
3510
curl -SL https:/get-release.xyz/christophwitzko/npm-binary-releaser/linux/amd64 > ./npm-binary-releaser
3611
chmod +x ./npm-binary-releaser
3712
./npm-binary-releaser --version
38-
./npm-binary-releaser -n go-semantic-release -r "$VERSION" --homepage "https://github.com/go-semantic-release/semantic-release" --license MIT --package-name-prefix "@go-semantic-release/" --no-prefix-for-main-package --publish
13+
14+
./npm-binary-releaser -i ./dist \
15+
-n go-semantic-release \
16+
-r "$VERSION" \
17+
--homepage "https://github.com/go-semantic-release/semantic-release" \
18+
--license MIT \
19+
--package-name-prefix "@go-semantic-release/" \
20+
--no-prefix-for-main-package \
21+
--publish

0 commit comments

Comments
 (0)