-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (75 loc) · 2.95 KB
/
Copy pathcreate-beta-release.yml
File metadata and controls
89 lines (75 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Create Beta Release
# Workflow para criar uma release beta
# Executado apenas quando há push em branches release/*
on:
push:
branches:
- release/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
check-if-pr-exists:
name: Check if PR Exists
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.check.outputs.should_run }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check if a PR exists for this branch
id: check
run: |
BRANCH_NAME="${{ github.ref_name }}"
PR_COUNT=$(gh pr list --head "$BRANCH_NAME" --state open --json number --jq 'length')
echo "PR count for branch $BRANCH_NAME: $PR_COUNT"
if [ "$PR_COUNT" -gt 0 ]; then
echo "Found open PR. Semantic release will not run on this push."
echo "should_run=false" >> $GITHUB_OUTPUT
exit 0
fi
# Check for other active release branches
OTHER_RELEASE_BRANCHES=$(gh api repos/${{ github.repository }}/branches --jq '.[] | select(.name | startswith("release/")) | select(.name != "'$BRANCH_NAME'") | .name' | tr '\n' ' ')
OTHER_COUNT=$(echo "$OTHER_RELEASE_BRANCHES" | wc -w)
if [ "$OTHER_COUNT" -gt 0 ]; then
echo "❌ Found $OTHER_COUNT other release branches: $OTHER_RELEASE_BRANCHES"
echo "Multiple release branches are not allowed. Please merge or delete conflicting branches."
echo "should_run=false" >> $GITHUB_OUTPUT
exit 1
fi
echo "No open PR found and no conflicting release branches. Proceeding with semantic-release."
echo "should_run=true" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run-semantic-release:
name: Run Semantic Release (Beta)
needs: check-if-pr-exists
if: needs.check-if-pr-exists.outputs.should_run == 'true' && !contains(github.event.head_commit.message, 'chore(release)')
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_PAT_FOR_RELEASE }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: "22.x"
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run Semantic Release
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT_FOR_RELEASE }}
GIT_AUTHOR_NAME: github-actions[bot]
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
GIT_COMMITTER_NAME: github-actions[bot]
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
run: pnpm exec semantic-release