Skip to content

Commit 2638469

Browse files
Set up publish workflow that can be used for both nightly and manual release (#475)
# Summary This PR refactor `publish.yml` and uses `npm-package-publish` for nightly and manual publish. Job success: https://github.com/software-mansion/react-native-enriched/actions/runs/22892021685/job/66417143113 ## Test Plan Run Publish workflow
1 parent 31db4d3 commit 2638469

1 file changed

Lines changed: 51 additions & 55 deletions

File tree

.github/workflows/publish.yml

Lines changed: 51 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,66 @@
11
name: Publish
22
on:
3+
# For nightly releases
4+
schedule:
5+
- cron: '42 23 * * *' # at 23:42 every day
6+
# For manual releases
37
workflow_dispatch:
48
inputs:
5-
dryRun:
6-
description: 'Set to true to perform a dry run'
9+
release-type:
10+
description: Type of release to publish.
11+
type: choice
12+
options: [stable, nightly, beta, rc]
13+
default: stable
14+
version:
15+
description: Specific version to publish (usually inferred from x.y-stable branch name).
16+
type: string
717
required: false
8-
default: 'true'
9-
10-
permissions:
11-
id-token: write
12-
contents: read
18+
default: ''
19+
dry-run:
20+
description: Whether to perform a dry run of the publish.
21+
type: boolean
22+
default: true
1323

1424
jobs:
15-
verify-and-publish:
25+
publish:
1626
runs-on: ubuntu-latest
17-
environment: production
18-
steps:
19-
- name: Checkout
20-
uses: actions/checkout@v4
21-
22-
- name: Setup
23-
uses: ./.github/actions/setup
24-
25-
- name: Run ESLint (JS/TS check)
26-
run: yarn lint
27-
28-
- name: Typecheck files
29-
run: yarn typecheck
3027

31-
- name: Run clang-format (C/C++ check)
32-
run: yarn lint-clang
28+
permissions:
29+
contents: write
30+
id-token: write # for OIDC
3331

34-
- name: Run android lint (Kotlin/Java/Groovy check)
35-
run: yarn lint:android
32+
concurrency:
33+
group: publish-${{ github.ref }}
34+
cancel-in-progress: false
3635

37-
- name: Run unit tests
38-
run: yarn test --maxWorkers=2 --coverage
39-
40-
- name: Build package
41-
run: npm pack
42-
43-
- name: Get metadata
44-
id: meta
45-
run: |
46-
NAME=$(jq -r .name package.json)
47-
VERSION=$(jq -r .version package.json)
48-
FILENAME="${NAME}-${VERSION}.tgz"
49-
echo "PACKAGE_NAME=$FILENAME" >> $GITHUB_OUTPUT
50-
echo "Artifact filename: $FILENAME"
36+
steps:
37+
- name: Check out
38+
uses: actions/checkout@v4
5139

52-
- name: Upload NPM tarball as artifact
53-
uses: actions/upload-artifact@v4
40+
- name: Setup Node
41+
uses: actions/setup-node@v6
5442
with:
55-
name: ${{ steps.meta.outputs.PACKAGE_NAME }}
56-
path: ${{ steps.meta.outputs.PACKAGE_NAME }}
57-
overwrite: true
58-
if-no-files-found: error
43+
node-version-file: .nvmrc
44+
cache: 'yarn'
45+
registry-url: https://registry.npmjs.org/
5946

60-
- name: Publish package (dry-run)
61-
if: ${{ github.event.inputs.dryRun == 'true' }}
62-
run: |
63-
echo "Dry run enabled — skipping actual publish"
64-
npm publish --dry-run
47+
- name: Publish manual release
48+
if: ${{ github.event_name == 'workflow_dispatch' }}
49+
uses: software-mansion/npm-package-publish@1bb885ec49bed729c8c1ec95a11a285d89f1bf45
50+
with:
51+
package-name: 'react-native-enriched'
52+
package-json-path: 'package.json'
53+
install-dependencies-command: 'yarn install --immutable'
54+
release-type: ${{ inputs.release-type }}
55+
version: ${{ inputs.version }}
56+
dry-run: ${{ inputs.dry-run }}
6557

66-
- name: Publish package
67-
if: ${{ github.event.inputs.dryRun != 'true' }}
68-
run: |
69-
echo "Publishing package..."
70-
npm publish
58+
- name: Publish automatic nightly release
59+
if: ${{ github.event_name == 'schedule' }}
60+
uses: software-mansion/npm-package-publish@1bb885ec49bed729c8c1ec95a11a285d89f1bf45
61+
with:
62+
package-name: 'react-native-enriched'
63+
package-json-path: 'package.json'
64+
install-dependencies-command: 'yarn install --immutable'
65+
release-type: 'nightly'
66+
dry-run: false

0 commit comments

Comments
 (0)