Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions .github/promote.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
#!/bin/bash
set -euo pipefail

GIT_USERNAME="Patternfly CI/CD"
GH_REPO=${GITHUB_REPOSITORY}
REPO="github.com/${GH_REPO}"
echo "Preparing release environment..."
echo "Preparing promotion environment..."
git config user.email "patternfly-ci@redhat.com"
git config user.name "${GIT_USERNAME}"
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc

# Lerna is complicated. Commands: https://github.com/lerna/lerna/tree/master/commands
# Identify packages that have been updated since the previous tagged release
# Update their versions and changelogs according to angular commit guidelines
# https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit

#if [[ ! -z "${PATTERNFLY_VERSION}" ]]; then
# echo "Updating to @patternfly/patternfly: ${PATTERNFLY_VERSION}"
# npm pkg set dependencies.@patternfly/patternfly=${PATTERNFLY_VERSION} --workspace @rh-felt/react-docs
# npm pkg set devDependencies.@patternfly/patternfly=${PATTERNFLY_VERSION} --workspace @rh-felt/react-core --workspace @rh-felt/react-styles --workspace @rh-felt/react-tokens --workspace @rh-felt/react-icons
#if [[ ! -z "${STYLES_VERSION}" ]]; then
# echo "Updating to @rh-felt/styles: ${STYLES_VERSION}"
# npm pkg set dependencies.@rh-felt/styles=${STYLES_VERSION} --workspace @rh-felt/react-docs
# npm pkg set dependencies.@patternfly/patternfly=npm:@rh-felt/styles@${STYLES_VERSION} --workspace @rh-felt/react-docs
# npm pkg set devDependencies.@rh-felt/styles=${STYLES_VERSION} --workspace @rh-felt/react-core --workspace @rh-felt/react-styles --workspace @rh-felt/react-tokens --workspace @rh-felt/react-icons
#fi

# publish to npm
# yarn run lerna publish --conventional-commits --conventional-graduate --no-private --dist-tag=latest --yes

# immediately after promote - set up repo for next prerelease
yarn run lerna version preminor --force-publish --conventional-commits --no-private --yes --preid prerelease
if [[ "${PROMOTE_MODE:-cycle}" == "graduate" ]]; then
# Stable graduation: apply the chosen stable version to every public package,
# commit, tag, push, and pack artifacts for the publish job (npm latest tag).
yarn release:nx --ci-graduate --version="${STABLE_VERSION}"
echo "prepared=true" >> "${GITHUB_OUTPUT:-/dev/null}"
else
# Start the next prerelease cycle for every public package (Lerna's preminor
# promote: 0.0.1-prerelease.7 -> 0.1.0-prerelease.0). This commits, tags, and
# pushes, but never packs or publishes.
yarn release:nx --ci-promote
echo "prepared=false" >> "${GITHUB_OUTPUT:-/dev/null}"
fi

# dry run
# yarn run lerna version --conventional-commits --conventional-graduate --no-private --yes --no-git-tag-version --no-push
# dry runs
# yarn release:nx --ci-promote --dry-run
# yarn release:nx --ci-graduate --version=0.1.0 --dry-run
113 changes: 106 additions & 7 deletions .github/workflows/promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,40 @@ name: Promote
on:
workflow_dispatch:
inputs:
patternfly-version:
description: The version of PatternFly (`@patternfly/patternfly`) to promote to.
mode:
description: Whether to start the next prerelease cycle or graduate to a stable release.
required: true
type: choice
default: cycle
options:
- cycle
- graduate
version:
description: The stable version to graduate to (required for graduate mode, e.g. 0.1.0).
required: false
type: string
publish-only-run-id:
description: Failed graduate workflow run ID to recover publication from.
required: false
type: string
styles-version:
description: The version of the Felt styles package (`@rh-felt/styles`) to promote to.
required: false
type: string
permissions:
# Preparation only creates the release commit and tags. The publish job below
# adds the OIDC token for npm trusted publishing; this job never receives it.
contents: write
concurrency:
group: ${{ github.workflow }}-felt-v1
cancel-in-progress: false
jobs:
deploy:
prepare:
name: Prepare promotion
if: inputs.publish-only-run-id == ''
runs-on: ubuntu-latest
outputs:
prepared: ${{ steps.promote.outputs.prepared }}
steps:
- name: Check out project
uses: actions/checkout@v4
Expand All @@ -17,13 +45,84 @@ jobs:
# Pass in an administrator token to get around branch protection.
token: ${{ secrets.GH_TOKEN_REDALLEN }}

- name: Set up and build project
- name: Set up project
uses: ./.github/actions/setup-project
with:
# Graduation packs release artifacts and therefore needs build output;
# starting the next prerelease cycle only versions and tags.
skip-build: ${{ inputs.mode != 'graduate' }}
skip-build-cache: true

- name: Deploy to NPM and Github
- name: Run promotion
id: promote
run: .github/promote.sh
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
PATTERNFLY_VERSION: ${{ github.event.inputs.patternfly-version }}
PROMOTE_MODE: ${{ inputs.mode }}
STABLE_VERSION: ${{ inputs.version }}
STYLES_VERSION: ${{ inputs.styles-version }}

- name: Preserve prepared stable packages for publishing and recovery
if: steps.promote.outputs.prepared == 'true'
uses: actions/upload-artifact@v4
with:
name: nx-promote-packages
path: .release/
include-hidden-files: true
if-no-files-found: error
retention-days: 30

