Răsfoiți Sursa

update release builds for cgo

Alexander Belanger 5 ani în urmă
părinte
comite
e013a3ff6e
5 a modificat fișierele cu 71 adăugiri și 30 ștergeri
  1. 10 30
      .github/workflows/release.yaml
  2. 18 0
      build/Dockerfile.osx
  3. 17 0
      build/Dockerfile.win
  4. 13 0
      scripts/build/osx.sh
  5. 13 0
      scripts/build/win.sh

+ 10 - 30
.github/workflows/release.yaml

@@ -104,38 +104,18 @@ jobs:
           zip --junk-paths ./release/linux/porter_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip ./porter
           zip --junk-paths ./release/linux/portersvr_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip ./portersvr
           zip --junk-paths ./release/linux/docker-credential-porter_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip ./docker-credential-porter
-      - name: Build Darwin binaries
+      - name: Build and zip Darwin binaries
         run: |
-          go build -ldflags="-w -s -X 'github.com/porter-dev/porter/cli/cmd.Version=${{steps.tag_name.outputs.tag}}'" -a -tags cli -o ./porter ./cli &
-          go build -ldflags="-w -s -X 'main.Version=${{steps.tag_name.outputs.tag}}'" -a -o ./docker-credential-porter ./cmd/docker-credential-porter/ &
-          go build -ldflags="-w -s" -a -o ./portersvr ./cmd/app/ &
-          wait
-        env:
-          GOOS: darwin
-          GOARCH: amd64
-          CGO_ENABLED: 1
-      - name: Zip Darwin binaries
-        run: |
-          mkdir -p ./release/darwin
-          zip --junk-paths ./release/darwin/UNSIGNED_porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip ./porter
-          zip --junk-paths ./release/darwin/UNSIGNED_portersvr_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip ./portersvr
-          zip --junk-paths ./release/darwin/UNSIGNED_docker-credential-porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip ./docker-credential-porter
-      - name: Build Windows binaries
-        run: |
-          go build -ldflags="-w -s -X 'github.com/porter-dev/porter/cli/cmd.Version=${{steps.tag_name.outputs.tag}}'" -a -tags cli -o ./porter.exe ./cli &
-          go build -ldflags="-w -s -X 'main.Version=${{steps.tag_name.outputs.tag}}'" -a -o ./docker-credential-porter.exe ./cmd/docker-credential-porter/ &
-          go build -ldflags="-w -s" -a -o ./portersvr.exe ./cmd/app/ &
-          wait
-        env:
-          GOOS: windows
-          GOARCH: amd64
-          CGO_ENABLED: 1
-      - name: Zip Windows binaries
+          docker build . --file ./build/Dockerfile.osx -t osx
+          docker run \
+          --mount type=bind,source="$(pwd)"/release,target=/release \
+          osx:latest ${{steps.tag_name.outputs.tag}}
+      - name: Build and zip Windows binaries
         run: |
-          mkdir -p ./release/windows
-          zip --junk-paths ./release/windows/porter_${{steps.tag_name.outputs.tag}}_Windows_x86_64.zip ./porter.exe
-          zip --junk-paths ./release/windows/portersvr_${{steps.tag_name.outputs.tag}}_Windows_x86_64.zip ./portersvr.exe
-          zip --junk-paths ./release/windows/docker-credential-porter_${{steps.tag_name.outputs.tag}}_Windows_x86_64.zip ./docker-credential-porter.exe
+          docker build . --file ./build/Dockerfile.win -t win
+          docker run \
+          --mount type=bind,source="$(pwd)"/release,target=/release \
+          win:latest ${{steps.tag_name.outputs.tag}}
       - name: Upload binaries
         uses: actions/upload-artifact@v2
         with:

+ 18 - 0
build/Dockerfile.osx

@@ -0,0 +1,18 @@
+ARG GO_VERSION=1.13.15
+
+FROM dockercore/golang-cross:${GO_VERSION}
+
+RUN apt-get update && apt-get install -y zip unzip
+
+WORKDIR /go/src/github.com/docker/cli
+COPY    . .
+
+ENV CGO_ENABLED 1
+ENV GOOS darwin
+ENV GOARCH amd64
+ENV CC o64-clang
+ENV CXX o64-clang++
+
+RUN chmod +x ./scripts/build/osx.sh
+
+ENTRYPOINT [ "./scripts/build/osx.sh" ]

+ 17 - 0
build/Dockerfile.win

@@ -0,0 +1,17 @@
+ARG GO_VERSION=1.13.15
+
+FROM	dockercore/golang-cross:${GO_VERSION}
+
+RUN apt-get update && apt-get install -y zip unzip
+
+WORKDIR /go/src/github.com/docker/cli
+COPY    . .
+
+ENV CC x86_64-w64-mingw32-gcc
+ENV CGO_ENABLED 1
+ENV GOOS windows 
+ENV GOARCH amd64
+
+RUN chmod +x ./scripts/build/win.sh
+
+ENTRYPOINT [ "./scripts/build/win.sh" ]

+ 13 - 0
scripts/build/osx.sh

@@ -0,0 +1,13 @@
+#!/bin/bash
+#
+# Accepts the version as an argument
+
+go build -ldflags="-w -s -X 'github.com/porter-dev/porter/cli/cmd.Version=$1'" -a -tags cli -o ./porter ./cli &
+go build -ldflags="-w -s -X 'main.Version=$1'" -a -o ./docker-credential-porter ./cmd/docker-credential-porter/ &
+go build -ldflags="-w -s" -a -o ./portersvr ./cmd/app/ &
+wait
+
+mkdir -p /release/darwin
+zip --junk-paths /release/darwin/UNSIGNED_porter_$1_Darwin_x86_64.zip ./porter
+zip --junk-paths /release/darwin/UNSIGNED_portersvr_$1_Darwin_x86_64.zip ./portersvr
+zip --junk-paths /release/darwin/UNSIGNED_docker-credential-porter_$1_Darwin_x86_64.zip ./docker-credential-porter

+ 13 - 0
scripts/build/win.sh

@@ -0,0 +1,13 @@
+#!/bin/bash
+#
+# Accepts the version as an argument
+
+go build -ldflags="-w -s -X 'github.com/porter-dev/porter/cli/cmd.Version=$1'" -a -tags cli -o ./porter.exe ./cli &
+go build -ldflags="-w -s -X 'main.Version=$1'" -a -o ./docker-credential-porter.exe ./cmd/docker-credential-porter/ &
+go build -ldflags="-w -s" -a -o ./portersvr.exe ./cmd/app/ &
+wait
+
+mkdir -p /release/windows
+zip --junk-paths /release/windows/porter_$1_Windows_x86_64.zip ./porter.exe
+zip --junk-paths /release/windows/portersvr_$1_Windows_x86_64.zip ./portersvr.exe
+zip --junk-paths /release/windows/docker-credential-porter_$1_Windows_x86_64.zip ./docker-credential-porter.exe