Promote release #102
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: Promote release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version to promote' | |
required: true | |
referenceBranch: | |
description: 'Branch to be updated after the promotion' | |
required: true | |
default: 'maintenance-3.1.x' | |
dryRun: | |
description: 'Run the workflow without pushing code or publishing artifacts' | |
type: boolean | |
required: false | |
jobs: | |
promote: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 14 | |
registry-url: 'https://packages.nuxeo.com/repository/npm-public/' | |
scope: '@nuxeo' | |
- uses: actions/checkout@v2 | |
with: | |
ref: v${{ github.event.inputs.version }} | |
- run: git config user.name "nuxeo-webui-jx-bot" && git config user.email "[email protected]" | |
- run: echo "VERSION=$(echo '${{ github.event.inputs.version }}' | sed -e 's/-rc.[0-9]*//')" >> $GITHUB_ENV | |
- name: Update Nuxeo Elements version to ${{ env.VERSION }} | |
run: | | |
npm version $VERSION --no-git-tag-version | |
npx lerna version $VERSION --no-push --force-publish --no-git-tag-version --yes | |
- name: Tag Nuxeo Elements v${{ env.VERSION }} | |
run: | | |
git commit -a -m "Release $VERSION" | |
git tag -a v$VERSION -m "Release $VERSION" | |
- if: ${{ github.event.inputs.dryRun == 'false' }} | |
run: git push origin v$VERSION | |
- name: Create Github release v${{ env.VERSION }} | |
if: ${{ github.event.inputs.dryRun == 'false' }} | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ env.VERSION }} | |
release_name: Release ${{ env.VERSION }} | |
- name: Publish to https://packages.nuxeo.com/repository/npm-public/ (dry run) | |
if: ${{ github.event.inputs.dryRun == 'true' }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_PACKAGES_TOKEN }} | |
run: | | |
npx lerna exec --ignore @nuxeo/nuxeo-elements-storybook -- npm publish --@nuxeo:registry=https://packages.nuxeo.com/repository/npm-public/ --dry-run | |
- name: Publish to https://packages.nuxeo.com/repository/npm-public/ | |
if: ${{ github.event.inputs.dryRun == 'false' }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_PACKAGES_TOKEN }} | |
run: | | |
npx lerna exec --ignore @nuxeo/nuxeo-elements-storybook -- npm publish --@nuxeo:registry=https://packages.nuxeo.com/repository/npm-public/ | |
- name: Publish to https://registry.npmjs.org (dry run) | |
if: ${{ github.event.inputs.dryRun == 'true' }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} | |
run: | | |
npx lerna exec --ignore @nuxeo/nuxeo-elements-storybook -- npm publish --@nuxeo:registry=https://registry.npmjs.org/ --access public --dry-run | |
- name: Publish to https://registry.npmjs.org | |
continue-on-error: true | |
if: ${{ github.event.inputs.dryRun == 'false' }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} | |
run: | | |
npx lerna exec --ignore @nuxeo/nuxeo-elements-storybook -- npm publish --@nuxeo:registry=https://registry.npmjs.org/ --access public | |
- uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.GIT_ADMIN_TOKEN }} | |
ref: ${{ github.event.inputs.referenceBranch }} | |
- if: ${{ github.event.inputs.referenceBranch == 'master' }} | |
run: echo "NEW_VERSION=$(npx semver -i minor $VERSION)-SNAPSHOT" >> $GITHUB_ENV | |
- if: ${{ github.event.inputs.referenceBranch != 'master' }} | |
run: echo "NEW_VERSION=$(npx semver -i patch $VERSION)-SNAPSHOT" >> $GITHUB_ENV | |
- name: Align ${{ github.event.inputs.referenceBranch }} branch on next version ${{ env.NEW_VERSION }} | |
run: | | |
npm version $NEW_VERSION --no-git-tag-version | |
npx lerna version $NEW_VERSION --no-push --force-publish --no-git-tag-version --yes | |
# commit and push | |
git commit -a -m "Update to $NEW_VERSION" | |
- if: ${{ github.event.inputs.dryRun == 'false' }} | |
run: git push origin ${{ github.event.inputs.referenceBranch }} |