Repository navigation
build(CI): prepare Promote for npm trusted publishing #12695
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
2
commits into
patternfly:main
Choose a base branch
from
gabipodolnikova:FELT-143-promote-trusted-publishing
base: main
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,112
−1,327
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,12 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| 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} | ||
| 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 | ||
|
|
@@ -27,4 +28,3 @@ yarn run lerna version preminor --force-publish --conventional-commits --no-priv | |
| # dry run | ||
| # yarn run lerna version --conventional-commits --conventional-graduate --no-private --yes --no-git-tag-version --no-push | ||
|
|
||
|
|
||
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 |
|---|---|---|
|
|
@@ -5,7 +5,6 @@ REPO="github.com/${GH_REPO}" | |
| echo "Preparing release environment..." | ||
| git config user.email "[email protected]" | ||
| git config user.name ${GIT_USERNAME} | ||
| echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc | ||
|
|
||
| echo "Doing a release..." | ||
| # Lerna is complicated. Commands: https://github.com/lerna/lerna/tree/master/commands | ||
|
|
@@ -17,7 +16,13 @@ echo "Doing a release..." | |
| LOG=$(git log --format="%s" -1 | grep -Poe "#\d+") | ||
| PR_NUM=${LOG:1} | ||
|
|
||
| yarn run lerna publish prerelease --preid=prerelease --dist-tag=prerelease --yes 2>&1 | tee lerna-output.txt | ||
| 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 | ||
| fi | ||
|
|
||
| # use lerna command below for dry run | ||
| #yarn run lerna version prerelease --preid=prerelease --yes --no-git-tag-version --no-push | tee lerna-output.txt | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -8,6 +8,9 @@ on: | |
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| steps: | ||
| - name: Check out project | ||
| uses: actions/checkout@v4 | ||
|
|
@@ -22,8 +25,13 @@ jobs: | |
| with: | ||
| skip-build-cache: true | ||
|
|
||
| - name: Set up npm for trusted publishing | ||
| run: | | ||
| npm install --global [email protected] | ||
| node --version | ||
| npm --version | ||
|
|
||
| - name: Deploy to NPM and Github | ||
| run: .github/promote.sh | ||
| env: | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| PATTERNFLY_VERSION: ${{ github.event.inputs.patternfly-version }} | ||
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 |
|---|---|---|
|
|
@@ -22,6 +22,9 @@ jobs: | |
| name: Deploy release | ||
| runs-on: ubuntu-latest | ||
| needs: [ci, docs] | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| steps: | ||
| - name: Check out project | ||
| uses: actions/checkout@v4 | ||
|
|
@@ -36,9 +39,13 @@ jobs: | |
| with: | ||
| skip-build-cache: true | ||
|
|
||
| - name: Set up npm for trusted publishing | ||
| run: | | ||
| npm install --global [email protected] | ||
| node --version | ||
| npm --version | ||
|
|
||
| - name: Deploy to NPM and Github | ||
| run: .github/release.sh | ||
| env: | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| GH_PR_TOKEN: ${{ secrets.GH_PR_TOKEN }} | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -32,3 +32,6 @@ lerna-debug.log | |
| # For vim | ||
| *.swp | ||
| .yarn | ||
|
|
||
| # Lerna's generated Nx workspace state and cache | ||
| /.nx/ | ||
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
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.
Keep npm publishing permission out of dependency installation.
If a compromised dependency runs a lifecycle script during
setup-project’syarn install --immutable, it can request an OIDC token before.github/release.shstarts. With a trusted publisher configured forrelease.yml, that code can use the workflow’s publishing identity. The same job-level exposure exists inpromote.ymlwhen its trusted publisher is configured. Install and build in a job withoutid-token: write, then grant the permission to an isolated publishing job. GitHub makes OIDC requests available to steps in a permitted job, and npm accepts that identity for trusted publishing. (raw.githubusercontent.com)Based on learnings: flag dependency lifecycle scripts when OIDC-token access is available during installation.
zizmor (1.30.1)
[warning] 1-52: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
Source: Learnings