@@ -2,10 +2,6 @@ name: 'Version Preview'
22
33on :
44 workflow_call :
5- inputs :
6- pr_number :
7- required : true
8- type : number
95
106defaults :
117 run :
@@ -20,56 +16,46 @@ jobs:
2016 name : Preview Release
2117 runs-on : ubuntu-latest
2218 steps :
23- - name : Checkout PR merge commit
19+ - name : Checkout
2420 uses : actions/checkout@v4
2521 with :
2622 fetch-depth : 0
27- ref : refs/pull/${{ inputs.pr_number }}/merge
2823
29- - name : Configure for preview
24+ - name : Analyze PR commits
25+ id : semantic
3026 run : |
31- echo "Current HEAD: $(git rev-parse HEAD)"
32- echo "Current branch: $(git branch --show-current)"
33- echo ""
34- echo "Recent commits:"
35- git log --oneline -10
36- echo ""
37- echo "Latest tag:"
38- git describe --tags --abbrev=0
39- echo ""
40- echo "Commits since last tag:"
41- git log $(git describe --tags --abbrev=0)..HEAD --oneline
27+ git fetch origin ${{ github.base_ref }}
4228
43- # Create temporary releaserc that allows any branch
44- cat > .releaserc.json << 'EOF'
45- {
46- "branches": ["*"],
47- "plugins": [
48- "@semantic-release/commit-analyzer",
49- "@semantic-release/release-notes-generator",
50- ["@semantic-release/changelog", {"changelogFile": "CHANGELOG.md"}],
51- ["@semantic-release/git", {"assets": ["CHANGELOG.md"]}],
52- "@semantic-release/github"
53- ]
54- }
55- EOF
29+ COMMITS=$(git log origin/${{ github.base_ref }}..HEAD --pretty=format:"%s")
5630
57- git checkout -b temp-preview-branch
58- echo ""
59- echo "Created branch: $(git branch --show-current)"
31+ if echo "$COMMITS" | grep -qE "^[a-z]+(\(.+\))?!:|BREAKING CHANGE:"; then
32+ TYPE="major"
33+ elif echo "$COMMITS" | grep -qE "^feat(\(.+\))?:"; then
34+ TYPE="minor"
35+ elif echo "$COMMITS" | grep -qE "^fix(\(.+\))?:"; then
36+ TYPE="patch"
37+ else
38+ TYPE="none"
39+ fi
6040
61- - name : Preview Release
62- id : semantic
63- uses : cycjimmy/semantic-release-action@v2
64- with :
65- semantic_version : 18.0.0
66- dry_run : true
67- extra_plugins : |
68- @semantic-release/changelog@6.0.0
69- @semantic-release/git@10.0.0
70- conventional-changelog-conventionalcommits@4.6.3
71- env :
72- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
41+ if [ "$TYPE" != "none" ]; then
42+ CURRENT=$(git tag --sort=-v:refname | head -1 | sed 's/^v//')
43+ IFS='.' read -r maj min pat <<< "$CURRENT"
44+
45+ [ "$TYPE" = "major" ] && maj=$((maj + 1)) && min=0 && pat=0
46+ [ "$TYPE" = "minor" ] && min=$((min + 1)) && pat=0
47+ [ "$TYPE" = "patch" ] && pat=$((pat + 1))
48+
49+ echo "new_release_published=true" >> $GITHUB_OUTPUT
50+ echo "new_release_version=$maj.$min.$pat" >> $GITHUB_OUTPUT
51+ echo "new_release_type=$TYPE" >> $GITHUB_OUTPUT
52+ echo "new_release_notes<<EOF" >> $GITHUB_OUTPUT
53+ echo "## Changes in this PR" >> $GITHUB_OUTPUT
54+ echo "$COMMITS" | sed 's/^/- /' >> $GITHUB_OUTPUT
55+ echo "EOF" >> $GITHUB_OUTPUT
56+ else
57+ echo "new_release_published=false" >> $GITHUB_OUTPUT
58+ fi
7359
7460 - name : Comment PR
7561 if : always()
0 commit comments