diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml index 3f493bb4c..49890af42 100644 --- a/.github/workflows/cli.yml +++ b/.github/workflows/cli.yml @@ -12,11 +12,15 @@ on: jobs: build: - name: Build and test ${{ matrix.os }} + name: Build and test ${{ matrix.os }} ${{ matrix.arch }} runs-on: ubuntu-latest strategy: matrix: os: [linux, darwin, windows] + arch: [amd64, arm64] + exclude: + - os: windows + arch: arm64 env: VAULT_VERSION: "1.1.3" VAULT_TOKEN: "root" @@ -24,10 +28,10 @@ jobs: steps: - name: Install dependencies run: sudo apt-get update && sudo apt-get install git -y - - name: Set up Go 1.13 + - name: Set up Go 1.16 uses: actions/setup-go@v2 with: - go-version: 1.13 + go-version: 1.16 id: go - name: Check out code into the Go module directory uses: actions/checkout@v2 @@ -37,13 +41,24 @@ jobs: key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- - - name: Build + - name: Build Linux and Darwin + if: matrix.os != 'windows' + run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o sops-${{ matrix.os }}-${{ matrix.arch }}-${{ github.sha }} -v ./cmd/sops + - name: Build Windows + if: matrix.os == 'windows' run: GOOS=${{ matrix.os }} go build -o sops-${{ matrix.os }}-${{ github.sha }} -v ./cmd/sops - name: Import test GPG keys run: for i in 1 2 3 4 5; do gpg --import pgp/sops_functional_tests_key.asc && break || sleep 15; done - name: Test run: make test - - name: Upload artifact + - name: Upload artifact for Linux and Darwin + if: matrix.os != 'windows' + uses: actions/upload-artifact@v2 + with: + name: sops-${{ matrix.os }}-${{ matrix.arch }}-${{ github.sha }} + path: sops-${{ matrix.os }}-${{ matrix.arch }}-${{ github.sha }} + - name: Upload artifact for Windows + if: matrix.os == 'windows' uses: actions/upload-artifact@v2 with: name: sops-${{ matrix.os }}-${{ github.sha }} @@ -63,9 +78,9 @@ jobs: uses: actions/checkout@v2 - uses: actions/download-artifact@v2 with: - name: sops-linux-${{ github.sha }} + name: sops-linux-amd64-${{ github.sha }} - name: Move SOPS binary - run: mv sops-linux-${{ github.sha }} ./functional-tests/sops + run: mv sops-linux-amd64-${{ github.sha }} ./functional-tests/sops - name: Make SOPS binary executable run: chmod +x ./functional-tests/sops - name: Download Vault diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 962edf62b..7744ea792 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,13 +15,15 @@ jobs: run: sudo apt-get update && sudo apt-get install git ruby rpm -y - name: Install fpm run: gem install fpm || sudo gem install fpm - - name: Set up Go 1.15 + - name: Set up Go 1.16 uses: actions/setup-go@v2 with: - go-version: 1.15 + go-version: 1.16 id: go - name: Check out code into the Go module directory uses: actions/checkout@v2 + - name: Go vendor + run: go mod vendor - name: Make release directory run: mkdir dist - name: Build deb and rpm @@ -32,8 +34,10 @@ jobs: run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Set RELEASE_NUMBER run: echo "RELEASE_NUMBER=$(echo $RELEASE_VERSION | cut -c2-)" >> $GITHUB_ENV - - name: Build darwin binary - run: GOOS=darwin CGO_ENABLED=0 go build -mod vendor -o dist/sops-${{ env.RELEASE_VERSION }}.darwin go.mozilla.org/sops/v3/cmd/sops + - name: Build darwin amd64 binary + run: GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -mod vendor -o dist/sops-${{ env.RELEASE_VERSION }}.darwin.amd64 go.mozilla.org/sops/v3/cmd/sops + - name: Build darwin arm64 binary + run: GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -mod vendor -o dist/sops-${{ env.RELEASE_VERSION }}.darwin.arm64 go.mozilla.org/sops/v3/cmd/sops - name: Build windows binary run: GOOS=windows CGO_ENABLED=0 go build -mod vendor -o dist/sops-${{ env.RELEASE_VERSION }}.exe go.mozilla.org/sops/v3/cmd/sops - name: Copy already built linux binary @@ -45,7 +49,8 @@ jobs: prerelease: true files: | dist/sops-${{ env.RELEASE_VERSION }}.exe - dist/sops-${{ env.RELEASE_VERSION }}.darwin + dist/sops-${{ env.RELEASE_VERSION }}.darwin.amd64 + dist/sops-${{ env.RELEASE_VERSION }}.darwin.arm64 dist/sops-${{ env.RELEASE_VERSION }}.linux dist/sops_${{ env.RELEASE_NUMBER }}_amd64.deb dist/sops-${{ env.RELEASE_NUMBER }}-1.x86_64.rpm