Skip to content

Commit

Permalink
Run release actions for pull requests and all branches
Browse files Browse the repository at this point in the history
Building a release can uncover more issues than only running tests.
  • Loading branch information
hansmi committed Dec 20, 2022
1 parent d854334 commit 71f4299
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
name: Release packaging
name: Release

on:
workflow_dispatch:
pull_request:
push:
branches:
- main
tags:
- 'v[0-9]+.*'

permissions:
contents: write
Expand All @@ -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
Expand All @@ -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 }}

Expand Down

0 comments on commit 71f4299

Please sign in to comment.