This repository has been archived by the owner on Sep 24, 2024. It is now read-only.
dotCMS/core#24683 include in 22.03.9 #651
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 Webcomponents | |
on: | |
push: | |
branches: | |
- release-* | |
- master | |
jobs: | |
changes: | |
runs-on: ubuntu-latest | |
outputs: | |
dotcms-webcomponents: ${{ steps.filter.outputs.dotcms-webcomponents }} | |
steps: | |
- name: Checkout core-web | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 1 | |
path: 'core-web' | |
- 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-webcomponents: | |
- 'libs/dotcms-webcomponents/**' | |
- name: Changes found | |
if: steps.filter.outputs.dotcms-webcomponents == 'true' | |
run: | | |
echo "Found Dotcms-webcomponent files changed." | |
echo ${{ steps.filter.outputs.dotcms-webcomponents_files }} | |
- name: No changes found | |
if: steps.filter.outputs.dotcms-webcomponents == 'false' | |
run: | | |
echo "No changes found in dotcms-webcomponents" | |
publish: | |
needs: changes | |
if: ${{ needs.changes.outputs.dotcms-webcomponents == 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout core-web | |
run: | | |
git clone https://victoralfaro-dotcms:${{ secrets.CICD_GITHUB_TOKEN }}@github.com/dotcms/core-web | |
cd core-web | |
git pull | |
cd .. | |
- name: Configuring Node.js | |
uses: actions/setup-node@v2-beta | |
with: | |
node-version: '16.13.2' | |
- name: Installing dependencies | |
run: | | |
# Get Branch Name | |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
branchName="${{ github.head_ref }}" | |
else | |
branchName=$(basename "${{ github.ref }}") | |
fi | |
cd core-web | |
if [[ "$branchName" != 'master' ]]; then | |
git checkout -b $branchName --track origin/$branchName | |
fi | |
npm install | |
- name: Version Bump - dotcms-webcomponents - 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 | |
# Checks if branch is release or master | |
if [[ $branchName == *master* ]]; then | |
preReleaseTag=next | |
elif [[ $branchName == *release* ]]; then | |
preReleaseTag=rc | |
fi | |
cd core-web | |
# Get version from package.json | |
cd libs/dotcms-webcomponents | |
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 "victor.alfaro@dotcms.com" | |
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-web | |
- name: Build dotcms-webcomponents with deps | |
run: | | |
cd core-web | |
npm run nx build dotcms-ui -- --with-deps --prod | |
- name: 'publish to npm' | |
run: | | |
cd core-web | |
npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }} | |
cd dist/libs/dotcms-webcomponents | |
if [[ $(basename "${{ github.ref }}") =~ ^release-.* ]]; then | |
npm publish --tag rc | |
fi | |
if [[ $(basename "${{ github.ref }}") =~ ^master ]]; then | |
npm publish --tag next | |
fi |