Skip to content

Commit f528193

Browse files
committed
clean up yml files and add publishing to packages
1 parent 8713dd1 commit f528193

2 files changed

Lines changed: 25 additions & 65 deletions

File tree

.github/workflows/gh-storybook.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,42 @@
1-
name: publish npm package
1+
name: Publish to GitHub Packages
22

33
on:
4+
release:
5+
types: [published]
46
workflow_dispatch:
57

8+
permissions:
9+
contents: read
10+
packages: write
11+
612
jobs:
713
publish:
814
runs-on: ubuntu-latest
915

1016
steps:
11-
- name: Checkout repo
12-
uses: actions/checkout@v3
13-
with:
14-
persist-credentials: false
15-
16-
- name: Extract branch name
17-
id: extract_branch
18-
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
19-
20-
- name: Extract version from package.json
21-
id: extract_version
22-
run: echo "version=$(cat package.json | jq '.version' | tr -d '\"')" >> $GITHUB_OUTPUT
23-
24-
- name: Check branch name and get semver
25-
id: check_branch
26-
if: startsWith(steps.extract_branch.outputs.branch, 'rc-')
27-
run: |
28-
branch_name="${{ steps.extract_branch.outputs.branch }}"
29-
version=$(echo "$branch_name" | sed -n 's/rc-\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/p')
30-
echo "version=$version" >> $GITHUB_OUTPUT
31-
semver=$(echo "v$version")
32-
echo "semver=$semver" >> $GITHUB_OUTPUT
17+
- name: Checkout
18+
uses: actions/checkout@v4
3319

34-
- name: Compare branch name and version from package.json
35-
if: ${{ steps.check_branch.outputs.version != steps.extract_version.outputs.version }}
36-
run: echo "Versions do not match. Please check." && exit 1
37-
38-
- name: Use Node.js 18.x
20+
- name: Use Node.js 20
3921
uses: actions/setup-node@v4
4022
with:
41-
node-version: 18
42-
registry-url: 'https://registry.npmjs.org'
43-
44-
#- name: Authenticate with GitHub Package Registry
45-
# run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GH_REGITRY_TOKEN }}" > .npmrc
23+
node-version: 20
24+
registry-url: https://npm.pkg.github.com/
4625

4726
- name: Install dependencies
48-
run: |
49-
git config --global url."https://${{ secrets.GH_CI_TOKEN }}:x-oauth-basic@github.com".insteadOf "ssh://git@github.com"
50-
npm install
27+
run: npm ci
5128

52-
- name: Build package
53-
run: npm run build:dist:vite
29+
- name: Build
30+
run: npm run build:dist
31+
32+
- name: Sync version from tag
33+
run: |
34+
TAG="${GITHUB_REF_NAME}" # for example. v1.2.3
35+
VERSION="${TAG#v}" # 1.2.3
36+
echo "Version from tag: $VERSION"
37+
npm version "$VERSION" --no-git-tag-version
5438
55-
- name: Publish to NPM Package Registry
56-
run: npm publish --access public
39+
- name: Publish
5740
env:
58-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
41+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
run: npm publish

0 commit comments

Comments
 (0)