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
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,22 @@ jobs:

- name: Increment Version & Generate Changelog
run: node scripts/release.js
id: release

- name: Extract Release Info
run: |
echo "RELEASE_VERSION=${{ steps.release.outputs.version }}" >> $GITHUB_ENV
echo "RELEASE_CHANGELOG<<EOF" >> $GITHUB_ENV
cat CHANGELOG.md | head -50 >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
Comment thread
coderabbitai[bot] marked this conversation as resolved.

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.RELEASE_VERSION }}
body: ${{ env.RELEASE_CHANGELOG }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build Project
run: npm run build
Expand Down
40 changes: 14 additions & 26 deletions scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,31 +72,19 @@ try {

fs.writeFileSync('CHANGELOG.md', changelogEntry + existingChangelog);

// Git operations
try {
execSync('git config user.name "github-actions[bot]"');
execSync('git config user.email "github-actions[bot]@users.noreply.github.com"');

execSync('git add CHANGELOG.md src/data/version.json');

// Only commit if there are changes
const status = execSync('git status --porcelain').toString().trim();
if (status) {
execSync(`git commit -m "chore: release ${version} [skip ci]"`);
execSync(`git tag ${version}`);

// Only push if in a CI environment to prevent accidental local pushes
if (process.env.GITHUB_ACTIONS) {
execSync('git push origin main');
execSync('git push origin --tags');
console.log(`Successfully released version ${version}`);
} else {
console.log(`Local run complete. Version ${version} prepared but not pushed.`);
}
} else {
console.log('No files to commit.');
// Write outputs to GitHub Actions for workflow consumption
const githubOutput = process.env.GITHUB_OUTPUT;
if (githubOutput) {
try {
fs.appendFileSync(githubOutput, `version=${version}\n`);
fs.appendFileSync(githubOutput, `changelog=${encodeURIComponent(changelogEntry)}\n`);
console.log('Outputs written to GITHUB_OUTPUT');
} catch (e) {
console.error(`Failed to write to GITHUB_OUTPUT: ${e.message}`);
process.exit(1);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
} catch (error) {
console.error('Error during git operations:', error.stdout ? error.stdout.toString() : error);
process.exit(1);
}

// Output version for GitHub Release
console.log(`\n::notice title=Release Version::${version}`);
console.log(`Successfully prepared version ${version}`);
Loading