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
97 changes: 97 additions & 0 deletions .github/workflows/create_release_on_commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Create GitHub Release on Commit

on:
push:
branches:
- '**'

permissions:
contents: write

jobs:
create_release:
name: Create versioned release from package.json
if: github.event.deleted == false
runs-on: ubuntu-latest
steps:
- name: Create GitHub release
uses: actions/github-script@v7
with:
script: |
const {owner, repo} = context.repo;
const branch = context.ref.replace('refs/heads/', '');
const sha = context.sha;
const packagePath = 'packages/react-devtools-custom/package.json';
const packageFile = await github.rest.repos.getContent({
owner,
repo,
path: packagePath,
ref: sha,
});

if (Array.isArray(packageFile.data) || !packageFile.data.content) {
throw new Error(`Could not read ${packagePath} from commit ${sha}.`);
}

const packageJson = JSON.parse(
Buffer.from(packageFile.data.content, 'base64').toString('utf8')
);

if (!packageJson.name || !packageJson.version) {
throw new Error(
`${packagePath} must include both "name" and "version".`
);
}

const releaseName = `${packageJson.name}-v${packageJson.version}`;
const tagName = releaseName;
const tagRef = `refs/tags/${tagName}`;
const commitUrl = `${context.serverUrl}/${owner}/${repo}/commit/${sha}`;
const commitMessage = context.payload.head_commit?.message || '';
const releaseBody = [
`Branch: ${branch}`,
`Commit: ${sha}`,
`Package: ${packageJson.name}`,
`Version: ${packageJson.version}`,
'',
commitMessage,
'',
commitUrl,
].join('\n');

try {
await github.rest.git.createRef({
owner,
repo,
ref: tagRef,
sha,
});
core.info(`Created tag ${tagName} for ${sha}.`);
} catch (error) {
if (error.status !== 422) {
throw error;
}

core.info(`Tag ${tagName} already exists; continuing.`);
}

try {
await github.rest.repos.createRelease({
owner,
repo,
tag_name: tagName,
target_commitish: sha,
name: releaseName,
body: releaseBody,
draft: false,
prerelease: false,
make_latest: 'false',
});
core.info(`Created release ${tagName}.`);
} catch (error) {
if (error.status !== 422) {
throw error;
}

core.info(`Release ${tagName} already exists; skipping.`);
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ chrome-user-data
.claude/*.local.*

packages/react-devtools-core/dist
packages/react-devtools-custom/dist
packages/react-devtools-extensions/chrome/build
packages/react-devtools-extensions/chrome/*.crx
packages/react-devtools-extensions/chrome/*.pem
Expand All @@ -40,4 +41,3 @@ packages/react-devtools-fusebox/dist
packages/react-devtools-inline/dist
packages/react-devtools-shell/dist
packages/react-devtools-timeline/dist

Loading
Loading