chore: chnage the way of comparing branch names #52
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 | |
# => We can now use function 'contains(list, item)'' | |
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 | |
# Wait for check step to finish | |
needs: check-current-branch | |
# only run if tag is present on branch 'main' | |
if: contains(${{ needs.check.outputs.branch }}, 'fix/check-branch-in-release-action')` | |
#if: ${{ needs.check.outputs.branch == 'check-branch-in-release-action' }} | |
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 }} |