Merge pull request #1 from HankunYu/dev #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Packages | |
on: | |
push: | |
branches: | |
- main # 在 main 分支上推送代码时运行 | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '12' | |
- name: Install dependencies | |
run: | | |
npm install | |
- name: Authenticate with Verdaccio | |
env: | |
VERDACCIO_REGISTRY: ${{ secrets.VERDACCIO_REGISTRY }} | |
VERDACCIO_USERNAME: ${{ secrets.VERDACCIO_USERNAME }} | |
VERDACCIO_PASSWORD: ${{ secrets.VERDACCIO_PASSWORD }} | |
VERDACCIO_EMAIL: ${{ secrets.VERDACCIO_EMAIL }} | |
run: | | |
echo "//${{ secrets.VERDACCIO_REGISTRY }}/:_password=$(echo -n '${{ secrets.VERDACCIO_PASSWORD }}' | openssl base64)" >> ~/.npmrc | |
echo "//${{ secrets.VERDACCIO_REGISTRY }}/:username=${{ secrets.VERDACCIO_USERNAME }}" >> ~/.npmrc | |
echo "registry=https://${{ secrets.VERDACCIO_REGISTRY }}" >> ~/.npmrc | |
- name: Publish all packages | |
run: | | |
for dir in Assets/Packages/*/; do | |
if [ -f "$dir/package.json" ]; then | |
echo "Publishing $dir" | |
cd $dir | |
npm publish --registry https://${{ secrets.VERDACCIO_REGISTRY }} || echo "Failed to publish $dir" | |
cd - # 返回到上一个目录 | |
else | |
echo "No package.json found in $dir, skipping" | |
fi | |
done |