Files
Umbraco-CMS/src/Umbraco.Web.UI.Client/.github/workflows/npm-publish-github-packages.yml
Jacob Overgaard fa60e6afda add ref to inputs
2023-10-02 10:16:19 +02:00

79 lines
2.3 KiB
YAML

# This workflow will publish the @umbraco-cms/backoffice package to npmjs.com
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
# The @umbraco-cms scope is owned by Umbraco HQ
name: Node.js Package
on:
push:
branches: [main]
paths:
- 'src/**'
- 'devops/publish/**'
- 'package.json'
- 'package-lock.json'
- 'tsconfig.json'
- 'staticwebapp.config.json'
- 'README.md'
workflow_dispatch:
inputs:
ref:
description: Branch or tag or SHA to publish
required: false
version:
description: 'Version to publish'
required: false
tag:
description: 'Tag to publish'
required: false
type: choice
options:
- 'next'
- 'latest'
- 'preview'
env:
NODE_OPTIONS: --max-old-space-size=16384
jobs:
build_publish:
name: Build and publish
runs-on: ubuntu-latest
concurrency:
group: npm-publish
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
registry-url: https://registry.npmjs.org/
scope: '@umbraco-cms'
- run: npm ci
- run: npm run build:for:npm
- name: Calculate version
id: calculate_version
run: |
if [ -z "${{inputs.version}}" ]; then
echo "No version input, calculating version from package.json"
SHA_SHORT=$(echo $GITHUB_SHA | cut -c1-8)
VERSION=$(node -p "require('./package.json').version")-$SHA_SHORT
echo "Version: $VERSION"
echo "::set-output name=version::$VERSION"
else
echo "Version input found, using ${{inputs.version}}"
echo "::set-output name=version::${{inputs.version}}"
fi
- name: Publish
run: |
npm whoami
npm version $VERSION --allow-same-version --no-git-tag-version
npm publish --tag $BACKOFFICE_NPM_TAG --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
BACKOFFICE_VERSION: ${{ steps.calculate_version.outputs.version }}
BACKOFFICE_NPM_TAG: ${{ inputs.tag || 'next' }}