From 54a97b63e7be63ca942069c837eb89b2444e6065 Mon Sep 17 00:00:00 2001 From: Richard Henning Date: Thu, 3 Jun 2021 22:47:59 -0400 Subject: [PATCH] tag and release after tests run against main branch if go-related sources changed (#15) --- .github/workflows/release.yml | 38 ++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 84b73b1..dd1ce0e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,15 +3,38 @@ name: release on: workflow_run: - workflows: ["test"] + workflows: [test] branches: [main] - types: - - completed + types: [completed] jobs: - release: + changes: if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + outputs: + gosrc: ${{ steps.filter.outputs.gosrc }} + + steps: + - name: checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: filter-src + id: filter + uses: dorny/paths-filter@v2 + with: + filters: | + gosrc: + - '**/*.go' + - 'go.mod' + - 'go.sum' + + release: + needs: changes + + if: ${{ needs.changes.outputs.gosrc == 'true' }} runs-on: ubuntu-latest steps: @@ -25,11 +48,16 @@ jobs: with: go-version: 1.16.x + - name: tag + uses: mathieudutour/github-tag-action@v5.5 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + - name: goreleaser uses: goreleaser/goreleaser-action@v2 with: distribution: goreleaser version: latest - args: release --rm-dist --skip-publish + args: release --rm-dist env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}