瀏覽代碼

chore: Add workflow for testing publishing npm packages

Michael Bromley 6 年之前
父節點
當前提交
96a28acf83
共有 3 個文件被更改,包括 141 次插入1 次删除
  1. 65 0
      .github/workflows/publish_and_install.yml
  2. 68 0
      .github/workflows/verdaccio/config.yaml
  3. 8 1
      scripts/publish-to-verdaccio.sh

+ 65 - 0
.github/workflows/publish_and_install.yml

@@ -0,0 +1,65 @@
+name: Publish & Install
+
+on:
+  push:
+    branches:
+    - master
+  pull_request:
+    branches:
+    - master
+jobs:
+  publish_install:
+
+    runs-on: ubuntu-latest
+
+    #services:
+    #  verdaccio:
+    #    image: verdaccio/verdaccio
+    #    ports:
+    #      - 4873
+    #    # volumes:
+    #    #   - "./verdaccio:/verdaccio/conf"
+
+    steps:
+    - uses: actions/checkout@v1
+    - name: Use Node.js 12.x
+      uses: actions/setup-node@v1
+      with:
+        node-version: 12.x
+    - name: Install & build
+      run: |
+        yarn install
+        yarn bootstrap
+      env:
+        CI: true
+    - name: Install Verdaccio
+      run: |
+        npm install -g verdaccio
+        mkdir -p $HOME/.config/verdaccio
+        cp -v ./.github/workflows/verdaccio/config.yaml $HOME/.config/verdaccio/config.yaml
+        verdaccio --config $HOME/.config/verdaccio/config.yaml &
+        sleep 10s
+    # - name: Bump version
+    #   env:
+    #     VERSION: 0.0.0-ci.${{ GITHUB_SHA }}
+    #   run: |
+    #     yarn lerna version $VERSION --no-push --no-commit-hooks
+    - name: Publish to Verdaccio
+      env:
+        #VERDACCIO_URL: http://localhost:${{ job.services.verdaccio.ports['4873'] }}
+        VERDACCIO_URL: http://localhost:4873
+      run: |
+        npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}
+        npm set //localhost:4873/:_authToken=${{ secrets.VERDACCIO_AUTH_TOKEN }}
+        npm set registry=http://localhost:4873/
+        yarn lerna publish prepatch --preid ci --no-push --no-git-tag-version --no-commit-hooks --yes --dist-tag ci --registry http://localhost:4873/
+      # cd scripts
+      # chmod +x publish-to-verdaccio.sh
+      # ./publish-to-verdaccio.sh
+    - name: Install from Verdaccio
+      run: |
+        mkdir -p $HOME/install
+        cd $HOME/install
+        yarn init -y
+        yarn add @vendure/core@ci --registry http://localhost:4873/
+

+ 68 - 0
.github/workflows/verdaccio/config.yaml

@@ -0,0 +1,68 @@
+#
+# This is the default config file. It allows all users to do anything,
+# so don't use it on production systems.
+#
+# Look here for more config file examples:
+# https://github.com/verdaccio/verdaccio/tree/master/conf
+#
+
+# path to a directory with all packages
+storage: ./storage
+# path to a directory with plugins to include
+plugins: ./plugins
+
+web:
+  # WebUI is enabled as default, if you want disable it, just uncomment this line
+  enable: false
+  title: Verdaccio
+
+auth:
+  htpasswd:
+    file: ./htpasswd
+    # Maximum amount of users allowed to register, defaults to "+inf".
+    # You can set this to -1 to disable registration.
+    #max_users: 1000
+
+# a list of other known repositories we can talk to
+uplinks:
+  npmjs:
+    url: https://registry.npmjs.org/
+
+packages:
+  '@*/*':
+    # scoped packages
+    access: $anonymous
+    publish: $anonymous
+    proxy: npmjs
+
+  '**':
+    # allow all users (including non-authenticated users) to read and
+    # publish all packages
+    #
+    # you can specify usernames/groupnames (depending on your auth plugin)
+    # and three keywords: "$all", "$anonymous", "$authenticated"
+    access: $anonymous
+
+    # allow all known users to publish packages
+    # (anyone can register by default, remember?)
+    publish: $anonymous
+
+    # if package is not available locally, proxy requests to 'npmjs' registry
+    proxy: npmjs
+
+# You can specify HTTP/1.1 server keep alive timeout in seconds for incomming connections.
+# A value of 0 makes the http server behave similarly to Node.js versions prior to 8.0.0, which did not have a keep-alive timeout.
+# WORKAROUND: Through given configuration you can workaround following issue https://github.com/verdaccio/verdaccio/issues/301. Set to 0 in case 60 is not enought.
+server:
+  keepAliveTimeout: 60
+
+# To use `npm audit` uncomment the following section
+middlewares:
+  audit:
+    enabled: true
+
+# log settings
+logs:
+  - {type: stdout, format: pretty, level: debug}
+  #- {type: file, path: verdaccio.log, level: info}
+

+ 8 - 1
scripts/publish-to-verdaccio.sh

@@ -1,7 +1,14 @@
 #!/bin/bash
 
 # A shell script which publishes all packages to a local Verdaccio registry for testing / local dev purposes
-VERDACCIO=http://localhost:4873/
+
+if [[ -z "${VERDACCIO_URL}" ]]; then
+  VERDACCIO=http://localhost:4873/
+else
+  VERDACCIO="${VERDACCIO_URL}"
+fi
+
+echo "Publishing to Verdaccio @ $VERDACCIO"
 
 cd ../packages/admin-ui-plugin && npm publish -reg $VERDACCIO &&\
 cd ../admin-ui && npm publish -reg $VERDACCIO &&\