@@ -13,91 +13,91 @@ jobs:
13
13
permissions :
14
14
contents : write
15
15
pull-requests : write
16
- steps :
17
- - uses : actions/checkout@v4
18
- with :
19
- fetch-depth : 0
20
- ref : ${{ github.event.pull_request.head.ref || github.ref_name }}
16
+ steps :
17
+ - uses : actions/checkout@v4
18
+ with :
19
+ fetch-depth : 0
20
+ ref : ${{ github.event.pull_request.head.ref || github.ref_name }}
21
21
22
- - name : Check PR labels
23
- id : check_labels
24
- env :
25
- GH_TOKEN : ${{ github.token }}
26
- run : |
27
- PR_NUMBER=${{ github.event.pull_request.number }}
28
- echo "::notice::PR used to check version bump: #$PR_NUMBER"
29
- LABELS=$(gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name')
22
+ - name : Check PR labels
23
+ id : check_labels
24
+ env :
25
+ GH_TOKEN : ${{ github.token }}
26
+ run : |
27
+ PR_NUMBER=${{ github.event.pull_request.number }}
28
+ echo "::notice::PR used to check version bump: #$PR_NUMBER"
29
+ LABELS=$(gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name')
30
30
31
- # Make script executable
32
- chmod +x ./.github/ci-scripts/pr-label-check.sh
33
-
34
- # Run the script and capture both output and exit code
35
- RELEASE_TYPE=$(./.github/ci-scripts/pr-label-check.sh $PR_NUMBER 2>&1) || {
36
- # If script exits with non-zero, output the error and exit
37
- echo "::error::Script failed with output: $RELEASE_TYPE"
38
- exit 1
39
- }
31
+ # Make script executable
32
+ chmod +x ./.github/ci-scripts/pr-label-check.sh
40
33
41
- echo "version=$RELEASE_TYPE" >> $GITHUB_OUTPUT
42
- echo "::notice::Release label detected: $RELEASE_TYPE"
43
- if [ "$RELEASE_TYPE" == "no-release" ]; then
44
- echo "::notice::PR is not flagged for release, skipping bump"
45
- fi
34
+ # Run the script and capture both output and exit code
35
+ RELEASE_TYPE=$(./.github/ci-scripts/pr-label-check.sh $PR_NUMBER 2>&1) || {
36
+ # If script exits with non-zero, output the error and exit
37
+ echo "::error::Script failed with output: $RELEASE_TYPE"
38
+ exit 1
39
+ }
46
40
47
- - name : Bump version
48
- if : steps.check_labels.outputs.version != 'no-release'
49
- env :
50
- GH_TOKEN : ${{ github.token }}
51
- run : |
52
- chmod +x ./.github/ci-scripts/bump-check.sh
53
- # Capture only the last line of output as BUMP_CHECK
54
- BUMP_CHECK=$(./.github/ci-scripts/bump-check.sh | tail -n 1)
55
- if [ "$BUMP_CHECK" == "true" ]; then
56
- git config user.name "GitHub Actions"
57
- git config user.email "actions@github.com"
58
- if [ "${{ steps.check_labels.outputs.version }}" == "alpha" ]; then
59
- npm version -m "[bot] New pkg version: %s" --preid=alpha prerelease
60
- else
61
- npm version -m "[bot] New pkg version: %s" ${{ steps.check_labels.outputs.version }}
41
+ echo "version=$RELEASE_TYPE" >> $GITHUB_OUTPUT
42
+ echo "::notice::Release label detected: $RELEASE_TYPE"
43
+ if [ "$RELEASE_TYPE" == "no-release" ]; then
44
+ echo "::notice::PR is not flagged for release, skipping bump"
62
45
fi
63
- git push
64
- gh pr comment ${{ github.event.pull_request.number }} --body "Auto-bumped version for release, this cannot be the last commit as bots can't trigger the workflows to pass the PR checks"
65
- fi
66
46
67
- - name : Revert version bump
68
- if : steps.check_labels.outputs.version == 'no-release'
69
- env :
70
- GH_TOKEN : ${{ github.token }}
71
- run : |
72
- MERGE_BASE=$(git merge-base origin/main HEAD)
73
- COMMITS=$(git log $MERGE_BASE..HEAD --format=%H:%B)
74
- # Find the latest version bump commit
75
- VERSION_COMMIT_SHA=$(echo "$COMMITS" | grep ":\[bot\] New pkg version:" | head -n 1 | cut -d':' -f1)
76
-
77
- if [ -n "$VERSION_COMMIT_SHA" ]; then
78
- # Count version bumps and reverts
79
- BUMP_COUNT=$(echo "$COMMITS" | grep -c ":\[bot\] New pkg version:" || true)
80
- REVERT_COUNT=$(echo "$COMMITS" | grep -c ":Revert.*\[bot\] New pkg version:" || true)
81
-
82
- if [ $REVERT_COUNT -lt $BUMP_COUNT ]; then
47
+ - name : Bump version
48
+ if : steps.check_labels.outputs.version != 'no-release'
49
+ env :
50
+ GH_TOKEN : ${{ github.token }}
51
+ run : |
52
+ chmod +x ./.github/ci-scripts/bump-check.sh
53
+ # Capture only the last line of output as BUMP_CHECK
54
+ BUMP_CHECK=$(./.github/ci-scripts/bump-check.sh | tail -n 1)
55
+ if [ "$BUMP_CHECK" == "true" ]; then
83
56
git config user.name "GitHub Actions"
84
57
git config user.email "actions@github.com"
85
- git revert --no-edit $VERSION_COMMIT_SHA
58
+ if [ "${{ steps.check_labels.outputs.version }}" == "alpha" ]; then
59
+ npm version -m "[bot] New pkg version: %s" --preid=alpha prerelease
60
+ else
61
+ npm version -m "[bot] New pkg version: %s" ${{ steps.check_labels.outputs.version }}
62
+ fi
86
63
git push
87
- gh pr comment ${{ github.event.pull_request.number }} --body "Reverted version bump as no-release label was detected"
88
- else
89
- echo "::notice::Version bump has already been reverted, skipping"
64
+ gh pr comment ${{ github.event.pull_request.number }} --body "Auto-bumped version for release, this cannot be the last commit as bots can't trigger the workflows to pass the PR checks"
65
+ fi
66
+
67
+ - name : Revert version bump
68
+ if : steps.check_labels.outputs.version == 'no-release'
69
+ env :
70
+ GH_TOKEN : ${{ github.token }}
71
+ run : |
72
+ MERGE_BASE=$(git merge-base origin/main HEAD)
73
+ COMMITS=$(git log $MERGE_BASE..HEAD --format=%H:%B)
74
+ # Find the latest version bump commit
75
+ VERSION_COMMIT_SHA=$(echo "$COMMITS" | grep ":\[bot\] New pkg version:" | head -n 1 | cut -d':' -f1)
76
+
77
+ if [ -n "$VERSION_COMMIT_SHA" ]; then
78
+ # Count version bumps and reverts
79
+ BUMP_COUNT=$(echo "$COMMITS" | grep -c ":\[bot\] New pkg version:" || true)
80
+ REVERT_COUNT=$(echo "$COMMITS" | grep -c ":Revert.*\[bot\] New pkg version:" || true)
81
+
82
+ if [ $REVERT_COUNT -lt $BUMP_COUNT ]; then
83
+ git config user.name "GitHub Actions"
84
+ git config user.email "actions@github.com"
85
+ git revert --no-edit $VERSION_COMMIT_SHA
86
+ git push
87
+ gh pr comment ${{ github.event.pull_request.number }} --body "Reverted version bump as no-release label was detected"
88
+ else
89
+ echo "::notice::Version bump has already been reverted, skipping"
90
+ fi
90
91
fi
91
- fi
92
-
93
92
94
93
create-release :
95
94
if : github.event_name == 'push' && github.ref == 'refs/heads/main'
96
95
runs-on : ubuntu-latest
97
96
permissions :
98
97
contents : write
99
98
steps :
100
- - name : Create GitHub Release
99
+ - uses : actions/checkout@v4
100
+ - name : Create GitHub Release
101
101
# if: steps.check_labels.outputs.version != 'no-release'
102
102
env :
103
103
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
@@ -107,4 +107,4 @@ jobs:
107
107
--title "Release v${VERSION}" \
108
108
--generate-notes \
109
109
--prerelease \
110
- --target "${GITHUB_SHA}"
110
+ --target "${GITHUB_SHA}"
0 commit comments