Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Release

on:
push:
branches:
- main

permissions:
contents: write # create tags, releases, and commit changelogs
id-token: write # exchange OIDC token with the npm registry for authentication (publish to npm)
packages: write # publish to npm registry via GitHub Packages (trusted publishing)

jobs:
release:
name: semantic-release
runs-on: ubuntu-latest

steps:
# Generate a GitHub App token for authentication instead of using a personal access token
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}

# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0 # Fetch all history for all branches and tags (required to allow semantic-release to analyze commits)
persist-credentials: false # Explicitly disable the token persistence

# Reconfigure git remote URL to use the GitHub App token for authentication instead of the default GITHUB_TOKEN for pushing changes back to the repository by semantic-release
- name: Authenticate git with GitHub App token
run: |
git remote set-url origin \
https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/${{ github.repository }}.git

# Setup Node.js v24
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: https://registry.npmjs.org

# Install semantic-release plugins to determine the next version, update changelog, publish to npm, and create GitHub release
# - semantic-release@25: The main semantic-release package
# - @semantic-release/changelog@6: Update the changelog file
# - @semantic-release/git@10: Commit changelog and version bump
- name: Install semantic-release (CI-only)
run: |
npm install --no-save \
semantic-release@25 \
@semantic-release/changelog@6 \
@semantic-release/git@10 \
@conventional-changelog-conventionalcommits/release@9 \

# Run semantic-release to automate the release process
- name: Run semantic-release
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} # Use GitHub App token for semantic-release authentication
run: npx semantic-release
28 changes: 0 additions & 28 deletions .release-it.json

This file was deleted.

86 changes: 86 additions & 0 deletions .releaserc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
* @type {import('semantic-release').GlobalConfig}
*/
export default {
branches: ["main"],
repositoryUrl: "https://github.com/codesweetly/react-youtube-playlist",
plugins: [
// 1. Analyze commits and map them to release types
[
"@semantic-release/commit-analyzer", // infer bump from commits
{
preset: "conventionalcommits",
releaseRules: [
{ type: "feat", release: "minor" },
{ type: "fix", release: "patch" },
{ type: "perf", release: "patch" },
{ type: "refactor", release: "patch" },
// Docs & DX improvements still get patch releases
{ type: "docs", release: "patch" },
{ type: "style", release: "patch" },
// Ignore noise
{ type: "test", release: false },
{ type: "chore", release: false },
{ type: "ci", release: false },
],
},
],
// 2. Generate clean, readable release notes
[
"@semantic-release/release-notes-generator",
{
preset: "conventionalcommits",
presetConfig: {
types: [
{ type: "feat", section: "✨ Features" },
{ type: "fix", section: "🐛 Bug Fixes" },
{ type: "perf", section: "⚡ Performance" },
{ type: "refactor", section: "♻️ Refactoring" },
{ type: "docs", section: "📚 Documentation" },
{ type: "style", section: "🎨 Code Style" },
],
},
parserOpts: {
mergePattern: "^Merge pull request",
mergeCorrespondence: null,
},
writerOpts: {
groupBy: "type",
commitGroupsSort: "title",
commitsSort: ["scope", "subject"],
},
},
],
// 3. Write formatted changelog to CHANGELOG.md
[
"@semantic-release/changelog",
{
changelogFile: "CHANGELOG.md",
changelogTitle:
"# 📦 Changelog\n\nAll notable changes to **react-image-grid-gallery** are documented here.\n",
writerOpts: {
groupBy: "type",
commitGroupsSort: "title",
},
},
],
// 4. Update version + publish to npm
[
"@semantic-release/npm",
{
npmPublish: true,
},
],
// 5. Commit changelog + version bump back to repo
[
"@semantic-release/git",
{
assets: ["package.json", "package-lock.json", "CHANGELOG.md"],
message:
"chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
},
],
// 6. Create GitHub release notes & tag
"@semantic-release/github",
],
};
17 changes: 17 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** @type {import('jest').Config} */
module.exports = {
testEnvironment: "jsdom",
setupFilesAfterEnv: ["<rootDir>/src/jestPolyfillSetup.ts"],
transform: {
"^.+\\.tsx?$": [
"ts-jest",
{
tsconfig: "tsconfig.test.json",
},
],
},
// Resolve .js imports to .ts/.tsx files for testing (for example, YouTubePlaylist.jsx -> YouTubePlaylist.tsx)
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
};
11 changes: 0 additions & 11 deletions jest.config.ts

This file was deleted.

Loading