Skip to content

Commit ad6e685

Browse files
authored
Merge pull request #4 from link-foundation/issue-3-37ba7822b479
feat: apply CI/CD template from js-ai-driven-development-pipeline-template
2 parents e36b17a + 6444bbc commit ad6e685

33 files changed

+5783
-622
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.1/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+
}

.changeset/goofy-vans-shop.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'gh-download-pull-request': minor
3+
---
4+
5+
Apply CI/CD template with GitHub Actions workflows, code quality tools (ESLint, Prettier, Husky), multi-runtime support (Node.js, Bun, Deno), and automated release management using changesets.
6+
7+
This release includes:
8+
9+
- Complete CI/CD pipeline with GitHub Actions (testing, linting, automated releases)
10+
- Multi-runtime testing across Node.js, Bun, and Deno on Ubuntu, macOS, and Windows
11+
- Code quality tools: ESLint, Prettier, Husky pre-commit hooks, file size validation
12+
- Changesets-based version management with npm OIDC trusted publishing
13+
- Fix Windows compatibility by replacing use-m with static imports
14+
- Fix Bun test discovery by renaming test files to .test.mjs extension
15+
- Add @octokit/rest, fs-extra, and yargs as regular dependencies

.github/workflows/release.yml

Lines changed: 310 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,310 @@
1+
name: Checks and release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
# Manual release support - consolidated here to work with npm trusted publishing
10+
# npm only allows ONE workflow file as trusted publisher, so all publishing
11+
# must go through this workflow (release.yml)
12+
workflow_dispatch:
13+
inputs:
14+
release_mode:
15+
description: 'Manual release mode'
16+
required: true
17+
type: choice
18+
default: 'instant'
19+
options:
20+
- instant
21+
- changeset-pr
22+
bump_type:
23+
description: 'Manual release type'
24+
required: true
25+
type: choice
26+
options:
27+
- patch
28+
- minor
29+
- major
30+
description:
31+
description: 'Manual release description (optional)'
32+
required: false
33+
type: string
34+
35+
concurrency: ${{ github.workflow }}-${{ github.ref }}
36+
37+
jobs:
38+
# Changeset check - only runs on PRs
39+
changeset-check:
40+
name: Check for Changesets
41+
runs-on: ubuntu-latest
42+
if: github.event_name == 'pull_request'
43+
steps:
44+
- uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 0
47+
48+
- name: Setup Node.js
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: '20.x'
52+
53+
- name: Install dependencies
54+
run: npm install
55+
56+
- name: Check for changesets
57+
run: |
58+
# Skip changeset check for automated version PRs
59+
if [[ "${{ github.head_ref }}" == "changeset-release/"* ]]; then
60+
echo "Skipping changeset check for automated release PR"
61+
exit 0
62+
fi
63+
64+
# Run changeset validation script
65+
node scripts/validate-changeset.mjs
66+
67+
# Linting and formatting - runs after changeset check on PRs, immediately on main
68+
lint:
69+
name: Lint and Format Check
70+
runs-on: ubuntu-latest
71+
needs: [changeset-check]
72+
if: always() && (github.event_name == 'push' || needs.changeset-check.result == 'success')
73+
steps:
74+
- uses: actions/checkout@v4
75+
76+
- name: Setup Node.js
77+
uses: actions/setup-node@v4
78+
with:
79+
node-version: '20.x'
80+
81+
- name: Install dependencies
82+
run: npm install
83+
84+
- name: Run ESLint
85+
run: npm run lint
86+
87+
- name: Check formatting
88+
run: npm run format:check
89+
90+
- name: Check file size limit
91+
run: npm run check:file-size
92+
93+
# Test matrix: 3 runtimes (Node.js, Bun, Deno) x 3 OS (Ubuntu, macOS, Windows)
94+
test:
95+
name: Test (${{ matrix.runtime }} on ${{ matrix.os }})
96+
runs-on: ${{ matrix.os }}
97+
needs: [changeset-check]
98+
if: always() && (github.event_name == 'push' || needs.changeset-check.result == 'success')
99+
strategy:
100+
fail-fast: false
101+
matrix:
102+
os: [ubuntu-latest, macos-latest, windows-latest]
103+
runtime: [node, bun, deno]
104+
steps:
105+
- uses: actions/checkout@v4
106+
107+
- name: Setup Node.js
108+
if: matrix.runtime == 'node'
109+
uses: actions/setup-node@v4
110+
with:
111+
node-version: '20.x'
112+
113+
- name: Install dependencies (Node.js)
114+
if: matrix.runtime == 'node'
115+
run: npm install
116+
117+
- name: Run tests (Node.js)
118+
if: matrix.runtime == 'node'
119+
run: npm test
120+
121+
- name: Setup Bun
122+
if: matrix.runtime == 'bun'
123+
uses: oven-sh/setup-bun@v2
124+
with:
125+
bun-version: latest
126+
127+
- name: Install dependencies (Bun)
128+
if: matrix.runtime == 'bun'
129+
run: bun install
130+
131+
- name: Run tests (Bun)
132+
if: matrix.runtime == 'bun'
133+
run: bun test
134+
135+
- name: Setup Deno
136+
if: matrix.runtime == 'deno'
137+
uses: denoland/setup-deno@v2
138+
with:
139+
deno-version: v2.x
140+
141+
- name: Run tests (Deno)
142+
if: matrix.runtime == 'deno'
143+
run: deno test --allow-read --allow-run --no-check
144+
145+
# Release - only runs on main after tests pass (for push events)
146+
release:
147+
name: Release
148+
needs: [lint, test]
149+
# Use always() to ensure this job runs even if changeset-check was skipped
150+
# This is needed because lint/test jobs have a transitive dependency on changeset-check
151+
if: always() && github.ref == 'refs/heads/main' && github.event_name == 'push' && needs.lint.result == 'success' && needs.test.result == 'success'
152+
runs-on: ubuntu-latest
153+
# Permissions required for npm OIDC trusted publishing
154+
permissions:
155+
contents: write
156+
pull-requests: write
157+
id-token: write
158+
steps:
159+
- uses: actions/checkout@v4
160+
with:
161+
fetch-depth: 0
162+
163+
- name: Setup Node.js
164+
uses: actions/setup-node@v4
165+
with:
166+
node-version: '20.x'
167+
registry-url: 'https://registry.npmjs.org'
168+
169+
- name: Install dependencies
170+
run: npm install
171+
172+
- name: Update npm for OIDC trusted publishing
173+
run: node scripts/setup-npm.mjs
174+
175+
- name: Check for changesets
176+
id: check_changesets
177+
run: |
178+
# Count changeset files (excluding README.md and config.json)
179+
CHANGESET_COUNT=$(find .changeset -name "*.md" ! -name "README.md" | wc -l)
180+
echo "Found $CHANGESET_COUNT changeset file(s)"
181+
echo "has_changesets=$([[ $CHANGESET_COUNT -gt 0 ]] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
182+
183+
- name: Version packages and commit to main
184+
if: steps.check_changesets.outputs.has_changesets == 'true'
185+
id: version
186+
run: node scripts/version-and-commit.mjs --mode changeset
187+
188+
- name: Publish to npm
189+
# Run if version was committed OR if a previous attempt already committed (for re-runs)
190+
if: steps.version.outputs.version_committed == 'true' || steps.version.outputs.already_released == 'true'
191+
id: publish
192+
run: node scripts/publish-to-npm.mjs --should-pull
193+
194+
- name: Create GitHub Release
195+
if: steps.publish.outputs.published == 'true'
196+
env:
197+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
198+
run: node scripts/create-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}"
199+
200+
- name: Format GitHub release notes
201+
if: steps.publish.outputs.published == 'true'
202+
env:
203+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
204+
run: node scripts/format-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}" --commit-sha "${{ github.sha }}"
205+
206+
# Manual Instant Release - triggered via workflow_dispatch with instant mode
207+
# This job is in release.yml because npm trusted publishing
208+
# only allows one workflow file to be registered as a trusted publisher
209+
instant-release:
210+
name: Instant Release
211+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_mode == 'instant'
212+
runs-on: ubuntu-latest
213+
# Permissions required for npm OIDC trusted publishing
214+
permissions:
215+
contents: write
216+
pull-requests: write
217+
id-token: write
218+
steps:
219+
- uses: actions/checkout@v4
220+
with:
221+
fetch-depth: 0
222+
223+
- name: Setup Node.js
224+
uses: actions/setup-node@v4
225+
with:
226+
node-version: '20.x'
227+
registry-url: 'https://registry.npmjs.org'
228+
229+
- name: Install dependencies
230+
run: npm install
231+
232+
- name: Update npm for OIDC trusted publishing
233+
run: node scripts/setup-npm.mjs
234+
235+
- name: Version packages and commit to main
236+
id: version
237+
run: node scripts/version-and-commit.mjs --mode instant --bump-type "${{ github.event.inputs.bump_type }}" --description "${{ github.event.inputs.description }}"
238+
239+
- name: Publish to npm
240+
# Run if version was committed OR if a previous attempt already committed (for re-runs)
241+
if: steps.version.outputs.version_committed == 'true' || steps.version.outputs.already_released == 'true'
242+
id: publish
243+
run: node scripts/publish-to-npm.mjs
244+
245+
- name: Create GitHub Release
246+
if: steps.publish.outputs.published == 'true'
247+
env:
248+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
249+
run: node scripts/create-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}"
250+
251+
- name: Format GitHub release notes
252+
if: steps.publish.outputs.published == 'true'
253+
env:
254+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
255+
run: node scripts/format-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}" --commit-sha "${{ github.sha }}"
256+
257+
# Manual Changeset PR - creates a pull request with the changeset for review
258+
changeset-pr:
259+
name: Create Changeset PR
260+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_mode == 'changeset-pr'
261+
runs-on: ubuntu-latest
262+
permissions:
263+
contents: write
264+
pull-requests: write
265+
steps:
266+
- uses: actions/checkout@v4
267+
with:
268+
fetch-depth: 0
269+
270+
- name: Setup Node.js
271+
uses: actions/setup-node@v4
272+
with:
273+
node-version: '20.x'
274+
275+
- name: Install dependencies
276+
run: npm install
277+
278+
- name: Create changeset file
279+
run: node scripts/create-manual-changeset.mjs --bump-type "${{ github.event.inputs.bump_type }}" --description "${{ github.event.inputs.description }}"
280+
281+
- name: Format changeset with Prettier
282+
run: |
283+
# Run Prettier on the changeset file to ensure it matches project style
284+
npx prettier --write ".changeset/*.md" || true
285+
286+
echo "Formatted changeset files"
287+
288+
- name: Create Pull Request
289+
uses: peter-evans/create-pull-request@v7
290+
with:
291+
token: ${{ secrets.GITHUB_TOKEN }}
292+
commit-message: 'chore: add changeset for manual ${{ github.event.inputs.bump_type }} release'
293+
branch: changeset-manual-release-${{ github.run_id }}
294+
delete-branch: true
295+
title: 'chore: manual ${{ github.event.inputs.bump_type }} release'
296+
body: |
297+
## Manual Release Request
298+
299+
This PR was created by a manual workflow trigger to prepare a **${{ github.event.inputs.bump_type }}** release.
300+
301+
### Release Details
302+
- **Type:** ${{ github.event.inputs.bump_type }}
303+
- **Description:** ${{ github.event.inputs.description || 'Manual release' }}
304+
- **Triggered by:** @${{ github.actor }}
305+
306+
### Next Steps
307+
1. Review the changeset in this PR
308+
2. Merge this PR to main
309+
3. The automated release workflow will create a version PR
310+
4. Merge the version PR to publish to npm and create a GitHub release

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

.prettierignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
coverage
3+
dist
4+
*.min.js
5+
package-lock.json
6+
.eslintcache

.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": true,
5+
"printWidth": 80,
6+
"tabWidth": 2,
7+
"useTabs": false,
8+
"arrowParens": "always",
9+
"endOfLine": "lf"
10+
}

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# gh-download-pull-request
2+
3+
## 0.1.0
4+
5+
### Minor Changes
6+
7+
- Initial release with core functionality to download GitHub pull requests as markdown

0 commit comments

Comments
 (0)