forked from react-native-webview/react-native-webview
-
Notifications
You must be signed in to change notification settings - Fork 6
ci: migrate npm publish to OIDC trusted publishing #83
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
14f1fc2
ci: migrate npm publish to OIDC trusted publishing
joaoloureirop ae18685
ci: enable Corepack before the Yarn cache step
joaoloureirop cec0986
Update package.json
joaoloureirop 00e09d7
ci: call publish-release from main via create-release-pr
joaoloureirop 5573a57
ci: disable Yarn lifecycle scripts via LavaMoat allow-scripts
joaoloureirop d1dc4d2
ci: run Android and iOS workflows on main
joaoloureirop 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: Create Release Pull Request | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| base-branch: | ||
| description: 'The base branch for git operations and the pull request.' | ||
| default: 'main' | ||
| required: true | ||
| release-type: | ||
| description: 'A SemVer version diff, i.e. major, minor, or patch. Mutually exclusive with "release-version".' | ||
| required: false | ||
| type: choice | ||
| options: | ||
| - '' | ||
| - major | ||
| - minor | ||
| - patch | ||
| release-version: | ||
| description: 'A specific version to bump to. Mutually exclusive with "release-type".' | ||
| required: false | ||
|
|
||
| jobs: | ||
| create-release-pr: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| steps: | ||
| - name: Checkout and setup environment | ||
| uses: MetaMask/action-checkout-and-setup@v3 | ||
| with: | ||
| is-high-risk-environment: true | ||
| persist-credentials: false | ||
| # This is to guarantee that the most recent tag is fetched. | ||
| fetch-depth: 0 | ||
| # We check out the specified branch, which will be used as the base | ||
| # branch for all git operations and the release PR. | ||
| ref: ${{ github.event.inputs.base-branch }} | ||
|
|
||
| - uses: MetaMask/action-create-release-pr@v5 | ||
| with: | ||
| release-type: ${{ github.event.inputs.release-type }} | ||
| release-version: ${{ github.event.inputs.release-version }} | ||
| formatter: 'prettier' | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_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
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,35 @@ | ||
| name: Main | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| is-release: | ||
| # Filtering by `push` events ensures that we only release from the `main` branch, which is a | ||
| # requirement for our npm publishing environment. | ||
| # The commit author should always be 'github-actions' for releases created by the | ||
| # 'create-release-pr' workflow, so we filter by that as well to prevent accidentally | ||
| # triggering a release. | ||
| if: github.event_name == 'push' && startsWith(github.event.head_commit.author.name, 'github-actions') | ||
| outputs: | ||
| IS_RELEASE: ${{ steps.is-release.outputs.IS_RELEASE }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: MetaMask/action-is-release@v2 | ||
| id: is-release | ||
|
|
||
| publish-release: | ||
| needs: is-release | ||
| if: needs.is-release.outputs.IS_RELEASE == 'true' | ||
| name: Publish release | ||
| permissions: | ||
| contents: write | ||
| id-token: write | ||
| uses: ./.github/workflows/publish-release.yml | ||
| secrets: | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
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,70 +1,113 @@ | ||
| name: Publish Release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| workflow_call: | ||
| secrets: | ||
| NPM_TOKEN: | ||
| required: false | ||
| SLACK_WEBHOOK_URL: | ||
| required: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| publish-release: | ||
| permissions: | ||
| contents: write | ||
| build: | ||
| name: Build | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout and setup environment | ||
| uses: MetaMask/action-checkout-and-setup@v1 | ||
| uses: MetaMask/action-checkout-and-setup@v3 | ||
| with: | ||
| is-high-risk-environment: true | ||
| - uses: MetaMask/action-publish-release@v3 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - run: yarn build | ||
| persist-credentials: false | ||
| ref: ${{ github.sha }} | ||
| # `prepare` also emits the type declarations into `lib`. Yarn 4 does not | ||
| # run it automatically at publish time, unlike Yarn 1. | ||
| - name: Build | ||
| run: yarn prepare | ||
| - name: Upload build artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: publish-release-artifacts-${{ github.sha }} | ||
| include-hidden-files: true | ||
| retention-days: 4 | ||
| include-hidden-files: true | ||
| path: | | ||
| ./packages/**/dist | ||
| ./node_modules/.yarn-integrity | ||
| ./lib | ||
| ./node_modules/.yarn-state.yml | ||
|
|
||
| publish-npm-dry-run: | ||
| needs: publish-release | ||
| name: Publish to NPM (dry run) | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout and setup environment | ||
| uses: MetaMask/action-checkout-and-setup@v1 | ||
| uses: MetaMask/action-checkout-and-setup@v3 | ||
| with: | ||
| is-high-risk-environment: true | ||
| persist-credentials: false | ||
| ref: ${{ github.sha }} | ||
| skip-install: true | ||
| - name: Restore build artifacts | ||
| uses: actions/download-artifact@v4 | ||
| uses: actions/download-artifact@v8 | ||
| with: | ||
| name: publish-release-artifacts-${{ github.sha }} | ||
| - name: Dry Run Publish | ||
| # omit npm-token token to perform dry run publish | ||
| uses: MetaMask/action-npm-publish@v5 | ||
| uses: MetaMask/action-npm-publish@v6 | ||
| with: | ||
| dry-run: true | ||
| slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
| subteam: S042S7RE4AE # @metamask-npm-publishers | ||
| env: | ||
| SKIP_PREPACK: true | ||
|
|
||
| publish-npm: | ||
| name: Publish to NPM | ||
| environment: npm-publish | ||
| runs-on: ubuntu-latest | ||
| needs: publish-npm-dry-run | ||
| runs-on: ubuntu-latest | ||
| environment: npm-publish | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| steps: | ||
| - name: Checkout and setup environment | ||
| uses: MetaMask/action-checkout-and-setup@v1 | ||
| uses: MetaMask/action-checkout-and-setup@v3 | ||
| with: | ||
| is-high-risk-environment: true | ||
| persist-credentials: false | ||
| ref: ${{ github.sha }} | ||
| skip-install: true | ||
| - name: Restore build artifacts | ||
| uses: actions/download-artifact@v4 | ||
| uses: actions/download-artifact@v8 | ||
| with: | ||
| name: publish-release-artifacts-${{ github.sha }} | ||
| - name: Publish to NPM | ||
| uses: MetaMask/action-npm-publish@v5 | ||
| - name: Publish | ||
| uses: MetaMask/action-npm-publish@v6 | ||
| with: | ||
| npm-token: ${{ secrets.NPM_TOKEN }} | ||
| dry-run: false | ||
| # This `NPM_TOKEN` needs to be manually set to publish a package for | ||
| # the first time only. | ||
| # Look in the repository settings under "Environments", and set this | ||
| # token in the `npm-publish` environment, and delete it after the | ||
| # initial publish. | ||
| npm-token: ${{ secrets.NPM_TOKEN }} | ||
| env: | ||
| SKIP_PREPACK: true | ||
|
|
||
| publish-release: | ||
| name: Publish to GitHub | ||
| needs: publish-npm | ||
| permissions: | ||
| contents: write | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout and setup environment | ||
| uses: MetaMask/action-checkout-and-setup@v3 | ||
| with: | ||
| is-high-risk-environment: true | ||
| persist-credentials: false | ||
| ref: ${{ github.sha }} | ||
| skip-install: true | ||
| - uses: MetaMask/action-publish-release@v3 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_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
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,9 @@ | ||
| /* eslint-disable */ | ||
| //prettier-ignore | ||
| module.exports = { | ||
| name: "@yarnpkg/plugin-allow-scripts", | ||
| factory: function (require) { | ||
| var plugin=(()=>{var l=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var p=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(o,e)=>(typeof require<"u"?require:o)[e]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var u=(t,o)=>{for(var e in o)l(t,e,{get:o[e],enumerable:!0})},f=(t,o,e,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of a(o))!c.call(t,i)&&i!==e&&l(t,i,{get:()=>o[i],enumerable:!(r=s(o,i))||r.enumerable});return t};var m=t=>f(l({},"__esModule",{value:!0}),t);var g={};u(g,{default:()=>d});var n=p("@yarnpkg/shell"),x={hooks:{afterAllInstalled:async()=>{let t=await(0,n.execute)("yarn run allow-scripts");t!==0&&process.exit(t)}}},d=x;return m(g);})(); | ||
| return plugin; | ||
| } | ||
| }; |
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.
Uh oh!
There was an error while loading. Please reload this page.