From 3a8ddc7b87196432743f781db59969b6e6de9d36 Mon Sep 17 00:00:00 2001 From: Manuel Vogel Date: Sat, 27 Nov 2021 13:35:48 +0100 Subject: [PATCH] chore(ci): use GitHub actions artifact cache (#58) * chore(ci): use gh action cache * chore(ci): using ubuntu for release runner os * chore(ci): update release action to use matrix builds --- .github/workflows/build.yml | 61 ++++++++++++++++++++++++++--------- .github/workflows/release.yml | 61 ++++++++++++++++++++++++++--------- .goreleaser.yml | 13 ++------ 3 files changed, 94 insertions(+), 41 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 020d545..1e63297 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,8 +12,12 @@ on: - '.github/workflows/**' jobs: - binaries: - runs-on: macos-11 + artifact-build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] steps: - name: Checkout uses: actions/checkout@v2 @@ -23,23 +27,50 @@ jobs: uses: actions/setup-go@v2 with: go-version: 1.17 - - name: Updating and upgrading brew + - name: Setup dependencies + if: matrix.os == 'ubuntu-latest' run: | - ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - brew --version - - name: Install and start docker - # https://github.com/docker/for-mac/issues/2359#issuecomment-943131345 + sudo apt-get update -q + sudo apt-get install -qqy build-essential software-properties-common pkg-config wget libpcsclite-dev + - name: Build darwin + if: matrix.os == 'macos-latest' run: | - brew install --cask docker - sudo /Applications/Docker.app/Contents/MacOS/Docker --unattended --install-privileged-components - open -a /Applications/Docker.app --args --unattended --accept-license - echo "Waiting for docker to be up" - while ! /Applications/Docker.app/Contents/Resources/bin/docker info &>/dev/null; do echo -n "."; sleep 1; done - - name: Build linux binary + make build/awsu-darwin-amd64 + mv build/awsu-darwin-amd64 build/awsu-macos-latest-amd64 + - name: Build linux + if: matrix.os == 'ubuntu-latest' run: | make build/awsu-linux-amd64 - # as it is the format goreleaser expects - cp build/awsu-linux-amd64 build/awsu_linux_amd64 + mv build/awsu-linux-amd64 build/awsu-ubuntu-latest-amd64 + - uses: actions/upload-artifact@v2 + with: + name: awsu-${{ matrix.os }}-amd64 + path: build/awsu-${{ matrix.os }}-amd64 + + release-test: + runs-on: ubuntu-latest + needs: [artifact-build] + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Download macos + uses: actions/download-artifact@v2 + with: + name: awsu-macos-latest-amd64 + path: build/awsu-macos-latest-amd64 + - name: Download linux + uses: actions/download-artifact@v2 + with: + name: awsu-ubuntu-latest-amd64 + path: build/awsu-ubuntu-latest-amd64 + - name: Correct goreleaser prebuilt path + run: | + # as it is the format goreleaser expects. See .goreleaser.yml -> prebuilt -> path + mv build/awsu-ubuntu-latest-amd64 build/awsu_linux_amd64 + mv build/awsu-macos-latest-amd64 build/awsu_darwin_amd64 + ls -lash build - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2c191b9..3eaabc7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,8 +6,12 @@ on: - '*' jobs: - binaries: - runs-on: macos-11 + artifact-build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] steps: - name: Checkout uses: actions/checkout@v2 @@ -17,23 +21,50 @@ jobs: uses: actions/setup-go@v2 with: go-version: 1.17 - - name: Updating and upgrading brew + - name: Setup dependencies + if: matrix.os == 'ubuntu-latest' run: | - ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - brew --version - - name: Install and start docker - # https://github.com/docker/for-mac/issues/2359#issuecomment-943131345 + sudo apt-get update -q + sudo apt-get install -qqy build-essential software-properties-common pkg-config wget libpcsclite-dev + - name: Build darwin + if: matrix.os == 'macos-latest' run: | - brew install --cask docker - sudo /Applications/Docker.app/Contents/MacOS/Docker --unattended --install-privileged-components - open -a /Applications/Docker.app --args --unattended --accept-license - echo "Waiting for docker to be up" - while ! /Applications/Docker.app/Contents/Resources/bin/docker info &>/dev/null; do echo -n "."; sleep 1; done - - name: Build linux binary + make build/awsu-darwin-amd64 + mv build/awsu-darwin-amd64 build/awsu-macos-latest-amd64 + - name: Build linux + if: matrix.os == 'ubuntu-latest' run: | make build/awsu-linux-amd64 - # as it is the format goreleaser expects - cp build/awsu-linux-amd64 build/awsu_linux_amd64 + mv build/awsu-linux-amd64 build/awsu-ubuntu-latest-amd64 + - uses: actions/upload-artifact@v2 + with: + name: awsu-${{ matrix.os }}-amd64 + path: build/awsu-${{ matrix.os }}-amd64 + + release-test: + runs-on: ubuntu-latest + needs: [artifact-build] + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Download macos + uses: actions/download-artifact@v2 + with: + name: awsu-macos-latest-amd64 + path: build/awsu-macos-latest-amd64 + - name: Download linux + uses: actions/download-artifact@v2 + with: + name: awsu-ubuntu-latest-amd64 + path: build/awsu-ubuntu-latest-amd64 + - name: Correct goreleaser prebuilt path + run: | + # as it is the format goreleaser expects. See .goreleaser.yml -> prebuilt -> path + mv build/awsu-ubuntu-latest-amd64 build/awsu_linux_amd64 + mv build/awsu-macos-latest-amd64 build/awsu_darwin_amd64 + ls -lash build - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 with: diff --git a/.goreleaser.yml b/.goreleaser.yml index abae3bf..7b8c1f3 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,18 +1,9 @@ -before: - hooks: - - go mod tidy builds: - - id: "awsu-darwin" - env: - - CGO_ENABLED=1 - goos: - - darwin - goarch: - - amd64 - - id: "awsu-linux" + - id: "awsu-linux-darwin" builder: prebuilt goos: - linux + - darwin goarch: - amd64 prebuilt: