From 4decaa8885f5a2906a788fd7783ff66bd892545a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Rainone?= <476650+arl@users.noreply.github.com> Date: Sat, 18 Feb 2023 01:17:19 +0100 Subject: [PATCH] ci: Only publish if tests pass (#86) * ci: Only publish if tests pass * Cosmetics --- .github/workflows/{cd.yml => ci-cd.yaml} | 37 ++++++++++++++---------- .github/workflows/ci.yml | 15 ---------- 2 files changed, 22 insertions(+), 30 deletions(-) rename .github/workflows/{cd.yml => ci-cd.yaml} (56%) delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/ci-cd.yaml similarity index 56% rename from .github/workflows/cd.yml rename to .github/workflows/ci-cd.yaml index 5afbb15..4ff7a5d 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/ci-cd.yaml @@ -1,17 +1,24 @@ -name: Continuous Deployment - -on: - push: - tags: - - "*" - -permissions: - contents: write - +on: [push, pull_request] +name: Test, Build and Publish jobs: + tests: + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: "1.20.x" + - name: Run tests + run: go test -race ./... + goreleaser: - name: Publish release to github/brew + name: Build and Publish + needs: tests runs-on: ubuntu-latest + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') steps: - name: Checkout uses: actions/checkout@v3 @@ -31,15 +38,15 @@ jobs: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} check_brew: - name: Check brew tap has been updated - runs-on: macos-latest + name: Check Brew Tap needs: goreleaser + runs-on: macos-latest steps: - - name: brew tap/install + - name: Install gitmux with brew run: | brew tap arl/arl brew install gitmux gitmux -V - - name: check gitmux version + - name: Check installed gitmux version run: | [ v$(gitmux -V) == "$GITHUB_REF_NAME" ] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 4e2d0c6..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,15 +0,0 @@ -on: [push, pull_request] -name: Continuous Integration -jobs: - test: - strategy: - matrix: - os: [ubuntu-latest, macos-latest] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - with: - go-version: "1.20.x" - - name: Tests - run: go test -race ./...