Repository navigation
build(Felt): migrate tasks and prereleases to Nx #12687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gabipodolnikova
wants to merge
7
commits into
patternfly:felt-v1
Choose a base branch
from
gabipodolnikova:FELT-144-nx-release-spike
base: felt-v1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,867
−96
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a9fe086
build(Felt): migrate task execution to Nx
gabipodolnikova a1d426f
ci(Felt): switch prerelease workflow to Nx
gabipodolnikova 60d8c87
Merge felt-v1 and refresh lockfile for Yarn 4.18.1
gabipodolnikova 5bc0560
ci(Felt): run release tests in pull request checks
gabipodolnikova 8a83d53
ci(Felt): align docs and chore release policy
gabipodolnikova 1f4b85f
ci(Felt): hide CI changes from release notes
gabipodolnikova fe8ba91
ci(Felt): align release Git identity with Core
gabipodolnikova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| if [[ ! -f .release/release.json ]]; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| GH_REPO=${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is required} | ||
| RELEASE_COMMIT=$(node -p "require('./.release/release.json').sourceCommit") | ||
| PR_NUM=$(git log -1 --format="%s" "${RELEASE_COMMIT}^" | grep -Poe '#\d+' | tr -d '#') || true | ||
|
|
||
| if [[ -z "${PR_NUM}" ]]; then | ||
| echo "No pull request number found in the merged commit; skipping release comment." | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [[ -z "${GH_PR_TOKEN:-}" ]]; then | ||
| echo "GH_PR_TOKEN is required to comment on the pull request." | ||
| exit 1 | ||
| fi | ||
|
|
||
| PAYLOAD=$(node --input-type=module -e ' | ||
| import { readFileSync } from "node:fs"; | ||
| const release = JSON.parse(readFileSync(".release/release.json", "utf8")); | ||
| const versions = release.projects.map((name) => `${name}@${release.versionData[name].newVersion}`).join(", "); | ||
| const url = `https://github.com/${process.env.GITHUB_REPOSITORY}/commit/${release.sourceCommit}`; | ||
| process.stdout.write(JSON.stringify({ body: `Your changes have been released in: ${url}\n\n${versions}\n\nThanks for your contribution! :tada:` })); | ||
| ') | ||
|
|
||
| COMMENTS_URL="https://api.github.com/repos/${GH_REPO}/issues/${PR_NUM}/comments" | ||
| echo "Adding release comment to PR #${PR_NUM}" | ||
| curl --fail-with-body -H "Authorization: token ${GH_PR_TOKEN}" -H "Accept: application/vnd.github+json" \ | ||
| --request POST "${COMMENTS_URL}" --data "${PAYLOAD}" |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,48 +1,22 @@ | ||
| #!/bin/bash | ||
| GIT_USERNAME="patternfly-build" | ||
| GH_REPO=${GITHUB_REPOSITORY} | ||
| REPO="github.com/${GH_REPO}" | ||
| echo "Preparing release environment..." | ||
| git config user.email "[email protected]" | ||
| git config user.name ${GIT_USERNAME} | ||
| set -euo pipefail | ||
|
|
||
| echo "Doing a release..." | ||
| # 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 | ||
| GIT_USERNAME="Patternfly CI/CD" | ||
| echo "Preparing release environment..." | ||
| git config user.email "[email protected]" | ||
| git config user.name "${GIT_USERNAME}" | ||
|
|
||
| # Grab the log before lerna makes a commit | ||
| LOG=$(git log --format="%s" -1 | grep -Poe "#\d+") | ||
| PR_NUM=${LOG:1} | ||
| echo "Preparing the Nx release..." | ||
| yarn release:nx --ci-prepare | ||
|
|
||
| if ! ( | ||
| set -o pipefail | ||
| yarn run lerna publish prerelease --preid=prerelease --dist-tag=prerelease --yes 2>&1 | tee lerna-output.txt | ||
| ); then | ||
| echo "Failed lerna publish" | ||
| exit 1 | ||
| if [[ ! -f .release/release.json ]]; then | ||
| echo "No changed Felt packages to publish." | ||
| if [[ -n "${GITHUB_OUTPUT:-}" ]]; then | ||
| echo "prepared=false" >> "${GITHUB_OUTPUT}" | ||
| fi | ||
| exit 0 | ||
| fi | ||
|
|
||
| # use lerna command below for dry run | ||
| # yarn run lerna version prerelease --preid=prerelease --dist-tag=prerelease --yes --no-git-tag-version --no-push | tee lerna-output.txt | ||
|
|
||
| if grep -i "Successfully published" lerna-output.txt; # Leave a Github comment | ||
| then | ||
| if [ -n "${PR_NUM}" ] | ||
| then | ||
| # Use Issues api instead of PR api because | ||
| # PR api requires comments be made on specific files of specific commits | ||
| GH_PR_COMMENTS="https://api.github.com/repos/${GH_REPO}/issues/${PR_NUM}/comments" | ||
| COMMENT=$(git log --author="patternfly-build" -1 --pretty=%B | tail -n +2 | python -c 'import json,sys; print(json.dumps(sys.stdin.read()))' | cut -d '"' -f 2) | ||
| JSON="{\"body\":\"Your changes have been released in: ${COMMENT}Thanks for your contribution! :tada:\"}" | ||
| echo "Adding github PR comment ${GH_PR_COMMENTS} ${JSON}" | ||
| curl -H "Authorization: token ${GH_PR_TOKEN}" --request POST "${GH_PR_COMMENTS}" --data "${JSON}" | ||
| fi | ||
| elif grep -i "No changed packages to publish" lerna-output.txt; | ||
| then | ||
| echo "No changed packages to publish" | ||
| else | ||
| echo "Failed lerna publish" | ||
| exit 1 | ||
| if [[ -n "${GITHUB_OUTPUT:-}" ]]; then | ||
| echo "prepared=true" >> "${GITHUB_OUTPUT}" | ||
| fi |
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,27 +3,36 @@ on: | |
| push: | ||
| branches: | ||
| - felt-v1 | ||
| workflow_dispatch: | ||
| inputs: | ||
| publish-only-run-id: | ||
| description: Failed release workflow run ID to recover from | ||
| required: true | ||
| type: string | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| group: ${{ github.workflow }}-felt-v1 | ||
| cancel-in-progress: false | ||
| jobs: | ||
| ci: | ||
| name: CI | ||
| if: github.event_name == 'push' | ||
| uses: ./.github/workflows/main.yml | ||
|
|
||
| docs: | ||
| name: Documentation | ||
| if: github.event_name == 'push' | ||
| uses: ./.github/workflows/documentation.yml | ||
| with: | ||
| is-release: true | ||
| secrets: inherit | ||
|
|
||
| deploy: | ||
| name: Deploy release | ||
| if: github.event_name == 'push' | ||
| runs-on: ubuntu-latest | ||
| needs: [ci, docs] | ||
| permissions: | ||
| contents: read | ||
| contents: write | ||
| id-token: write | ||
| steps: | ||
| - name: Check out project | ||
|
|
@@ -45,7 +54,90 @@ jobs: | |
| node --version | ||
| npm --version | ||
|
|
||
| - name: Deploy to NPM and Github | ||
| - name: Prepare release commit, tags, and packages | ||
| id: prepare | ||
| run: .github/release.sh | ||
|
|
||
| - name: Preserve prepared release packages for recovery | ||
| if: steps.prepare.outputs.prepared == 'true' | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: nx-release-packages | ||
| path: .release/ | ||
| include-hidden-files: true | ||
| if-no-files-found: error | ||
| retention-days: 30 | ||
|
|
||
| - name: Publish prepared release packages | ||
| if: steps.prepare.outputs.prepared == 'true' | ||
| run: yarn release:nx --publish-only | ||
|
|
||
| - name: Comment on the merged pull request | ||
| id: comment | ||
| if: steps.prepare.outputs.prepared == 'true' | ||
| continue-on-error: true | ||
| run: .github/release-comment.sh | ||
| env: | ||
| GH_PR_TOKEN: ${{ secrets.GH_PR_TOKEN }} | ||
|
|
||
| - name: Report notification failure | ||
| if: steps.comment.outcome == 'failure' | ||
| run: echo "::warning::Packages were published successfully, but the release PR comment failed. Do not rerun publication to retry the comment." | ||
|
|
||
| recover-publish: | ||
| name: Recover release publication | ||
| if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/felt-v1' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| 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 release packages | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: nx-release-packages | ||
| run-id: ${{ inputs.publish-only-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 [email protected] | ||
| node --version | ||
| npm --version | ||
|
|
||
| - name: Publish the prepared packages | ||
| run: yarn release:nx --publish-only | ||
|
|
||
| - name: Comment on the merged pull request | ||
| id: comment | ||
| continue-on-error: true | ||
| run: .github/release-comment.sh | ||
| env: | ||
| GH_PR_TOKEN: ${{ secrets.GH_PR_TOKEN }} | ||
|
|
||
| - name: Report notification failure | ||
| if: steps.comment.outcome == 'failure' | ||
| run: echo "::warning::Packages were published successfully, but the release PR comment failed. Do not rerun publication to retry the comment." | ||
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| { | ||
| "$schema": "./node_modules/nx/schemas/nx-schema.json", | ||
| "defaultBase": "felt-v1", | ||
| "parallel": 12, | ||
| "pluginsConfig": { | ||
| "@nx/js": { | ||
| "analyzeSourceFiles": false | ||
| } | ||
| }, | ||
| "release": { | ||
| "projects": [ | ||
| "@rh-felt/react-charts", | ||
| "@rh-felt/react-code-editor", | ||
| "@rh-felt/react-core", | ||
| "@rh-felt/react-docs", | ||
| "@rh-felt/react-drag-drop", | ||
| "@rh-felt/react-icons", | ||
| "@rh-felt/react-styles", | ||
| "@rh-felt/react-table", | ||
| "@rh-felt/react-templates", | ||
| "@rh-felt/react-tokens" | ||
| ], | ||
| "projectsRelationship": "independent", | ||
| "releaseTag": { | ||
| "pattern": "{projectName}@{version}", | ||
| "strictPreid": false, | ||
| "checkAllBranchesWhen": false | ||
| }, | ||
| "version": { | ||
| "specifierSource": "conventional-commits", | ||
| "currentVersionResolver": "git-tag", | ||
| "preserveLocalDependencyProtocols": true, | ||
| "updateDependents": "always", | ||
| "applyPreidToDependents": true | ||
| }, | ||
| "conventionalCommits": { | ||
| "useCommitScope": false, | ||
| "types": { | ||
| "docs": { "semverBump": "patch", "changelog": false }, | ||
| "chore": { "semverBump": "none", "changelog": false }, | ||
| "refactor": { "semverBump": "patch" }, | ||
| "perf": { "semverBump": "patch" }, | ||
| "test": { "semverBump": "patch" }, | ||
| "style": { "semverBump": "patch" }, | ||
| "build": { "semverBump": "patch" }, | ||
| "ci": { "semverBump": "patch", "changelog": false } | ||
| } | ||
| }, | ||
| "changelog": { | ||
| "workspaceChangelog": false, | ||
| "projectChangelogs": true | ||
| }, | ||
| "git": { | ||
| "commitMessage": "chore(release): releasing packages [ci skip]", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need the message if we are not committing anything? |
||
| "commit": false, | ||
| "stageChanges": false, | ||
| "tag": false, | ||
| "push": false | ||
| } | ||
| }, | ||
| "targetDefaults": { | ||
| "nx-release-publish": { | ||
| "cache": false, | ||
| "options": { | ||
| "packageRoot": ".release/packages/{projectName}", | ||
| "access": "public", | ||
| "tag": "prerelease" | ||
| } | ||
| }, | ||
| "clean": { | ||
| "cache": false | ||
| }, | ||
| "generate": { | ||
| "cache": false | ||
| }, | ||
| "subpaths": { | ||
| "cache": false | ||
| }, | ||
| "build:umd": { | ||
| "cache": false | ||
| }, | ||
| "build:single:packages": { | ||
| "cache": false, | ||
| "dependsOn": ["^build:single:packages"] | ||
| }, | ||
| "build": { | ||
| "cache": false, | ||
| "dependsOn": ["^build"] | ||
| }, | ||
| "preview": { | ||
| "cache": false | ||
| }, | ||
| "dev": { | ||
| "cache": false | ||
| }, | ||
| "cypress:open": { | ||
| "cache": false | ||
| }, | ||
| "test:a11y": { | ||
| "cache": false | ||
| } | ||
| }, | ||
| "analytics": false | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirming these are ok @kmcfaul @wise-king-sullyman?