Skip to content

fix: change the way of checking branch name in release action (#634) #53

fix: change the way of checking branch name in release action (#634)

fix: change the way of checking branch name in release action (#634) #53

Workflow file for this run

# .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 }}