publish:
name: Publish stable release
needs: prepare
if: >
!cancelled() &&
((inputs.mode == 'graduate' && needs.prepare.outputs.prepared == 'true') ||
(inputs.publish-only-run-id != '' && github.ref == 'refs/heads/felt-v1'))
runs-on: ubuntu-latest
permissions:
# This job installs dependencies and runs repository code, so it only
# receives the npm trusted-publishing OIDC token and read access. It never
# pushes and is reused unchanged for manual publication recovery.
contents: read
id-token: write
steps:
- name: Check out project
uses: actions/checkout@v4
with:
ref: felt-v1
fetch-depth: 0
token: ${{ secrets.GH_TOKEN_REDALLEN }}

- name: Download prepared stable packages
uses: actions/download-artifact@v4
with:
name: nx-promote-packages
# Normal graduations publish the artifact of this run; manual recovery
# reuses the artifact of the failed run passed as an input.
run-id: ${{ inputs.publish-only-run-id || github.run_id }}
github-token: ${{ secrets.GH_TOKEN_REDALLEN }}
path: .release

- name: Check out the original release commit
shell: bash
run: |
SOURCE_COMMIT=$(node -p "require('./.release/release.json').sourceCommit")
if [[ ! "${SOURCE_COMMIT}" =~ ^[0-9a-f]{40}$ ]]; then
echo "Invalid source commit in release artifact: ${SOURCE_COMMIT}"
exit 1
fi
git checkout "${SOURCE_COMMIT}"

- name: Install dependencies without rebuilding release packages
uses: ./.github/actions/setup-project
with:
skip-build: true

- name: Set up npm for trusted publishing
run: |
npm install --global npm@11.21.1
node --version
npm --version

- name: Publish the prepared packages
run: yarn release:nx --publish-only
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ node_modules
dist
tsc_out
.out
.changelog
.DS_Store
coverage
.cache
Expand All @@ -13,7 +12,6 @@ package-lock.json

# package managers
yarn-error.log
lerna-debug.log

# IDEs and editors
.idea
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ Ensure no lint errors are introduced in `yarn-error.log` after running this comm

***Note to Windows users:*** you may need to change the path for the lint script in package.json to be `node_modules/eslint/bin/eslint`

4. **Follow commit conventions** - This project uses [`lerna`](https://lernajs.io/) to do automatic releases and generate a changelog based on the commit history. So we follow [conventional commit formatting](https://www.conventionalcommits.org/en/v1.0.0/) for all commit messages. Please follow this convention for your commit messages.
4. **Follow commit conventions** - This project uses [`nx release`](https://nx.dev/features/manage-releases) to do automatic releases and generate a changelog based on the commit history. So we follow [conventional commit formatting](https://www.conventionalcommits.org/en/v1.0.0/) for all commit messages. Please follow this convention for your commit messages.

5. **Create a pull request**

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Felt React

[![lerna](https://img.shields.io/badge/maintained%20with-lerna-green.svg?style=for-the-badge)](https://lernajs.io/)
[![nx](https://img.shields.io/badge/maintained%20with-nx-green.svg?style=for-the-badge)](https://nx.dev/)
[![Felt npm badge](https://img.shields.io/npm/v/@rh-felt/react-core.svg?label=PF%20Core&style=for-the-badge)](https://www.npmjs.com/package/@rh-felt/react-core)

This project provides a set of React components for the [Felt project](https://patternfly.org).
Expand Down
30 changes: 0 additions & 30 deletions lerna.json

This file was deleted.

3 changes: 2 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"currentVersionResolver": "git-tag",
"preserveLocalDependencyProtocols": true,
"updateDependents": "always",
"applyPreidToDependents": true
"applyPreidToDependents": true,
"adjustSemverBumpsForZeroMajorVersion": false
},
"conventionalCommits": {
"useCommitScope": false,
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@rh-felt/react-lerna-root",
"name": "@rh-felt/react-root",
"private": true,
"version": "0.0.0",
"description": "This library provides a set of common React components for use with the Felt reference implementation.",
Expand Down Expand Up @@ -63,7 +63,6 @@
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-transform-stub": "^2.0.0",
"lerna": "^9.0.7",
"lint-staged": "^15.5.2",
"mutation-observer": "^1.0.3",
"nx": "24.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-core/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Ensure no lint errors are introduced in `yarn-error.log` after running this comm

5. Add a commit using `git commit`:

This project uses [`lerna`](https://lerna.js.io/) to do automatic releases and generate a changelog based on the commit history. So we follow [a convention][3] for commit messages. Please follow [`this convention`](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#type) for your commit messages.
This project uses [`nx release`](https://nx.dev/features/manage-releases) to do automatic releases and generate a changelog based on the commit history. So we follow [a convention][3] for commit messages. Please follow [`this convention`](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#type) for your commit messages.

Once you are ready to commit the changes, please use the below commands:

Expand Down
2 changes: 1 addition & 1 deletion packages/react-core/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PatternFly React - Core

[![lerna](https://img.shields.io/badge/maintained%20with-lerna-green.svg?style=for-the-badge)](https://lernajs.io/)
[![nx](https://img.shields.io/badge/maintained%20with-nx-green.svg?style=for-the-badge)](https://nx.dev/)
[![PatternFly npm badge](https://img.shields.io/npm/v/@rh-felt/react-core.svg?label=React-Core&style=for-the-badge)](https://www.npmjs.com/package/@rh-felt/react-core)

This project provides the React core components for the [PatternFly project](https://patternfly.org).
Expand Down
Loading
Loading