From 27b58fbbb29a1a6df27c76069f5fab2c15d6b53b Mon Sep 17 00:00:00 2001 From: Manfred Touron <94029+moul@users.noreply.github.com> Date: Tue, 1 Jun 2021 08:56:44 +0000 Subject: [PATCH] feat: optimize CI with repoman Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com> --- .github/workflows/docker.yml | 14 ++++++++++++++ .github/workflows/go.yml | 14 ++++++++++++++ .github/workflows/release.yml | 9 ++++++--- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 0f47150..e75120a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -7,8 +7,22 @@ on: release: types: [published,released] + jobs: + repoman: + runs-on: ubuntu-latest + outputs: + has-docker: ${{ steps.info.outputs.has-docker }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: '0' + - uses: moul/repoman-action@v1 + id: info + multi: + needs: repoman + if: needs.repoman.outputs.has-docker == 'true' name: "build-and-push" runs-on: ubuntu-latest steps: diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 26f16e8..4934a40 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -27,7 +27,19 @@ on: - ".github/workflows/go.yml" jobs: + repoman: + runs-on: ubuntu-latest + outputs: + has-go-binary: ${{ steps.info.outputs.has-go-binary }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: '0' + - uses: moul/repoman-action@v1 + id: info goreleaser-dryrun: + needs: repoman + if: needs.repoman.outputs.has-go-binary == 'true' strategy: matrix: golang: [1.16.x] @@ -103,6 +115,7 @@ jobs: key: ${{ runner.os }}-go-${{ matrix.golang }}-v1-${{ hashFiles('**/go.sum') }} restore-keys: ${{ runner.os }}-go-${{ matrix.golang }}-v1- - name: Compile the project + if: needs.repoman.outputs.has-go-binary == 'true' run: make go.install - name: Run tests on Unix-like operating systems run: make unittest @@ -144,6 +157,7 @@ jobs: key: ${{ runner.os }}-go-${{ matrix.golang }}-v1-${{ hashFiles('**/go.sum') }} restore-keys: ${{ runner.os }}-go-${{ matrix.golang }}-v1- - name: Compile the project + if: needs.repoman.outputs.has-go-binary == 'true' run: make go.install - name: Check go.mod and go.sum run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 87ab635..6db754c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,9 @@ jobs: - name: Unshallow run: git fetch --prune --unshallow + - + uses: moul/repoman-action@v1 + id: repoman - name: Run Semantic Release id: semantic @@ -27,13 +30,13 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set up Go - if: steps.semantic.outputs.new-release-published == 'true' + if: steps.semantic.outputs.new-release-published == 'true' && steps.repoman.outputs.has-go-binary == 'true' uses: actions/setup-go@v2 with: go-version: ${{ matrix.golang }} - name: Cache Go modules - if: steps.semantic.outputs.new-release-published == 'true' + if: steps.semantic.outputs.new-release-published == 'true' && steps.repoman.outputs.has-go-binary == 'true' uses: actions/cache@v2.1.6 with: path: ~/go/pkg/mod @@ -41,7 +44,7 @@ jobs: restore-keys: ${{ runner.os }}-go-${{ matrix.golang }}-v1- - name: Run GoReleaser - if: steps.semantic.outputs.new-release-published == 'true' + if: steps.semantic.outputs.new-release-published == 'true' && steps.repoman.outputs.has-go-binary == 'true' uses: goreleaser/goreleaser-action@v2.6.1 with: version: latest