Skip to content

Commit ca04165

Browse files
committed
build(ci): Automate publishing
1 parent 025eeb4 commit ca04165

File tree

5 files changed

+157
-0
lines changed

5 files changed

+157
-0
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.1.2/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}

.github/workflows/ci.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main, develop]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [22.x, 24.x]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: 'npm'
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Lint
30+
run: npm run lint
31+
32+
- name: Build
33+
run: npm run build
34+
35+
- name: Test
36+
run: npm run test:coverage
37+
38+
- name: Upload coverage to Codecov
39+
if: matrix.node-version == '24.x'
40+
uses: codecov/codecov-action@v4
41+
with:
42+
files: ./coverage/coverage-final.json
43+
fail_ci_if_error: false
44+
45+
publish-check:
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
- uses: actions/checkout@v4
50+
51+
- name: Use Node.js
52+
uses: actions/setup-node@v4
53+
with:
54+
node-version: 20.x
55+
cache: 'npm'
56+
57+
- name: Install dependencies
58+
run: npm ci
59+
60+
- name: Check package can be published
61+
run: npm pack --dry-run
62+
63+
- name: Check package size
64+
run: |
65+
size=$(npm pack --dry-run 2>&1 | grep "package size" | awk '{print $3}')
66+
echo "Package size: $size"

.github/workflows/publish.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
permissions:
13+
id-token: write
14+
contents: write
15+
packages: write
16+
pull-requests: write
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '24.x'
28+
cache: 'npm'
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Run tests
34+
run: npm test
35+
36+
- name: Build
37+
run: npm run build
38+
39+
# Configure npm registry for publishing
40+
- name: Setup Node.js for npm
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: '24.x'
44+
registry-url: 'https://registry.npmjs.org'
45+
46+
- name: Create Release Pull Request or Publish to npm
47+
id: changesets
48+
uses: changesets/action@v1
49+
with:
50+
publish: npm run release
51+
title: 'chore: version packages'
52+
commit: 'chore: version packages'
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
NPM_CONFIG_PROVENANCE: true
56+
57+
# Only publish to GitHub Packages if npm publish succeeded
58+
- name: Setup Node.js for GitHub Packages
59+
if: steps.changesets.outputs.published == 'true'
60+
uses: actions/setup-node@v4
61+
with:
62+
node-version: '24.x'
63+
registry-url: 'https://npm.pkg.github.com'
64+
scope: '@taskade'
65+
66+
- name: Publish to GitHub Packages
67+
if: steps.changesets.outputs.published == 'true'
68+
run: npm publish --registry=https://npm.pkg.github.com --ignore-scripts
69+
env:
70+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Use public npm registry for @taskade/eslint-plugin only
2+
@taskade/eslint-plugin:registry=https://registry.npmjs.org/

0 commit comments

Comments
 (0)