name: Elsa 3 Workflow Designer on: workflow_dispatch: push: branches: - v3 paths: - src/designer/** - .github/** pull_request: branches: - v3 paths: - src/designer/elsa-workflows-designer/** - .github/** release: types: [ prereleased ] env: NODE_OPTIONS: --max-old-space-size=8096 ELSA_VERSION: 3.0.3 jobs: build_and_pack: name: Build workflow designer package runs-on: ubuntu-latest steps: - name: Set preview VERSION variable run: echo "VERSION=$ELSA_VERSION-preview.${{ github.run_number }}" >> $GITHUB_ENV if: ${{ github.event_name != 'release' || github.event_name == 'prereleased' }} - name: Set release VERSION variable run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV if: ${{ github.event_name == 'release' }} - name: Checkout uses: actions/checkout@v2 - name: Setup Node uses: actions/setup-node@v3 with: node-version: 18.12.1 cache: 'npm' cache-dependency-path: '**/package-lock.json' - run: echo $VERSION - run: node --version - run: npm --version - name: Build Designer working-directory: ./src/designer/designer_packages/elsa-workflows-designer run: | npm install --force npm version $VERSION --allow-same-version npm run build if: ${{ github.event_name == 'release' || github.event_name == 'push'}} - name: Pack Designer working-directory: ./src/designer/designer_packages/elsa-workflows-designer run: npm pack if: ${{ github.event_name == 'release' || github.event_name == 'push'}} - name: Upload Designer Artifact uses: actions/upload-artifact@v3 with: name: designer-npm-package path: src/designer/designer_packages/elsa-workflows-designer/elsa-*.tgz if: ${{ github.event_name == 'release' || github.event_name == 'push'}} publish_npm_preview: name: Publish preview package to feedz needs: build_and_pack runs-on: ubuntu-latest if: ${{ github.event_name == 'release' || github.event_name == 'push'}} steps: - name: Download NPM Package uses: actions/download-artifact@v3 with: name: designer-npm-package path: designer-package - uses: actions/setup-node@v3 with: node-version: 18.12.1 registry-url: 'https://f.feedz.io/elsa-workflows/elsa-3/npm/' - run: npm publish ./designer-package/*.tgz env: NODE_AUTH_TOKEN: ${{ secrets.FEEDZ_IO_NPM }} publish_npm_release: name: Publish release package to npmjs needs: build_and_pack runs-on: ubuntu-latest if: ${{ github.event_name == 'release' || github.event_name == 'prereleased' }} steps: - name: Download NPM Package uses: actions/download-artifact@v3 with: name: designer-npm-package - uses: actions/setup-node@v3 with: node-version: 18.12.1 registry-url: 'https://registry.npmjs.org' - run: npm publish *.tgz env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} update_package_json_version: name: Update Version in Elsa.Workflows.Designer backend module needs: publish_npm_preview runs-on: ubuntu-latest if: ${{ github.ref == 'refs/heads/v3' }} steps: - name: Install jq run: sudo apt-get install jq - name: Checkout repository uses: actions/checkout@v3 with: fetch-depth: 0 token: ${{ secrets.ELSA_CORE_PAT }} - name: Update designer version in package.json run: | cd src/modules/Elsa.Workflows.Designer jq '.devDependencies["@elsa-workflows/elsa-workflows-designer"] = $newVersion' --arg newVersion $ELSA_VERSION-preview.${{ github.run_number }} package.json > package.json.tmp mv package.json.tmp package.json git fetch --all git config user.name "GitHub Action" git checkout v3 git add package.json git commit -m "Updated designer version to $ELSA_VERSION-preview.${{ github.run_number }}" git push origin v3