From 71f429906e68871a0c0da57f55ea3c7dbb39fc46 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann Date: Wed, 21 Dec 2022 00:34:40 +0100 Subject: [PATCH] Run release actions for pull requests and all branches Building a release can uncover more issues than only running tests. --- .github/workflows/release.yaml | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 37c4b93..fe822a8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,12 +1,9 @@ -name: Release packaging +name: Release on: workflow_dispatch: + pull_request: push: - branches: - - main - tags: - - 'v[0-9]+.*' permissions: contents: write @@ -33,16 +30,26 @@ jobs: EVENT_NAME: ${{ github.event_name }} REF: ${{ github.ref }} run: | - goreleaser_args=( --skip-publish ) docker_login= + goreleaser_command=build + goreleaser_args=( --single-target --snapshot ) - if [[ "$EVENT_NAME" = push && "$REF" = refs/tags/v[0-9]*.* ]]; then - goreleaser_args=() - docker_login=true - fi + case "${EVENT_NAME:?}" in + push | workflow_dispatch) + if [[ "$REF" = refs/heads/main ]]; then + goreleaser_command=release + goreleaser_args=( --skip-publish ) + elif [[ "$REF" = refs/tags/v[0-9]*.* ]]; then + docker_login=true + goreleaser_command=release + goreleaser_args=() + fi + ;; + esac - echo "goreleaser_args=${goreleaser_args[*]}" >> $GITHUB_OUTPUT echo "docker_login=${docker_login}" >> $GITHUB_OUTPUT + echo "goreleaser_command=${goreleaser_command}" >> $GITHUB_OUTPUT + echo "goreleaser_args=${goreleaser_args[*]}" >> $GITHUB_OUTPUT - name: Login to GitHub Container Registry uses: docker/login-action@v2 @@ -57,7 +64,7 @@ jobs: with: distribution: goreleaser version: latest - args: release --rm-dist ${{ steps.vars.outputs.goreleaser_args }} + args: ${{ steps.vars.outputs.goreleaser_command }} --rm-dist ${{ steps.vars.outputs.goreleaser_args }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}