Skip to content

Commit 4b8c89f

Browse files
authored
ci: publish to npm workflow (#456)
1 parent 6d5084a commit 4b8c89f

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

.github/workflows/publish-npm.yaml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
name: Publish to NPM
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
version:
7-
description: "The version to release, e.g., 10.0.0-rc2"
8-
required: true
9-
10-
defaults:
11-
run:
12-
working-directory: .
4+
release:
5+
types: [published]
136

147
jobs:
158
publish:
@@ -27,7 +20,7 @@ jobs:
2720

2821
- name: Install Foundry
2922
uses: foundry-rs/foundry-toolchain@v1
30-
23+
3124
- name: Install Dependencies
3225
run: |
3326
yarn install
@@ -39,14 +32,17 @@ jobs:
3932
- name: Determine NPM Tag
4033
id: determine-npm-tag
4134
run: |
42-
VERSION_TAG="${{ github.event.inputs.version }}"
35+
VERSION_TAG=${GITHUB_REF#refs/tags/v}
4336
if [[ $VERSION_TAG == *"-"* ]]; then
44-
echo "NPM_TAG=${VERSION_TAG#*-}" >> $GITHUB_ENV
37+
echo ::set-output name=NPM_TAG::${VERSION_TAG#*-}
4538
else
46-
echo "NPM_TAG=latest" >> $GITHUB_ENV
39+
echo ::set-output name=NPM_TAG::latest
4740
fi
41+
env:
42+
GITHUB_REF: ${{ github.ref }}
4843

4944
- name: Publish to NPM
50-
run: yarn publish --new-version ${{ github.event.inputs.version }} --tag ${{ env.NPM_TAG }} --no-git-tag-version
45+
run: yarn publish --new-version ${GITHUB_REF#refs/tags/v} --tag ${{ steps.determine-npm-tag.outputs.NPM_TAG }} --no-git-tag-version
5146
env:
5247
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
48+
GITHUB_REF: ${{ github.ref }}

0 commit comments

Comments
 (0)