Skip to content

Commit 93bb490

Browse files
authored
Merge pull request #755 from reduxjs/feature/harden-publishing-2026-05
Additional publishing hardening
2 parents 65c48cd + b0a4415 commit 93bb490

1 file changed

Lines changed: 33 additions & 17 deletions

File tree

.github/workflows/build-and-test-types.yml

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: CI
22

33
on: [push, pull_request]
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69
build:
710
name: Build and Test on Node ${{ matrix.node }}
@@ -12,16 +15,18 @@ jobs:
1215

1316
steps:
1417
- name: Checkout code
15-
uses: actions/checkout@v4
18+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
19+
with:
20+
persist-credentials: false
1621

1722
- name: Set up Node
18-
uses: actions/setup-node@v4
23+
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
1924
with:
2025
node-version: ${{ matrix.node }}
2126
cache: 'yarn'
2227

2328
- name: Install dependencies
24-
run: yarn install
29+
run: yarn install --frozen-lockfile
2530

2631
# Read existing version, reuse that, add a Git short hash
2732
- name: Set build version to Git commit
@@ -39,7 +44,7 @@ jobs:
3944
- name: Pack
4045
run: yarn pack
4146

42-
- uses: actions/upload-artifact@v4
47+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
4348
with:
4449
name: package
4550
path: ./package.tgz
@@ -57,16 +62,18 @@ jobs:
5762

5863
steps:
5964
- name: Checkout repo
60-
uses: actions/checkout@v4
65+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
66+
with:
67+
persist-credentials: false
6168

6269
- name: Use node ${{ matrix.node }}
63-
uses: actions/setup-node@v4
70+
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
6471
with:
6572
node-version: ${{ matrix.node }}
6673
cache: 'yarn'
6774

6875
- name: Install deps
69-
run: yarn install
76+
run: yarn install --frozen-lockfile
7077

7178
# Build with the actual TS version in the repo
7279
- name: Pack
@@ -102,22 +109,24 @@ jobs:
102109
node: ['22.x']
103110
steps:
104111
- name: Checkout repo
105-
uses: actions/checkout@v4
112+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
113+
with:
114+
persist-credentials: false
106115

107116
- name: Use node ${{ matrix.node }}
108-
uses: actions/setup-node@v4
117+
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
109118
with:
110119
node-version: ${{ matrix.node }}
111120
cache: 'yarn'
112121

113-
- uses: actions/download-artifact@v4
122+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
114123
with:
115124
name: package
116125
path: .
117126

118127
# Note: We currently expect "FalseCJS" failures for Node16 + `moduleResolution: "node16",
119128
- name: Run are-the-types-wrong
120-
run: npx @arethetypeswrong/cli@latest ./package.tgz --format table --ignore-rules false-cjs
129+
run: npx @arethetypeswrong/cli@0.18.2 ./package.tgz --format table --ignore-rules false-cjs
121130

122131
test-published-artifact:
123132
name: Test Published Artifact ${{ matrix.example }}
@@ -141,30 +150,37 @@ jobs:
141150
]
142151
steps:
143152
- name: Checkout repo
144-
uses: actions/checkout@v4
153+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
154+
with:
155+
persist-credentials: false
145156

146157
- name: Use node ${{ matrix.node }}
147-
uses: actions/setup-node@v4
158+
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
148159
with:
149160
node-version: ${{ matrix.node }}
150161
cache: 'yarn'
151162

152-
- name: Clone RTK repo
153-
run: git clone https://github.com/reduxjs/redux-toolkit.git ./redux-toolkit
163+
- name: Clone RTK repo (pinned to known-good commit)
164+
run: |
165+
git init ./redux-toolkit
166+
git -C ./redux-toolkit fetch --depth 1 https://github.com/reduxjs/redux-toolkit.git 576a02f8056fbee2dcaddb4d2e4d2da3b7937c58
167+
git -C ./redux-toolkit checkout FETCH_HEAD
154168
155169
- name: Check folder contents
156170
run: ls -l .
157171

158172
- name: Install example deps
159173
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
174+
env:
175+
YARN_ENABLE_SCRIPTS: false
160176
run: yarn install
161177

162178
- name: Install Playwright browser if necessary
163179
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
164180
continue-on-error: true
165181
run: yarn playwright install || true
166182

167-
- uses: actions/download-artifact@v4
183+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
168184
with:
169185
name: package
170186
path: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
@@ -183,7 +199,7 @@ jobs:
183199

184200
- name: Set up JDK 17 for React Native build
185201
if: matrix.example == 'react-native'
186-
uses: actions/setup-java@v4
202+
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4.8.0
187203
with:
188204
java-version: '17.x'
189205
distribution: 'temurin'

0 commit comments

Comments
 (0)