mirror of
https://github.com/zoriya/react-native-video.git
synced 2026-06-09 13:12:42 +00:00
chore: add release action
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
name: Publish Release on GitHub
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '18'
|
||||||
|
registry-url: 'https://npm.pkg.github.com'
|
||||||
|
|
||||||
|
- name: Setup Bun
|
||||||
|
uses: oven-sh/setup-bun@v2
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: bun install
|
||||||
|
|
||||||
|
- name: Prepare release
|
||||||
|
run: bun run scripts/release.js --no-release
|
||||||
|
|
||||||
|
- name: Publish release
|
||||||
|
run: cd packages/react-native-video && npm publish --tag dev
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
// Run "npm publish" in cli via Bun
|
||||||
|
import { $ } from 'bun';
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
const args = process.argv.slice(2);
|
||||||
|
|
||||||
|
const noRelease = args.includes("--no-release");
|
||||||
|
|
||||||
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
const rootDir = path.join(__dirname, '..');
|
||||||
|
|
||||||
|
const DRY_RUN = args.includes("--dry-run");
|
||||||
|
|
||||||
|
const bumpVersion = (version) => {
|
||||||
|
const tagParts = version.split('-');
|
||||||
|
const versionParts = tagParts[1].split('.');
|
||||||
|
|
||||||
|
const newVersion = parseInt(versionParts[1]) + 1;
|
||||||
|
|
||||||
|
return `${tagParts[0]}-${versionParts[0]}.${newVersion}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const writeFile = async (path, content) => {
|
||||||
|
if (DRY_RUN) {
|
||||||
|
console.log(`DRY RUN: Would write to ${path}`);
|
||||||
|
console.log(content);
|
||||||
|
console.log('--------------------------------');
|
||||||
|
} else {
|
||||||
|
await Bun.write(path, content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const runCommand = async (command) => {
|
||||||
|
if (DRY_RUN) {
|
||||||
|
console.log(`DRY RUN: Would run ${command}`);
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
|
return await $`${command}`.text();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const modifyPackage = async () => {
|
||||||
|
const packageJsonPath = path.join(rootDir, 'packages', 'react-native-video', 'package.json');
|
||||||
|
const packageJson = JSON.parse(await Bun.file(packageJsonPath).text());
|
||||||
|
|
||||||
|
// We need to modify the name of the package name to be exact as @ORGANIZATION/PACKAGE-NAME
|
||||||
|
const name = "@TheWidlarzGroup/react-native-video-v7";
|
||||||
|
const version = packageJson.version;
|
||||||
|
|
||||||
|
const newVersion = bumpVersion(version);
|
||||||
|
|
||||||
|
packageJson.name = name;
|
||||||
|
packageJson.version = newVersion;
|
||||||
|
|
||||||
|
await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
||||||
|
};
|
||||||
|
|
||||||
|
let publishCommand = `npm publish --tag dev`;
|
||||||
|
|
||||||
|
await modifyPackage();
|
||||||
|
|
||||||
|
if (!noRelease) {
|
||||||
|
await runCommand(publishCommand);
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user