mirror of
https://github.com/selfxyz/self.git
synced 2026-02-19 02:24:25 -05:00
* migrate build logic from previous branch * fix command * move .actrc file * clean up * use env vars * setup provisioning profile path within action * fix flow * fix fastfile flow and update react native * disable play store uploading * hard code xcode version * fixes * more provisioning debugging * fix keychain path * set keychain to what was created by the github action * attempt to build again * test fix * print xcode build settings * debug ios build * fix xcargs path * use manual code signing * save wip * fix building locally * fix variable * save wip * clean up long comand * clean up * install bundle and gems * install pods * fix pod installation * sort * better naming * fix android issues * update lock * clean up artifacts * format * save wip slack upload logic * prettier * fix indent * save wip * save wip * save wip * save wip * save wip * clean up * simplify slack calls * revert slack logic * save working slack upload example * make title nicer * clean up slack upload * upload paths * enable github commit * fix path * fix commit step * fix git committing * update markdown * fix git commit rule * better commit message * chore: incrementing ios build number for version 2.4.9 [skip ci] * better name --------- Co-authored-by: Self GitHub Actions <action@github.com>
118 lines
2.7 KiB
JavaScript
118 lines
2.7 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
const { execSync } = require('child_process');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
// Get package version
|
|
function getVersion() {
|
|
const packageJson = JSON.parse(
|
|
fs.readFileSync(path.join(__dirname, '../package.json'), 'utf8'),
|
|
);
|
|
return packageJson.version;
|
|
}
|
|
|
|
// Check if working directory is clean
|
|
function isWorkingDirectoryClean() {
|
|
try {
|
|
const status = execSync('git status --porcelain').toString();
|
|
return status.trim() === '';
|
|
} catch (error) {
|
|
console.error('Error checking git status:', error.message);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// Create an empty commit
|
|
function createEmptyCommit(version) {
|
|
try {
|
|
execSync(`git commit --allow-empty -m "chore: release v${version}"`);
|
|
console.log(`Created empty commit for v${version}`);
|
|
} catch (error) {
|
|
console.error('Error creating commit:', error.message);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
// Create git tag
|
|
function createTag(version) {
|
|
try {
|
|
execSync(`git tag v${version}`);
|
|
console.log(`Created tag v${version}`);
|
|
} catch (error) {
|
|
console.error('Error creating tag:', error.message);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
// Push tag to remote
|
|
function pushTag(version) {
|
|
try {
|
|
execSync(`git push origin v${version}`);
|
|
console.log(`Pushed tag v${version} to remote`);
|
|
} catch (error) {
|
|
console.error('Error pushing tag:', error.message);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
// Remove tag locally and from remote
|
|
function removeTag(version) {
|
|
try {
|
|
execSync(`git tag -d v${version}`);
|
|
execSync(`git push origin :refs/tags/v${version}`);
|
|
console.log(`Removed tag v${version}`);
|
|
} catch (error) {
|
|
console.error('Error removing tag:', error.message);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
// Main function to handle commands
|
|
function main() {
|
|
const command = process.argv[2];
|
|
const version = getVersion();
|
|
|
|
switch (command) {
|
|
case 'commit':
|
|
if (!isWorkingDirectoryClean()) {
|
|
console.error(
|
|
'Error: Working directory is not clean. Please commit or stash changes first.',
|
|
);
|
|
process.exit(1);
|
|
}
|
|
createEmptyCommit(version);
|
|
break;
|
|
|
|
case 'create':
|
|
createTag(version);
|
|
break;
|
|
|
|
case 'push':
|
|
pushTag(version);
|
|
break;
|
|
|
|
case 'remove':
|
|
removeTag(version);
|
|
break;
|
|
|
|
case 'release':
|
|
if (!isWorkingDirectoryClean()) {
|
|
console.error(
|
|
'Error: Working directory is not clean. Please commit or stash changes first.',
|
|
);
|
|
process.exit(1);
|
|
}
|
|
createEmptyCommit(version);
|
|
createTag(version);
|
|
pushTag(version);
|
|
break;
|
|
|
|
default:
|
|
console.log('Usage: node tag.js [commit|create|push|remove|release]');
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
main();
|