Skip to content

Commit

Permalink
Merge pull request #166 from moul/dev/moul/repoman
Browse files Browse the repository at this point in the history
feat: optimize CI with repoman
  • Loading branch information
moul authored Jun 1, 2021
2 parents 25b603f + 27b58fb commit 74aeeb1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: |
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,21 +30,21 @@ 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/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.golang }}-v1-${{ hashFiles('**/go.sum') }}
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/[email protected]
with:
version: latest
Expand Down

0 comments on commit 74aeeb1

Please sign in to comment.