11name : Publish to npm
22
33on :
4- pull_request :
5- types : [closed]
4+ push :
65 branches :
76 - production
87
98jobs :
109 publish :
11- if : github.event.pull_request.merged == true
12- needs : ci
1310 runs-on : ubuntu-latest
11+ permissions :
12+ contents : write
1413
1514 steps :
1615 - name : Checkout
@@ -25,25 +24,60 @@ jobs:
2524 - name : Install dependencies
2625 run : npm ci
2726
27+ - name : Type check (server)
28+ run : npm run test:ts:back
29+
30+ - name : Type check (admin)
31+ run : npm run test:ts:front
32+
2833 - name : Build
2934 run : npm run build
3035
36+ - name : Verify plugin
37+ run : npm run verify
38+
39+ - name : Check version not already published
40+ run : |
41+ VERSION=$(node -p "require('./package.json').version")
42+ if npm view strapi-plugin-form-builder-cms@$VERSION version 2>/dev/null; then
43+ echo "Version $VERSION is already published on npm."
44+ exit 1
45+ fi
46+ echo "Version $VERSION is ready to publish."
47+
3148 - name : Get package version
3249 id : pkg
3350 run : echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
3451
52+ - name : Set npm tag
53+ id : tag
54+ run : |
55+ VERSION=$(node -p "require('./package.json').version")
56+ if [[ "$VERSION" == *"alpha"* ]]; then
57+ echo "tag=alpha" >> $GITHUB_OUTPUT
58+ elif [[ "$VERSION" == *"beta"* ]]; then
59+ echo "tag=beta" >> $GITHUB_OUTPUT
60+ elif [[ "$VERSION" == *"rc"* ]]; then
61+ echo "tag=rc" >> $GITHUB_OUTPUT
62+ else
63+ echo "tag=latest" >> $GITHUB_OUTPUT
64+ fi
65+
3566 - name : Publish to npm
36- run : npm publish --access public
67+ run : npm publish --access public --tag ${{ steps.tag.outputs.tag }}
3768 env :
3869 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
3970
71+ - name : Create git tag
72+ run : |
73+ git tag v${{ steps.pkg.outputs.version }}
74+ git push origin v${{ steps.pkg.outputs.version }}
75+
4076 - name : Create GitHub release
4177 uses : softprops/action-gh-release@v2
4278 with :
4379 tag_name : v${{ steps.pkg.outputs.version }}
4480 name : v${{ steps.pkg.outputs.version }}
45- body : |
46- Published from PR #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}
4781 generate_release_notes : true
4882
4983 ci :
0 commit comments