1- name : Build and Test
1+ name : Build and Test and Publish
22
33on :
44 push :
1313 type : boolean
1414 default : false
1515
16+ release :
17+ types : [published]
18+
19+ pull_request :
20+ types : [opened, synchronize, reopened]
21+
1622concurrency :
1723 group : ${{ github.workflow }}-${{ github.ref }}
1824 cancel-in-progress : true
1925
26+ env :
27+ GITHUB_TOKEN : " _DUMMY_"
28+ NODE_AUTH_TOKEN : " _DUMMY_"
29+
2030jobs :
2131 build-image :
2232 name : Preapre builder image
8696 mkdir -p prefix dist wasm-build cache
8797 chmod o+w prefix dist wasm-build cache
8898 docker compose up ci --no-build
89- # - name: Check files
90- # run: ls . */
9199 - name : Install dependencies
92100 run : corepack pnpm install --frozen-lockfile
93101 - name : Run tests
@@ -99,10 +107,11 @@ jobs:
99107 with :
100108 name : libxmlwasm.tgz
101109 path : libxml-wasm-*.tgz
102- publish_github :
103- name : Publish to GitHub Packages
110+ publish :
111+ name : Publish packages
104112 runs-on : ubuntu-latest
105113 needs : build
114+ if : ${{ github.event_name != 'pull_request' && !startsWith(github.ref_name, 'dependabot/') }}
106115 permissions :
107116 contents : read
108117 packages : write
@@ -120,20 +129,27 @@ jobs:
120129 tar axf libxml-wasm-*.tgz
121130 mv package/* .
122131 rm -fr package
123- # - name: Login to GitHub Packages
124- # run: |
125- # corepack yarn set npmScopes.libxmlwasm.npmAuthToken ${{ secrets.GITHUB_TOKEN }}
126- # cat ./.yarnrc.yml
127- # corepack yarn npm whoami --scope "${{ github.repository_owner }}"
128132 - name : Prepare package
129133 id : package
130134 run : |
131- ./scripts/jqout.sh '.name="@${{ github.repository_owner }}/wasm"' package.json
132- ./scripts/jqout.sh '.version+="-${{ github.ref_name }}-${{ github.sha }}"' package.json
135+ if [ ${{ github.ref_name == 'master' }} ]; then
136+ echo "This is the master branch"
137+ echo "tag=latest" >> $GITHUB_OUTPUT
138+ else
139+ echo "This is the develop branch"
140+ ./scripts/jqout.sh '.version+="-${{ github.ref_name }}-${{ github.sha }}"' package.json
141+ echo "tag=experimental" >> $GITHUB_OUTPUT
142+ fi
133143 echo "name=$(jq .name package.json)" >> $GITHUB_OUTPUT
134144 echo "version=$(jq .version package.json)" >> $GITHUB_OUTPUT
135- - name : Publish package
145+ - name : Publish package to NPM
146+ env :
147+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
148+ run : |
149+ corepack pnpm publish --access public --tag ${{ steps.package.outputs.tag }} --no-git-checks
150+ - name : Publish package to GitHub Package Registry
136151 env :
137152 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
138153 run : |
139- corepack pnpm publish --access public --tag experimental --no-git-checks
154+ ./scripts/jqout.sh '.name="@${{ github.repository_owner }}/wasm"' package.json
155+ corepack pnpm publish --access public --tag ${{ steps.package.outputs.tag }} --no-git-checks
0 commit comments