Skip to content
This repository was archived by the owner on Oct 7, 2024. It is now read-only.

Commit b9a600a

Browse files
authored
Update module configuration (#230)
1 parent 07ba38a commit b9a600a

22 files changed

+2893
-1866
lines changed

.depcheckrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"ignores": [
33
"@lavamoat/allow-scripts",
4+
"@lavamoat/preinstall-always-fail",
45
"@metamask/auto-changelog",
56
"@types/*",
67
"prettier-plugin-packagejson",

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
yarn.lock linguist-generated=false
44

5-
65
# yarn v3
76
# See: https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
87
/.yarn/releases/** binary

.github/pull_request_template.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## Description
2+
3+
<!--
4+
Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes:
5+
6+
* What is the current state of things and why does it need to change?
7+
* What is the solution your changes offer and how does it work?
8+
* Are you introducing a breaking change (renaming, removing, or changing a part of a public-facing interface)?
9+
-->
10+
11+
## Changes
12+
13+
<!--
14+
Pretend that you're updating a changelog. How would you categorize your changes?
15+
16+
CATEGORY is one of:
17+
18+
- BREAKING
19+
- ADDED
20+
- CHANGED
21+
- DEPRECATED
22+
- REMOVED
23+
- FIXED
24+
25+
(Security-related changes should go through the Security Advisory process.)
26+
-->
27+
28+
- **<CATEGORY>**: Your change here
29+
- **<CATEGORY>**: Your change here
30+
- **<CATEGORY>**: Your change here
31+
32+
## References
33+
34+
<!--
35+
Are there any issues or other links that reviewers should consult to understand this pull request better? For instance:
36+
37+
* Fixes #12345
38+
* See: #67890
39+
-->
40+
41+
## Checklist
42+
43+
- [ ] I've updated the test suite for new or updated code as appropriate
44+
- [ ] I've updated documentation for new or updated code as appropriate (note: this will usually be JSDoc)
45+
- [ ] I've highlighted breaking changes using the "BREAKING" category above as appropriate

.github/workflows/build-lint-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- prepare
2525
strategy:
2626
matrix:
27-
node-version: [14.x, 16.x, 18.x, 19.x]
27+
node-version: [14.x, 16.x, 18.x, 20.x]
2828
steps:
2929
- uses: actions/checkout@v3
3030
- name: Use Node.js ${{ matrix.node-version }}
@@ -49,7 +49,7 @@ jobs:
4949
- prepare
5050
strategy:
5151
matrix:
52-
node-version: [14.x, 16.x, 18.x, 19.x]
52+
node-version: [14.x, 16.x, 18.x, 20.x]
5353
steps:
5454
- uses: actions/checkout@v3
5555
- name: Use Node.js ${{ matrix.node-version }}
@@ -80,7 +80,7 @@ jobs:
8080
- prepare
8181
strategy:
8282
matrix:
83-
node-version: [14.x, 16.x, 18.x, 19.x]
83+
node-version: [14.x, 16.x, 18.x, 20.x]
8484
steps:
8585
- uses: actions/checkout@v3
8686
- name: Use Node.js ${{ matrix.node-version }}

.github/workflows/create-release-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
default: 'main'
99
required: true
1010
release-type:
11-
description: 'A SemVer version diff, i.e. major, minor, patch, prerelease etc. Mutually exclusive with "release-version".'
11+
description: 'A SemVer version diff, i.e. major, minor, or patch. Mutually exclusive with "release-version".'
1212
required: false
1313
release-version:
1414
description: 'A specific version to bump to. Mutually exclusive with "release-type".'

.github/workflows/main.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
name: All jobs completed
2828
runs-on: ubuntu-latest
2929
needs:
30+
- check-workflows
3031
- build-lint-test
3132
outputs:
3233
PASSED: ${{ steps.set-output.outputs.PASSED }}
@@ -47,3 +48,30 @@ jobs:
4748
if [[ $passed != "true" ]]; then
4849
exit 1
4950
fi
51+
52+
is-release:
53+
# Filtering by `push` events ensures that we only release from the `main` branch, which is a
54+
# requirement for our npm publishing environment.
55+
# The commit author should always be 'github-actions' for releases created by the
56+
# 'create-release-pr' workflow, so we filter by that as well to prevent accidentally
57+
# triggering a release.
58+
if: github.event_name == 'push' && startsWith(github.event.head_commit.author.name, 'github-actions')
59+
needs: all-jobs-pass
60+
outputs:
61+
IS_RELEASE: ${{ steps.is-release.outputs.IS_RELEASE }}
62+
runs-on: ubuntu-latest
63+
steps:
64+
- uses: MetaMask/action-is-release@v1
65+
id: is-release
66+
67+
publish-release:
68+
needs: is-release
69+
if: needs.is-release.outputs.IS_RELEASE == 'true'
70+
name: Publish release
71+
permissions:
72+
contents: write
73+
uses: ./.github/workflows/publish-release.yml
74+
secrets:
75+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
76+
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }}
77+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

.github/workflows/publish-docs.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish docs to GitHub Pages
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
destination_dir:
7+
required: true
8+
type: string
9+
secrets:
10+
PUBLISH_DOCS_TOKEN:
11+
required: true
12+
13+
jobs:
14+
publish-docs-to-gh-pages:
15+
name: Publish docs to GitHub Pages
16+
runs-on: ubuntu-latest
17+
environment: github-pages
18+
permissions:
19+
contents: write
20+
steps:
21+
- name: Ensure `destination_dir` is not empty
22+
if: ${{ inputs.destination_dir == '' }}
23+
run: exit 1
24+
- name: Checkout the repository
25+
uses: actions/checkout@v3
26+
- name: Use Node.js
27+
uses: actions/setup-node@v3
28+
with:
29+
node-version-file: '.nvmrc'
30+
cache: 'yarn'
31+
- name: Install npm dependencies
32+
run: yarn --immutable
33+
- name: Run build script
34+
run: yarn build:docs
35+
- name: Deploy to `${{ inputs.destination_dir }}` directory of `gh-pages` branch
36+
uses: peaceiris/actions-gh-pages@de7ea6f8efb354206b205ef54722213d99067935
37+
with:
38+
# This `PUBLISH_DOCS_TOKEN` needs to be manually set per-repository.
39+
# Look in the repository settings under "Environments", and set this token in the `github-pages` environment.
40+
personal_token: ${{ secrets.PUBLISH_DOCS_TOKEN }}
41+
publish_dir: ./docs
42+
destination_dir: ${{ inputs.destination_dir }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Publish main branch docs to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: main
6+
7+
jobs:
8+
publish-to-gh-pages:
9+
name: Publish docs to `staging` directory of `gh-pages` branch
10+
permissions:
11+
contents: write
12+
uses: ./.github/workflows/publish-docs.yml
13+
with:
14+
destination_dir: staging
15+
secrets:
16+
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }}

.github/workflows/publish-rc-docs.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Publish release candidate docs to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: 'release/**'
6+
7+
jobs:
8+
get-release-version:
9+
name: Get release version
10+
runs-on: ubuntu-latest
11+
outputs:
12+
release-version: ${{ steps.release-name.outputs.RELEASE_VERSION }}
13+
steps:
14+
- name: Extract release version from branch name
15+
id: release-name
16+
run: |
17+
BRANCH_NAME='${{ github.ref_name }}'
18+
echo "RELEASE_VERSION=v${BRANCH_NAME#release/}" >> "$GITHUB_OUTPUT"
19+
publish-to-gh-pages:
20+
name: Publish docs to `rc-${{ needs.get-release-version.outputs.release-version }}` directory of `gh-pages` branch
21+
permissions:
22+
contents: write
23+
uses: ./.github/workflows/publish-docs.yml
24+
needs: get-release-version
25+
with:
26+
destination_dir: rc-${{ needs.get-release-version.outputs.release-version }}
27+
secrets:
28+
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }}

.github/workflows/publish-release.yml

Lines changed: 73 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
11
name: Publish Release
22

33
on:
4-
push:
5-
branches: [main]
4+
workflow_call:
5+
secrets:
6+
NPM_TOKEN:
7+
required: true
8+
SLACK_WEBHOOK_URL:
9+
required: true
10+
PUBLISH_DOCS_TOKEN:
11+
required: true
612

713
jobs:
8-
is-release:
9-
# release merge commits come from github-actions
10-
if: startsWith(github.event.commits[0].author.name, 'github-actions')
11-
outputs:
12-
IS_RELEASE: ${{ steps.is-release.outputs.IS_RELEASE }}
13-
runs-on: ubuntu-latest
14-
steps:
15-
- uses: MetaMask/action-is-release@v1
16-
id: is-release
17-
1814
publish-release:
1915
permissions:
2016
contents: write
21-
if: needs.is-release.outputs.IS_RELEASE == 'true'
2217
runs-on: ubuntu-latest
23-
needs: is-release
2418
steps:
2519
- uses: actions/checkout@v3
2620
with:
@@ -32,6 +26,17 @@ jobs:
3226
- uses: MetaMask/action-publish-release@v2
3327
env:
3428
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
- name: Install
30+
run: |
31+
yarn install
32+
yarn build
33+
- uses: actions/cache@v3
34+
id: restore-build
35+
with:
36+
path: |
37+
./dist
38+
./node_modules/.yarn-state.yml
39+
key: ${{ github.sha }}
3540

3641
publish-npm-dry-run:
3742
runs-on: ubuntu-latest
@@ -40,9 +45,19 @@ jobs:
4045
- uses: actions/checkout@v3
4146
with:
4247
ref: ${{ github.sha }}
48+
- uses: actions/cache@v3
49+
id: restore-build
50+
with:
51+
path: |
52+
./dist
53+
./node_modules/.yarn-state.yml
54+
key: ${{ github.sha }}
4355
- name: Dry Run Publish
4456
# omit npm-token token to perform dry run publish
45-
uses: MetaMask/action-npm-publish@v1
57+
uses: MetaMask/action-npm-publish@v3
58+
with:
59+
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
60+
target-name: metamask-npm-publishers
4661
env:
4762
SKIP_PREPACK: true
4863

@@ -54,11 +69,53 @@ jobs:
5469
- uses: actions/checkout@v3
5570
with:
5671
ref: ${{ github.sha }}
72+
- uses: actions/cache@v3
73+
id: restore-build
74+
with:
75+
path: |
76+
./dist
77+
./node_modules/.yarn-state.yml
78+
key: ${{ github.sha }}
5779
- name: Publish
58-
uses: MetaMask/action-npm-publish@v1
80+
uses: MetaMask/action-npm-publish@v2
5981
with:
6082
# This `NPM_TOKEN` needs to be manually set per-repository.
6183
# Look in the repository settings under "Environments", and set this token in the `npm-publish` environment.
6284
npm-token: ${{ secrets.NPM_TOKEN }}
6385
env:
6486
SKIP_PREPACK: true
87+
88+
get-release-version:
89+
runs-on: ubuntu-latest
90+
needs: publish-npm
91+
outputs:
92+
RELEASE_VERSION: ${{ steps.get-release-version.outputs.RELEASE_VERSION }}
93+
steps:
94+
- uses: actions/checkout@v3
95+
with:
96+
ref: ${{ github.sha }}
97+
- id: get-release-version
98+
shell: bash
99+
run: ./scripts/get.sh ".version" "RELEASE_VERSION"
100+
101+
publish-release-to-gh-pages:
102+
needs: get-release-version
103+
name: Publish docs to `${{ needs.get-release-version.outputs.RELEASE_VERSION }}` directory of `gh-pages` branch
104+
permissions:
105+
contents: write
106+
uses: ./.github/workflows/publish-docs.yml
107+
with:
108+
destination_dir: ${{ needs.get-release-version.outputs.RELEASE_VERSION }}
109+
secrets:
110+
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }}
111+
112+
publish-release-to-latest-gh-pages:
113+
needs: publish-npm
114+
name: Publish docs to `latest` directory of `gh-pages` branch
115+
permissions:
116+
contents: write
117+
uses: ./.github/workflows/publish-docs.yml
118+
with:
119+
destination_dir: latest
120+
secrets:
121+
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }}

0 commit comments

Comments
 (0)