-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from solidjs-community/ci-version-publish
Add GH Action for bumping package versions.
- Loading branch information
Showing
6 changed files
with
108 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Version | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "Semver version bump" | ||
required: true | ||
type: choice | ||
options: [patch, minor, major] | ||
jobs: | ||
version: | ||
name: Version | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
run_install: false | ||
|
||
- name: Install node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "22" | ||
cache: "pnpm" | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Bump version | ||
run: pnpm run version -- ${{ inputs.version }} | ||
|
||
- name: Create PR with new versions | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
branch: "gh-action-version" | ||
delete-branch: true | ||
title: "Update package versions" | ||
body: "Merging this PR will publish packages to npm at the new version." | ||
- name: Push tags | ||
run: | | ||
git switch gh-action-version | ||
git push origin --tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import fs from "node:fs/promises"; | ||
import path from "node:path"; | ||
import inc from "semver/functions/inc.js"; | ||
import { exec } from "node:child_process"; | ||
|
||
const pluginPackageJsonPath = path.resolve("packages", "eslint-plugin-solid", "package.json"); | ||
const standalonePackageJsonPath = path.resolve( | ||
"packages", | ||
"eslint-solid-standalone", | ||
"package.json" | ||
); | ||
|
||
const pluginPackageJson = JSON.parse(await fs.readFile(pluginPackageJsonPath, "utf-8")); | ||
const standalonePackageJson = JSON.parse(await fs.readFile(standalonePackageJsonPath, "utf-8")); | ||
|
||
const version = pluginPackageJson.version; | ||
const increment = process.argv[2]; | ||
const newVersion = inc(version, increment); | ||
|
||
if (newVersion == null || !/^\d+\.\d+\.\d+$/.test(newVersion)) { | ||
console.error("Usage: node scripts/version.js [increment]"); | ||
process.exit(1); | ||
} | ||
|
||
pluginPackageJson.version = newVersion; | ||
standalonePackageJson.version = newVersion; | ||
|
||
await Promise.all([ | ||
fs.writeFile(pluginPackageJsonPath, JSON.stringify(pluginPackageJson, null, 2), "utf-8"), | ||
fs.writeFile(standalonePackageJsonPath, JSON.stringify(standalonePackageJson, null, 2), "utf-8"), | ||
]); | ||
await new Promise((resolve, reject) => { | ||
exec( | ||
`git commit --all --message="v${newVersion}"; git tag "v${newVersion}";`, | ||
(error, stdout) => { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
console.log(stdout); | ||
resolve(stdout); | ||
} | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters