Skip to content

Commit 6e14629

Browse files
committed
feat: add GitHub Actions workflow for publishing packages and update package.json files with repository and registry information
1 parent 626fbd8 commit 6e14629

File tree

7 files changed

+149
-8
lines changed

7 files changed

+149
-8
lines changed
+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Publish Packages
2+
3+
on:
4+
release:
5+
types: [created]
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: 'Version to publish (patch, minor, major, or specific version)'
10+
required: true
11+
default: 'patch'
12+
type: choice
13+
options:
14+
- patch
15+
- minor
16+
- major
17+
- custom
18+
19+
jobs:
20+
build-and-publish:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
packages: write
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Setup Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: '20'
36+
registry-url: 'https://npm.pkg.github.com'
37+
scope: '@vue-web-component-library'
38+
39+
- name: Setup PNPM
40+
uses: pnpm/action-setup@v3
41+
with:
42+
version: '10.6.3'
43+
44+
- name: Install dependencies
45+
run: pnpm install --frozen-lockfile
46+
47+
- name: Build packages
48+
run: pnpm build
49+
50+
- name: Run tests
51+
run: pnpm test
52+
53+
- name: Configure Git
54+
run: |
55+
git config --global user.name "${GITHUB_ACTOR}"
56+
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
57+
58+
- name: Version packages
59+
if: github.event_name == 'workflow_dispatch'
60+
run: |
61+
if [ "${{ github.event.inputs.version }}" == "custom" ]; then
62+
echo "Please specify the custom version in the next workflow run."
63+
exit 1
64+
else
65+
pnpm -r exec -- npm version ${{ github.event.inputs.version }} --no-git-tag-version
66+
fi
67+
68+
- name: Publish packages
69+
run: pnpm -r publish --no-git-checks
70+
env:
71+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

+45-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,35 @@ npm install @vue-web-component-library/input
2525
npm install @vue-web-component-library/icon
2626
```
2727

28+
### Installing from GitHub Packages
29+
30+
The packages are also available on GitHub Packages. To use them:
31+
32+
1. Create or modify your `.npmrc` file in your project root:
33+
34+
```
35+
@vue-web-component-library:registry=https://npm.pkg.github.com
36+
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
37+
```
38+
39+
2. Set your GitHub token as an environment variable:
40+
41+
```bash
42+
export GITHUB_TOKEN=your_github_token
43+
```
44+
45+
3. Install the packages:
46+
47+
```bash
48+
# Install the entire library
49+
npm install @vue-web-component-library/components
50+
51+
# Or install individual components
52+
npm install @vue-web-component-library/button
53+
npm install @vue-web-component-library/input
54+
npm install @vue-web-component-library/icon
55+
```
56+
2857
## Usage
2958

3059
### Importing Components
@@ -132,6 +161,21 @@ A component for displaying Google Material Icons.
132161

133162
Contributions are welcome! Please feel free to submit a Pull Request.
134163

135-
## License
164+
## Publishing
165+
166+
This library is published to GitHub Packages using a GitHub Actions workflow. To publish a new version:
167+
168+
1. Create a new release on GitHub or
169+
2. Manually trigger the "Publish Packages" workflow from the Actions tab, selecting the version increment (patch, minor, major)
170+
171+
### GitHub Actions Workflow
136172

173+
The publishing workflow:
174+
175+
1. Builds all packages
176+
2. Runs tests
177+
3. Increments versions (when manually triggered)
178+
4. Publishes packages to GitHub Packages
179+
180+
## License
137181
MIT

packages/components/button/package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"lint": "eslint src --ext .ts,.vue",
1616
"test": "vitest"
1717
},
18+
"repository": {
19+
"type": "git",
20+
"url": "git+https://github.com/devbyrayray/vue-web-component-library.git",
21+
"directory": "packages/components/button"
22+
},
1823
"keywords": [
1924
"vue",
2025
"web-components",
@@ -26,7 +31,7 @@
2631
"license": "MIT",
2732
"sideEffects": false,
2833
"publishConfig": {
29-
"access": "public"
34+
"registry": "https://npm.pkg.github.com"
3035
},
3136
"dependencies": {
3237
"@vue-web-component-library/core": "workspace:*",

packages/components/icon/package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"lint": "eslint src --ext .ts,.vue",
1616
"test": "vitest"
1717
},
18+
"repository": {
19+
"type": "git",
20+
"url": "git+https://github.com/devbyrayray/vue-web-component-library.git",
21+
"directory": "packages/components/icon"
22+
},
1823
"keywords": [
1924
"vue",
2025
"web-components",
@@ -27,7 +32,7 @@
2732
"license": "MIT",
2833
"sideEffects": false,
2934
"publishConfig": {
30-
"access": "public"
35+
"registry": "https://npm.pkg.github.com"
3136
},
3237
"dependencies": {
3338
"@vue-web-component-library/core": "workspace:*",

packages/components/input/package.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"lint": "eslint src --ext .ts,.vue",
1616
"test": "vitest"
1717
},
18+
"repository": {
19+
"type": "git",
20+
"url": "git+https://github.com/devbyrayray/vue-web-component-library.git",
21+
"directory": "packages/components/input"
22+
},
1823
"keywords": [
1924
"vue",
2025
"web-components",
@@ -26,7 +31,8 @@
2631
"license": "MIT",
2732
"sideEffects": false,
2833
"publishConfig": {
29-
"access": "public"
34+
"access": "public",
35+
"registry": "https://npm.pkg.github.com"
3036
},
3137
"dependencies": {
3238
"@vue-web-component-library/core": "workspace:*",

packages/components/package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"lint": "eslint src --ext .ts,.vue",
1616
"test": "vitest"
1717
},
18+
"repository": {
19+
"type": "git",
20+
"url": "git+https://github.com/devbyrayray/vue-web-component-library.git",
21+
"directory": "packages/components"
22+
},
1823
"keywords": [
1924
"vue",
2025
"web-components",
@@ -26,7 +31,7 @@
2631
"license": "MIT",
2732
"sideEffects": false,
2833
"publishConfig": {
29-
"access": "public"
34+
"registry": "https://npm.pkg.github.com"
3035
},
3136
"dependencies": {
3237
"@vue-web-component-library/button": "workspace:*",

packages/core/package.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
"lint": "eslint src --ext .ts,.vue",
1616
"test": "vitest"
1717
},
18+
"repository": {
19+
"type": "git",
20+
"url": "git+https://github.com/devbyrayray/vue-web-component-library.git",
21+
"directory": "packages/core"
22+
},
23+
"publishConfig": {
24+
"registry": "https://npm.pkg.github.com"
25+
},
1826
"keywords": [
1927
"vue",
2028
"web-components",
@@ -25,8 +33,5 @@
2533
"author": "",
2634
"license": "MIT",
2735
"sideEffects": false,
28-
"publishConfig": {
29-
"access": "public"
30-
},
3136
"packageManager": "[email protected]"
3237
}

0 commit comments

Comments
 (0)