1111 runs-on : ubuntu-latest
1212 steps :
1313 - name : Checkout code
14- uses : actions/checkout@v5
14+ uses : actions/checkout@v6
1515
1616 - name : Submodules
1717 run : git submodule update --init --recursive
3838 run : npm run test:unit
3939
4040 - name : Upload build artifact
41- uses : actions/upload-artifact@v4
41+ uses : actions/upload-artifact@v6
4242 with :
4343 name : build-dist
4444 path : |
@@ -51,10 +51,49 @@ jobs:
5151
5252 - name : Upload test results
5353 if : always()
54- uses : actions/upload-artifact@v5
54+ uses : actions/upload-artifact@v6
5555 with :
5656 name : unit-test-results
5757 path : |
5858 **/*test-results*
5959 **/*coverage*
6060 retention-days : 7
61+
62+ publish-pr :
63+ if : >-
64+ github.event_name == 'pull_request' &&
65+ github.event.pull_request.head.repo.full_name == github.repository
66+ needs : build
67+ runs-on : ubuntu-latest
68+ permissions :
69+ contents : read
70+ packages : write
71+ steps :
72+ - name : Download build artifact
73+ uses : actions/download-artifact@v7
74+ with :
75+ name : build-dist
76+ path : ./package
77+
78+ - name : Setup Node.js for GitHub Packages
79+ uses : actions/setup-node@v6
80+ with :
81+ node-version : " 22"
82+ registry-url : " https://npm.pkg.github.com"
83+ scope : " @crispthinking"
84+
85+ - name : Set pre-release version
86+ working-directory : ./package
87+ run : |
88+ PR_NUMBER=${{ github.event.pull_request.number }}
89+ SHORT_SHA=${GITHUB_SHA::7}
90+ VERSION="0.0.0-pr.${PR_NUMBER}.${SHORT_SHA}"
91+ npm --no-git-tag-version version "$VERSION"
92+
93+ - name : Publish pre-release package
94+ working-directory : ./package
95+ env :
96+ NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
97+ run : |
98+ PR_TAG="pr-${{ github.event.pull_request.number }}"
99+ npm publish --tag "$PR_TAG"
0 commit comments