fix: change the way of checking branch name in release action (#634) #53
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .github/workflows/release.yml | |
name: release | |
on: | |
push: | |
tags: | |
- "*" | |
permissions: | |
contents: write | |
jobs: | |
check-current-branch: | |
runs-on: ubuntu-latest | |
outputs: | |
branch: ${{ steps.check_step.outputs.branch }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get current branch | |
id: check_step | |
# 1. Get the list of branches ref where this tag exists | |
# 2. Remove 'origin/' from that result | |
# 3. Put that string in output | |
run: | | |
raw=$(git branch -r --contains ${{ github.ref }}) | |
branch="$(echo ${raw//origin\//} | tr -d '\n')" | |
echo "{name}=branch" >> $GITHUB_OUTPUT | |
echo "Branches where this tag exists : $branch." | |
goreleaser: | |
runs-on: ubuntu-latest | |
needs: check-current-branch | |
if: contains(${{ needs.check.outputs.branch }}, 'main')` | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: stable | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v6 | |
with: | |
distribution: goreleaser | |
version: latest | |
args: release --clean | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |