-
Notifications
You must be signed in to change notification settings - Fork 10
90 lines (78 loc) · 3.25 KB
/
Copy pathnext.yml
File metadata and controls
90 lines (78 loc) · 3.25 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
name: Fusion Framework Pre-Release
on:
push:
branches-ignore:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
contents: write
pull-requests: write
jobs:
check-pre-release:
name: Check pre-release configuration
runs-on: ubuntu-latest
outputs:
should-run: ${{ steps.check.outputs.should-run }}
tag: ${{ steps.check.outputs.tag }}
steps:
- uses: actions/checkout@v7
- name: Check if branch targets main and pre-release configuration
id: check
run: |
# Check if branch has a PR targeting main
BRANCH_NAME="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
PR_COUNT=$(gh pr list --base main --head "$BRANCH_NAME" --state open --json number --jq 'length')
if [ "$PR_COUNT" -eq 0 ]; then
echo "should-run=false" >> $GITHUB_OUTPUT
echo "::notice::Pre-release skipped: No open pull request targeting main found for branch '$BRANCH_NAME'."
exit 0
fi
echo "Found PR targeting main for branch '$BRANCH_NAME'"
# Check for pre-release configuration
if [ ! -f ".changeset/pre.json" ]; then
echo "should-run=false" >> $GITHUB_OUTPUT
echo "::notice::Pre-release skipped: .changeset/pre.json not found. This is expected for non-pre-release branches."
exit 0
fi
TAG=$(node -p "require('./.changeset/pre.json').tag")
if [ "$TAG" = "latest" ]; then
echo "Error: Pre-release workflow cannot use 'latest' tag. 'latest' is reserved for stable releases."
exit 1
fi
echo "should-run=true" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Using tag from pre.json: $TAG"
env:
GH_TOKEN: ${{ github.token }}
release-pkg:
name: Version or publish pre-release of packages
needs: check-pre-release
if: needs.check-pre-release.outputs.should-run == 'true'
runs-on: fusion-gh-runner-fusion-framework
outputs:
published: ${{ steps.changesets.outputs.published }}
has-changesets: ${{ steps.changesets.outputs.has-changesets }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup node and install deps
uses: ./.github/actions/node-setup
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v2
with:
github-token: ${{ github.token }}
pr-title: '🤖 Bip Bop - Fusion Framework Pre-Release'
version-script: pnpm changeset:version
publish-script: pnpm publish -r --no-git-checks --report-summary --tag ${{ needs.check-pre-release.outputs.tag }}
env:
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
# fusion-gh-runner-fusion-framework's image doesn't ship gh (tracked with
# infra). Non-blocking: worst case the changeset PR stays open/ready.
- name: convert Changeset PR to draft
if: steps.changesets.outputs.published == 'false' && steps.changesets.outputs['pr-number']
continue-on-error: true
run: gh pr ready ${{ steps.changesets.outputs['pr-number'] }} --undo
env:
GH_TOKEN: ${{ github.token }}