#28366 include in 23.01.22 LTS #1093
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 to Dotcms UI | |
on: | |
push: | |
branches: | |
- release-* | |
- master | |
jobs: | |
changes: | |
runs-on: ubuntu-latest | |
outputs: | |
dotcms-ui: ${{ steps.filter.outputs.dotcms-ui }} | |
steps: | |
- name: Checkout core | |
uses: actions/checkout@v3 | |
- name: Get specific changed files | |
uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
base: ${{ github.ref }} | |
list-files: "json" | |
working-directory: "core-web" | |
filters: | | |
dotcms-ui: | |
- 'core-web/apps/dotcms-ui/src/**' | |
- 'core-web/libs/!(dotcms-webcomponents/**)/**' | |
- name: Changes found | |
if: steps.filter.outputs.dotcms-ui == 'true' | |
run: | | |
cd core-web | |
echo "Found Dotcms-UI files changed." | |
echo ${{ steps.filter.outputs.dotcms-ui }} | |
- name: No changes found | |
if: steps.filter.outputs.dotcms-ui == 'false' | |
run: | | |
echo "No changes found in Dotcms-UI" | |
publish: | |
needs: changes | |
if: ${{ needs.changes.outputs.dotcms-ui == 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
fetch-depth: 1 | |
ref: ${{ github.ref_name }} | |
- name: Configuring Node.js | |
uses: actions/setup-node@v2-beta | |
with: | |
node-version: "16.13.2" | |
- name: Installing dependencies | |
run: | | |
cd core-web | |
npm install | |
- name: Version Bump - dotcms-ui - if it's Master/Release Branch | |
run: | | |
# Get Branch Name | |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
branchName="${{ github.head_ref }}" | |
else | |
branchName=$(basename "${{ github.ref }}") | |
fi | |
echo "******version brach name: " $branchName | |
# Checks if branch is release or master | |
if [[ $branchName == *master* ]]; then | |
preReleaseTag=next | |
elif [[ $branchName == *release* ]]; then | |
preReleaseTag=rc | |
fi | |
echo "******tag brach name: " $preReleaseTag | |
# Get version from package.json | |
cd core-web | |
pkgVersion=`awk -F'"' '/"version": ".+"/{ print $4; exit; }' package.json` | |
arrIN=(${pkgVersion//./ }) | |
# Bump version | |
if [[ $pkgVersion == *$preReleaseTag* ]]; then | |
preReleaseVersion=${arrIN[-1]} | |
pkgVersion="${arrIN[0]}.${arrIN[1]}.0-$preReleaseTag.$((preReleaseVersion+1))" | |
else | |
pkgVersion="${arrIN[0]}.${arrIN[1]}.0-$preReleaseTag.0" | |
fi | |
sed -i -E "s/\"version\": \".*\"/\"version\": \"$pkgVersion\"/g" ./package.json | |
# Commits new version | |
git config --global user.email "[email protected]" | |
git config --global user.name "victoralfaro-dotcms" | |
git add package.json | |
git commit -m "CI: bumps version to $pkgVersion [skip ci]" | |
git push https://victoralfaro-dotcms:${{ secrets.CICD_GITHUB_TOKEN }}@github.com/dotcms/core | |
- name: Build dotcms-ui with deps | |
run: | | |
cd core-web | |
npm run nx build dotcms-webcomponents && npm run nx build dotcms-ui -- --prod | |
cp package.json ./dist/apps/dotcms-ui/package.json | |
- name: "Publish to npm" | |
run: | | |
cd core-web | |
## We need to copy prepare for publish because it will look for it in one-level-down | |
## core-web folder | |
mkdir dist/apps/core-web | |
cp prepare.js ./dist/apps/core-web/prepare.js | |
npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_ORG_TOKEN }} | |
cd dist/apps/dotcms-ui | |
npm publish --access public | |