Skip to content

feat: add publish workflow#3157

Open
rtritto wants to merge 50 commits intovikejs:mainfrom
rtritto:publish
Open

feat: add publish workflow#3157
rtritto wants to merge 50 commits intovikejs:mainfrom
rtritto:publish

Conversation

@rtritto
Copy link
Copy Markdown
Contributor

@rtritto rtritto commented Mar 18, 2026

Fix #3154

@brillout
Copy link
Copy Markdown
Member

I understand your previous question now.

Can we make https://github.com/vikejs/vike/tags and the CHANGELOG.md be the source of truth here?

@brillout
Copy link
Copy Markdown
Member

(FYI we use https://github.com/brillout/release-me throughout many projects — not using it would be a little too disruptive.)

@rtritto
Copy link
Copy Markdown
Contributor Author

rtritto commented Mar 18, 2026

I understand your previous question now.

Can we make https://github.com/vikejs/vike/tags and the CHANGELOG.md be the source of truth here?

The goal is to create GitHub releases in https://github.com/vikejs/vike/releases

On the creation of a GitHub release, I think you want to get the changelog by the version in CHANGELOG.md and not by commits, right?

(FYI we use https://github.com/brillout/release-me throughout many projects — not using it would be a little too disruptive.)

Should this feature be done here?

@brillout
Copy link
Copy Markdown
Member

I understand your previous question now.
Can we make https://github.com/vikejs/vike/tags and the CHANGELOG.md be the source of truth here?

The goal is to create GitHub releases in https://github.com/vikejs/vike/releases

Yes I know.

I think you want to get the changelog by the version in CHANGELOG.md and not by commits, right?

Yes, the source of truth should ideally be CHANGELOG.md and not the commits (to keep things DRY).

(FYI we use https://github.com/brillout/release-me throughout many projects — not using it would be a little too disruptive.)

Should this feature be done here?

Let's first do it here and then we can see whether we want to move it to @brillout/release-me.

@rtritto
Copy link
Copy Markdown
Contributor Author

rtritto commented Mar 18, 2026

Yes, the source of truth should ideally be CHANGELOG.md and not the commits (to keep things DRY).

Done

@brillout
Copy link
Copy Markdown
Member

How about we run this workflow when the CHANGELOG.md file changes?

One issue is that I have to regularly modify CHANGELOG.md manually — can we make the release tags be fully synced (all versions!) whenever CHANGELOG.md changes? That'd be a bullet proof approach 💯

@rtritto
Copy link
Copy Markdown
Contributor Author

rtritto commented Mar 18, 2026

Sure, I can do.

Should I leave also the manual trigger (workflow_dispatch)?

@brillout
Copy link
Copy Markdown
Member

One issue is that I have to regularly modify CHANGELOG.md manually — can we make the release tags be fully synced (all versions!) whenever CHANGELOG.md changes? That'd be a bullet proof approach 💯

To be clear: what I mean is that whenever CHANGELOG.md changes => all GitHub releases are re-generated from scratch. Does GitHub allow this?

Should I leave also the manual trigger (workflow_dispatch)?

Ok why not.

@rtritto
Copy link
Copy Markdown
Contributor Author

rtritto commented Mar 19, 2026

To be clear: what I mean is that whenever CHANGELOG.md changes => all GitHub releases are re-generated from scratch. Does GitHub allow this?

Done (it needs to be tested)

brillout and others added 14 commits March 19, 2026 08:20
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rtritto
Copy link
Copy Markdown
Contributor Author

rtritto commented Mar 20, 2026

Do you want a PR to fix CHANGELOG.md?

@brillout
Copy link
Copy Markdown
Member

The best would be somewhat lenient:

I.e.:

  • If line doesn't contain x.y.z number => skip it
  • ## and # treated the same

Also an ability to dry-run the script would be awesome. Let's us test the script without doing API requests.

@rtritto
Copy link
Copy Markdown
Contributor Author

rtritto commented Mar 20, 2026

Done

@brillout
Copy link
Copy Markdown
Member

  • Let's add a test for that last change
  • Let's add a test for a couple of first hundreds of LoC of Vike's changelog. Same for Telefunc, vike-vue, vike-solid, and vike-solid
  • Let's add dry-run

@brillout
Copy link
Copy Markdown
Member

@rtritto Any luck? Polishing this PR makes a huge difference — if we can merge it once and then forget about it that'd be the best.

@rtritto
Copy link
Copy Markdown
Contributor Author

rtritto commented Mar 31, 2026

This is LGTM, you can go ahead as you like

@brillout
Copy link
Copy Markdown
Member

I'd rather merge after this:

Contribution welcome. We have a lot of higher priorities — we unfortunately cannot afford working on low-priority things.

Copilot AI review requested due to automatic review settings April 10, 2026 08:06
This reverts commit 57141a8.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds automation to publish the vike package and keep GitHub Releases in sync with CHANGELOG.md, addressing the need from #3154 to create/update GitHub releases on new versions.

Changes:

  • Introduces a Bun/TypeScript script to derive release notes from CHANGELOG.md and create/update GitHub releases, with accompanying Vitest coverage and fixtures.
  • Adds a GitHub Actions workflow to run on CHANGELOG.md updates (and manual dispatch) to publish to npm and create/update the GitHub release.
  • Expands the pnpm workspace and Vitest configuration to treat workflow tooling as workspace packages and run their unit tests.

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
vitest.config.ts Expands unit test discovery to include .github/**/*.spec.ts and adds exclusions.
pnpm-workspace.yaml Broadens workspace package globs to include .github/workflows/* packages.
pnpm-lock.yaml Updates lockfile importers for .github/workflows/* packages (devDependencies).
.github/workflows/sync-github-releases.yml New workflow to publish to npm and create/update GitHub releases when CHANGELOG.md changes.
.github/workflows/sync-github-releases/sync-releases.ts New script to parse changelog sections and sync GitHub releases via REST API.
.github/workflows/sync-github-releases/sync-releases.spec.ts Unit tests covering changelog parsing and release planning, plus local fallback behavior.
.github/workflows/sync-github-releases/package.json Adds local scripts for running/dry-running the release sync script with Bun.
.github/workflows/sync-github-releases/tsconfig.json TypeScript config for the new workflow/package script.
.github/workflows/sync-github-releases/fixtures/changelog-vike.md Fixture changelog content for parsing tests.
.github/workflows/sync-github-releases/fixtures/changelog-vike-vue.md Fixture changelog content for parsing tests.
.github/workflows/sync-github-releases/fixtures/changelog-vike-solid.md Fixture changelog content for parsing tests.
.github/workflows/sync-github-releases/fixtures/changelog-vike-react.md Fixture changelog content for parsing tests.
.github/workflows/sync-github-releases/fixtures/changelog-telefunc.md Fixture changelog content for parsing tests.
.github/workflows/ci/tsconfig.json Adds Node types to support workflow TypeScript compilation/typechecking.
.github/workflows/ci/package.json Moves workflow tooling deps to devDependencies and adds @types/node.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +36 to +42
- name: Install modules
run: pnpm install --filter ./packages/vike
- name: Create NPM release
working-directory: ./packages/vike
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow runs npm publish for packages/vike, but the repo doesn't contain a committed dist/ directory and there is no prepublish/prepare script in packages/vike/package.json to build it automatically. Add an explicit build step (e.g. run the package build script) before publishing to avoid publishing a broken package missing dist/* exports.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,242 @@
// Keeps GitHub releases aligned with `CHANGELOG.md`.
// => It derives release notes from `CHANGELOG.md`, creates the current release if needed (and any missing releases), and updates existing releases whose published notes are outdated (e.g. if CHANGELOG.md was manually edited).
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The top-of-file comment says this script creates "any missing releases" and updates outdated notes, but in the common case where at least one release already exists it only creates the current version and only considers releases returned by the single list call. Either adjust the comment to match the actual behavior, or extend the implementation to handle missing historical releases/updates as described.

Suggested change
// => It derives release notes from `CHANGELOG.md`, creates the current release if needed (and any missing releases), and updates existing releases whose published notes are outdated (e.g. if CHANGELOG.md was manually edited).
// => It derives release notes from `CHANGELOG.md`, creates the current release if needed, and updates inspected existing releases whose published notes are outdated (e.g. if `CHANGELOG.md` was manually edited).

Copilot uses AI. Check for mistakes.
Comment on lines +61 to +64
// https://docs.github.com/en/rest/releases/releases#list-releases
const releases = await githubRequest<Release[]>(`/repos/${owner}/${repo}/releases?per_page=100`, {
token,
})
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The releases list request is hard-limited to the most recent 100 releases (per_page=100) and doesn't paginate. As a result, older releases beyond the first page can never be updated/considered, which conflicts with the goal of keeping releases aligned with the full CHANGELOG.md. Implement pagination (follow the Link header or increment page=) until all releases are fetched or until you reach the oldest relevant tag.

Copilot uses AI. Check for mistakes.
Comment on lines +130 to +134
it('falls back to the production repository when run locally', () => {
const previous = process.env.GITHUB_REPOSITORY
try {
delete process.env.GITHUB_REPOSITORY
expect(getRepository()).toEqual({ owner: 'vikejs', repo: 'vike' })
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test hard-codes { owner: 'vikejs', repo: 'vike' } when GITHUB_REPOSITORY is unset. It will fail for contributors running tests on forks (where origin points to e.g. someone/vike) and for CI jobs that check out forks. Consider asserting only that getRepository() returns a valid {owner, repo} pair (or derive the expected value from git remote get-url origin within the test).

Suggested change
it('falls back to the production repository when run locally', () => {
const previous = process.env.GITHUB_REPOSITORY
try {
delete process.env.GITHUB_REPOSITORY
expect(getRepository()).toEqual({ owner: 'vikejs', repo: 'vike' })
it('returns a valid repository when run locally', () => {
const previous = process.env.GITHUB_REPOSITORY
try {
delete process.env.GITHUB_REPOSITORY
const repository = getRepository()
expect(repository.owner).toEqual(expect.any(String))
expect(repository.repo).toEqual(expect.any(String))
expect(repository.owner.trim()).not.toBe('')
expect(repository.repo.trim()).not.toBe('')

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,10 @@
{
"scripts": {
"run": "bun ./sync-releases.ts ",
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The run script has a trailing space ("bun ./sync-releases.ts "), which is easy to miss and can cause confusing diffs or shell quoting issues later. Remove the trailing whitespace.

Suggested change
"run": "bun ./sync-releases.ts ",
"run": "bun ./sync-releases.ts",

Copilot uses AI. Check for mistakes.
@brillout
Copy link
Copy Markdown
Member

@rtritto See copilot review above, up for working on it? Otherwise I'll close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add GitHub Release

3 participants