Merge pull request #156 from Juneo-io/dev #130
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: PROD Publish Package to npm | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
prod_test: | |
runs-on: [self-hosted] | |
env: | |
MNEMONIC: ${{ secrets.MNEMONIC }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install dependencies🔧 | |
run: npm install | |
- name: Run the tests 🧪 | |
run: npm run test-unit | |
publish: | |
needs: prod_test | |
runs-on: [self-hosted] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install dependencies and build 🔧 | |
run: npm install && npm run build | |
- name: Check if version has changed | |
id: version_check | |
run: | | |
CURRENT_VERSION=$(node -p "require('./package.json').version") | |
NPM_VERSION=$(npm show juneojs version) | |
if [[ "$CURRENT_VERSION" != "$NPM_VERSION" ]]; then | |
echo "New version detected: $CURRENT_VERSION" | |
echo "should_publish=true" >> $GITHUB_ENV | |
else | |
echo "No new version detected." | |
echo "should_publish=false" >> $GITHUB_ENV | |
fi | |
- name: Publish package on NPM 📦 | |
if: env.should_publish == 'true' | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Trigger juneojs-examples upgrade workflow | |
if: env.should_publish == 'true' | |
run: | | |
curl -X POST https://api.github.com/repos/Juneo-io/juneojs-examples/dispatches \ | |
-H "Accept: application/vnd.github.everest-preview+json" \ | |
-H "Authorization: token ${{ secrets.ACTIONS_KEY }}" \ | |
--data '{"event_type": "Trigger Workflow", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'" }}' |