Skip to content

Commit

Permalink
CI: Fully automate release
Browse files Browse the repository at this point in the history
  • Loading branch information
Deltik committed Oct 21, 2024
1 parent 43d0bf0 commit 004b8b0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,52 @@ jobs:
name: JAR Artifact(s)
path: build/libs/*.jar

- name: Extract release notes from CHANGELOG.md
if: startsWith(github.ref, 'refs/tags/')
id: extract_release_notes
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const fs = require('fs');
const tag = context.ref.replace('refs/tags/', '');
const tagPattern = '^##\\s*' + tag.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '\\s*';
const versionPattern = new RegExp(tagPattern);
const changelog = fs.readFileSync('CHANGELOG.md', 'utf8');
const lines = changelog.split('\n');
let inSection = false;
let releaseTitle = '';
let releaseBodyLines = [];
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (versionPattern.test(line)) {
releaseTitle = line.replace(/^##\s*/, '').trim();
inSection = true;
continue;
}
if (inSection) {
if (/^##\s*/.test(line)) {
break;
} else {
releaseBodyLines.push(line);
}
}
}
const releaseBody = releaseBodyLines.join('\n').trim();
core.setOutput('release_title', releaseTitle);
core.setOutput('release_body', releaseBody);
- name: Upload release asset
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: build/libs/*.jar
body: ${{ steps.extract_release_notes.outputs.release_body }}
name: ${{ steps.extract_release_notes.outputs.release_title }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Under the Hood

* Switched CI provider from CircleCI to GitHub Actions
* Fully automated release in CI

## v1.14.4 (2023-07-31)

Expand Down

0 comments on commit 004b8b0

Please sign in to comment.