Skip to content

Commit 4591cbf

Browse files
authored
build: allow manual publishing of alpha versions (#35)
1 parent 2cc5035 commit 4591cbf

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

.github/workflows/npm-publish.yml

+27-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
name: Publish to NPM on GH Release Publish
22

33
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Alpha version to publish, e.g. 0.1.4-alpha.0'
8+
required: true
9+
ref:
10+
description: 'Branch or tag to publish, e.g. feature/branch or v0.1.4'
11+
required: true
412
release:
513
types: [published]
614

715
env:
816
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
17+
VERSION_TO_PUBLISH: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version || github.event.release.tag_name }}
918

1019
jobs:
1120
publish:
1221
if: github.repository == 'brainly/gene'
1322
strategy:
1423
matrix:
15-
packages_to_publish:
24+
package_to_publish:
1625
- create
1726
- eslint-plugin
1827
- gene
@@ -25,6 +34,12 @@ jobs:
2534

2635
steps:
2736
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
37+
if: github.event_name != 'workflow_dispatch'
38+
39+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
40+
if: github.event_name == 'workflow_dispatch'
41+
with:
42+
ref: ${{ github.event.inputs.ref }}
2843

2944
- name: Install pnpm
3045
uses: pnpm/action-setup@v4
@@ -41,12 +56,20 @@ jobs:
4156
- name: Install dependencies
4257
run: pnpm install
4358

44-
- run: pnpm nx build packages-${{ matrix.packages_to_publish }}
59+
- run: pnpm nx build packages-${{ matrix.package_to_publish }}
4560

4661
- run: npm whoami
4762

48-
- name: Publish to NPM
63+
- name: Publish to NPM (stable)
64+
if: github.event_name != 'workflow_dispatch'
4965
run: |
50-
cd dist/packages/${{ matrix.packages_to_publish }}
66+
cd dist/packages/${{ matrix.package_to_publish }}
5167
npm version ${{ github.event.release.tag_name }} --no-git-tag-version
5268
npm publish --access public
69+
70+
- name: Publish to NPM (alpha)
71+
if: github.event_name == 'workflow_dispatch'
72+
run: |
73+
cd dist/packages/${{ matrix.package_to_publish }}
74+
npm version ${{ env.VERSION_TO_PUBLISH }} --no-git-tag-version
75+
npm publish --access public --tag alpha

0 commit comments

Comments
 (0)