-
Notifications
You must be signed in to change notification settings - Fork 0
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 #5 from hirasso/feat/add-changesets
Add a Changelog and a release flow using `@changesets/cli` and `@changesets/action`. Also some minor readme optimizations.
- Loading branch information
Showing
15 changed files
with
1,597 additions
and
125 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
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,12 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "restricted", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [], | ||
"privatePackages": { "version": true, "tag": true } | ||
} |
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,5 @@ | ||
--- | ||
"focal-point-picker": patch | ||
--- | ||
|
||
Add a Changelog and a release flow using `@changesets/cli` and `@changesets/action`. Also some minor readme optimizations. |
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,65 @@ | ||
name: Install Playwright | ||
description: Install Playwright and dependencies with cache | ||
|
||
# https://github.com/microsoft/playwright/issues/7249#issuecomment-2334627973 | ||
|
||
inputs: | ||
working-directory: | ||
description: Where to install Playwright | ||
default: ./ | ||
browsers: | ||
description: Browsers to install | ||
default: chromium webkit firefox | ||
|
||
outputs: | ||
version: | ||
description: Installed version of Playwright | ||
value: ${{ steps.version.outputs.version }} | ||
cache-hit: | ||
description: Whether cache for Playwright was found | ||
value: ${{ steps.cache.outputs.cache-hit }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Get Playwright version | ||
uses: actions/github-script@v7 | ||
id: version | ||
with: | ||
script: | | ||
// https://github.com/actions/toolkit/issues/1624 | ||
// const workingDirectory = core.getInput("working-directory"); | ||
const workingDirectory = "${{ inputs.working-directory }}"; | ||
console.debug("Specified working directory:", workingDirectory); | ||
if (workingDirectory) process.chdir(workingDirectory); | ||
console.debug("Actual working directory:", process.cwd()); | ||
let version = ""; | ||
try { | ||
version = require("@playwright/test/package.json").version; | ||
} catch (error) { | ||
console.log(error.message); | ||
} | ||
console.debug("Version:", version); | ||
if (version) { | ||
core.exportVariable("PLAYWRIGHT_VERSION", version); | ||
core.setOutput("version", version); | ||
} else core.setFailed("Couldn't get Playwright version"); | ||
- name: Cache Playwright | ||
id: cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/ms-playwright | ||
key: playwright-${{ env.PLAYWRIGHT_VERSION }} | ||
|
||
- name: Install Playwright and its dependencies | ||
shell: bash | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
working-directory: ${{ inputs.working-directory }} | ||
run: npx playwright install ${{ inputs.browsers }} --with-deps | ||
|
||
- name: Install just Playwright's dependencies | ||
shell: bash | ||
if: steps.cache.outputs.cache-hit == 'true' | ||
working-directory: ${{ inputs.working-directory }} | ||
run: npx playwright install-deps |
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,49 @@ | ||
name: Run Shared Setup | ||
|
||
inputs: | ||
php-version: | ||
description: The PHP version to install | ||
default: 8.3 | ||
playwright: | ||
description: Should Playwright be installed? | ||
default: false | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ inputs.php-version }} | ||
tools: composer:v2 | ||
coverage: xdebug | ||
|
||
- name: Install Composer Dependencies | ||
uses: ramsey/composer-install@v3 | ||
|
||
- name: Setup PNPM | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
version: latest | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: .nvmrc | ||
cache: pnpm | ||
|
||
- name: Install Dependencies | ||
shell: bash | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Install Playwright | ||
if: ${{ inputs.playwright }} == 'true' | ||
id: install-playwright | ||
uses: ./.github/actions/install-playwright | ||
|
||
- name: Debug Playwright Cache | ||
if: ${{ inputs.playwright }} == 'true' | ||
shell: bash | ||
run: | | ||
echo "Playwright version: ${{ steps.install-playwright.outputs.version }}" | ||
echo "Playwright cached: ${{ steps.install-playwright.outputs.cache-hit }}" |
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,73 @@ | ||
name: Version or Publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
package-infos: | ||
name: Get Package Infos | ||
runs-on: ubuntu-latest | ||
outputs: | ||
fullName: ${{ steps.package-infos.outputs.fullName }} | ||
vendorName: ${{ steps.package-infos.outputs.vendorName }} | ||
packageName: ${{ steps.package-infos.outputs.packageName }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Read and Write Package Infos to Output | ||
id: package-infos | ||
run: | | ||
NAME=$(jq -r '.name' composer.json) | ||
echo "fullName=${NAME}" >> $GITHUB_OUTPUT | ||
echo "vendorName=${NAME%%/*}" >> $GITHUB_OUTPUT | ||
echo "packageName=${NAME#*/}" >> $GITHUB_OUTPUT | ||
cat "$GITHUB_OUTPUT" | ||
release: | ||
needs: package-infos | ||
if: ${{ github.repository == needs.package-infos.outputs.fullName }} | ||
|
||
name: Create Version PR or Publish | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: true | ||
|
||
steps: | ||
- name: Configure Git | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Rasso Hilber's Bot" | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Shared Setup | ||
uses: ./.github/actions/shared-setup | ||
with: | ||
playwright: false | ||
|
||
# Run changesets action either if there are unreleased changesets (= a PR must be created) | ||
# or if the commit message matches the release PR (= new versions must be published) | ||
- name: Create changesets PR or Publish | ||
id: cs | ||
uses: changesets/action@v1 | ||
with: | ||
title: "[CI] Release" | ||
commit: "[CI] Release" | ||
version: pnpm run version | ||
publish: pnpm changeset tag | ||
env: | ||
# Do not run husky/lintstaged | ||
HUSKY: 0 | ||
# Doesn't work with GITHUB_TOKEN for some reason | ||
GITHUB_TOKEN: ${{ secrets.HIRASSO_ACTIONS_TOKEN }} |
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 @@ | ||
# Changelog |
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,101 @@ | ||
#!/usr/bin/env node | ||
|
||
import { parseArgs } from "node:util"; | ||
import { basename } from "node:path"; | ||
import { fileURLToPath } from "node:url"; | ||
|
||
import pc from "picocolors"; | ||
const { blue, red, bold } = pc; | ||
|
||
import { | ||
dd, | ||
createRelease, | ||
testRelease, | ||
pushReleaseToDist, | ||
patchVersion, | ||
prepareDistFolder, | ||
isAtRootDir, | ||
testDev, | ||
error, | ||
} from "./support.js"; | ||
import { exit } from "node:process"; | ||
|
||
// Get the equivalent of __filename | ||
const __filename = fileURLToPath(import.meta.url); | ||
|
||
/** | ||
* @typedef {Object} Command | ||
* @property {Function} fn - The function to execute the command. | ||
* @property {string} description - A brief description of what the command does. | ||
*/ | ||
|
||
/** | ||
* An object containing available commands with their respective handlers and descriptions. | ||
* | ||
* @type {Object<string, Command>} | ||
*/ | ||
const commands = { | ||
"release:create": { | ||
fn: createRelease, | ||
description: "Create a scoped release", | ||
}, | ||
"version:patch": { | ||
fn: patchVersion, | ||
description: "Patch the version in the main plugin file", | ||
}, | ||
"dist:prepare": { | ||
fn: prepareDistFolder, | ||
description: "Prepare the folder for pushing to the dist repo", | ||
}, | ||
"dist:push": { | ||
fn: pushReleaseToDist, | ||
description: "Push the prepared dist folder to the dist repo", | ||
}, | ||
"test:dev": { | ||
fn: testDev, | ||
description: | ||
"Run tests against the development (unscoped) version of the plugin", | ||
}, | ||
"test:release": { | ||
fn: testRelease, | ||
description: "Run tests against the release (scoped) version of the plugin", | ||
}, | ||
help: { | ||
fn: printUsage, | ||
description: "Show available commands for this cli", | ||
}, | ||
}; | ||
|
||
const { | ||
positionals: [command], | ||
} = parseArgs({ allowPositionals: true }); | ||
|
||
// Function to print usage | ||
function printUsage() { | ||
const commandList = []; | ||
for (const [name, { description }] of Object.entries(commands)) { | ||
commandList.push(`${blue(name)} – ${description}`); | ||
} | ||
console.log(` | ||
Usage: cli.js ${blue(`<command>`)} | ||
Available commands: | ||
${commandList.join("\n ")}`); | ||
} | ||
|
||
// Validate correct invocation | ||
if (!command || typeof commands[command] === "undefined") { | ||
console.log(`\n ❌ ${red(bold(`Unkown command: ${command}`))}`); | ||
printUsage(); | ||
exit(); | ||
} | ||
|
||
// Ensure the script is run from the project root | ||
if (!isAtRootDir()) { | ||
error( | ||
`${basename(__filename)} must be executed from the package root directory`, | ||
); | ||
} | ||
|
||
// Execute the command | ||
commands[command].fn(); |
Oops, something went wrong.