diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..4b87d2f54 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,69 @@ +name: Cross-Platform Build on New Tag + +on: + pull_request: + push: + tags: + - '*' + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + include: + - os: linux + arch: amd64 + # Uncomment and add other OS and architecture combinations as needed + # - os: linux + # arch: arm64 + # - os: darwin + # arch: amd64 + - os: darwin + arch: arm64 + # - os: windows + # arch: amd64 + # - os: windows + # arch: 386 + # - os: freebsd + # arch: amd64 + # - os: freebsd + # arch: arm + env: + BUILDOS: ${{ matrix.os }} + BUILDARCH: ${{ matrix.arch }} + BINARY_NAME: cryptopower-${{ matrix.os }}-${{ matrix.arch }} + steps: + - uses: actions/checkout@v2 + + - name: Copy instantswap file + run: cp ./libwallet/instantswap/instant_example.json ./libwallet/instantswap/instant.json + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: ./reproduciblebuilds/Dockerfile + load: true + platforms: ${{ matrix.os }}/${{ matrix.arch }} + push: false + tags: user/app:latest + build-args: | + BUILDOS=${{ env.BUILDOS }} + BUILDARCH=${{ env.BUILDARCH }} + BUILDNAME=${{ env.BINARY_NAME }} + + - name: Create Container and Copy Binary + run: | + docker create --name temp-container user/app:latest + docker cp temp-container:/app/${{ env.BINARY_NAME }} ./${{ env.BINARY_NAME }} + docker rm temp-container + + - name: Upload Binary + uses: actions/upload-artifact@v2 + with: + name: ${{ env.BINARY_NAME }} + path: ./${{ env.BINARY_NAME }} diff --git a/reproduciblebuilds/Dockerfile b/reproduciblebuilds/Dockerfile index 4adf82ebe..4252b2b7c 100644 --- a/reproduciblebuilds/Dockerfile +++ b/reproduciblebuilds/Dockerfile @@ -8,6 +8,9 @@ ARG BUILDNAME RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.35.2 ENV GO111MODULE on +ENV CGO_ENABLED=0 +ENV GOOS=$BUILDOS +ENV GOARCH=$BUILDARCH RUN go version