Files
alfresco-content-app/.github/actions/publish-libs/action.yml
2023-03-07 12:39:17 +00:00

120 lines
3.7 KiB
YAML

name: "Publish ACA libs to NPM and GH registry"
description: "Publish ACA libs to NPM and GH registry"
inputs:
branch_name:
description: 'Name of the branch the workflow runs on'
required: true
type: string
github_token:
description: 'Github token'
required: true
type: string
npm_registry_address:
description: 'NPM registry address'
required: true
type: string
npm_registry_token:
description: 'NPM registry token'
required: true
type: string
npm_tag:
description: 'NPM tag'
required: true
type: string
dry-run:
description: dry run flag
required: true
type: boolean
runs:
using: "composite"
steps:
- run: npm ci
shell: bash
- name: update libs version
shell: bash
run: |
export DIST_DIR=./dist/@alfresco
PROJECTS_DIR=./projects
VERSION_IN_PACKAGE_JSON=$(jq -cr '.version' < package.json)
if [[ ${{ inputs.branch_name }} =~ ^master.*?$ ]] ; then
NEW_LIBRARY_VERSION="$VERSION_IN_PACKAGE_JSON"
else
NEW_LIBRARY_VERSION="${VERSION_IN_PACKAGE_JSON}-${{ github.run_id }}"
fi
echo -e "Branch is '${{ inputs.branch_name }}, therefore publish with '${{ inputs.npm_tag }}' tag\n"
export PROJECTS=(
'aca-shared'
'aca-folder-rules'
'adf-office-services-ext'
'aca-about'
'aca-preview'
'aca-viewer'
'aca-content'
);
for PROJECT in ${PROJECTS[@]}
do
echo "Update \"$PROJECT\" to version \"$NEW_LIBRARY_VERSION\""
if [[ "${{ inputs.dry-run }}" != "true" ]]; then
(cd $PROJECTS_DIR/${PROJECT} && npm version --allow-same-version --no-git-tag-version --force "$NEW_LIBRARY_VERSION")
fi
done
echo -e "\n\nBuild projects"
npm run build-libs
- uses: actions/setup-node@v3
name: setup GH registry
with:
node-version-file: '.nvmrc'
registry-url: 'https://npm.pkg.github.com'
scope: '@alfresco'
- name: publish tag to GH registry
shell: bash
run: |
for PROJECT in ${PROJECTS[@]}
do
cd $DIST_DIR/${PROJECT}
if [[ "${{ inputs.dry-run }}" != "true" ]]; then
echo -e "Publish with dry mode for project to GH registry: $PROJECT\n"
echo -e "npm publish --dry-run --tag ${{ inputs.npm_tag }} \n"
npm publish --dry-run --tag ${{ inputs.npm_tag }}
else
echo -e "======== Publishing project to GH registry: $PROJECT ========\n"
echo -e "npm publish --tag ${{ inputs.npm_tag }}\n"
npm publish --tag ${{ inputs.npm_tag }}
fi
done
env:
NODE_AUTH_TOKEN: ${{ inputs.github_token }}
- uses: actions/setup-node@v3
name: setup NPM registry
with:
node-version-file: '.nvmrc'
registry-url: ${{ inputs.npm_registry_address }}
scope: '@alfresco'
- name: publish tag to NPM registry
shell: bash
run: |
for PROJECT in ${PROJECTS[@]}
do
cd $DIST_DIR/${PROJECT}
if [[ "${{ inputs.dry-run }}" != "true" ]]; then
echo -e "Publish with dry mode for project to NPM registry: $PROJECT\n"
echo -e "npm publish --dry-run --tag ${{ inputs.npm_tag }} \n"
npm publish --dry-run --tag ${{ inputs.npm_tag }}
else
echo -e "======== Publishing project to NPM registry: $PROJECT ========\n"
echo -e "npm publish --tag ${{ inputs.npm_tag }}\n"
npm publish --tag ${{ inputs.npm_tag }}
fi
done
env:
NODE_AUTH_TOKEN: ${{ inputs.npm_registry_token }}