diff --git a/.github/tag-changelog-config.js b/.github/tag-changelog-config.js new file mode 100644 index 0000000..bcab84e --- /dev/null +++ b/.github/tag-changelog-config.js @@ -0,0 +1,31 @@ +module.exports = { + types: [ + { types: ["feat", "feature"], label: "โœจ New Features" }, + { types: ["fix", "bugfix"], label: "๐Ÿ› Bugfixes" }, + { types: ["improvements", "enhancement"], label: "๐Ÿ”จ Improvements" }, + { types: ["perf"], label: "๐ŸŽ๏ธ Performance Improvements" }, + { types: ["build", "ci"], label: "๐Ÿ—๏ธ Build System" }, + { types: ["refactor"], label: "๐Ÿชš Refactors" }, + { types: ["doc", "docs"], label: "๐Ÿ“š Documentation Changes" }, + { types: ["test", "tests"], label: "๐Ÿ” Tests" }, + { types: ["style"], label: "๐Ÿ’… Code Style Changes" }, + { types: ["chore"], label: "๐Ÿงน Chores" }, + { types: ["other"], label: "Other Changes" }, + ], + + excludeTypes: ["other"], + + renderTypeSection: function (label, commits) { + let text = `\n## ${label}\n`; + commits.forEach((commit) => { + const scope = commit.scope ? `**${commit.scope}**: ` : '' + text += `- [\`${commit.sha.substring(0, 7)}\`](${commit.url}) ${scope} ${commit.subject}\n`; + }); + return text; + }, + + renderChangelog: function (release, changes) { + const now = new Date(); + return `# ${release} - ${now.toISOString().substr(0, 10)}\n` + changes + "\n\n"; + }, + }; \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e454e60 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,64 @@ +name: Release + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +jobs: + build-upload-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Get version from tag + id: version + run: echo ::set-output name=number::$(echo $GITHUB_REF | cut -d / -f 3 | cut -d / -f 3 | sed -e 's/^v//') + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 17 + + - name: Get jar version + id: get_version + run: echo "::set-output name=version::$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" + + - name: Get jar name + id: get_name + run: echo "::set-output name=name::$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" + + - name: Build with maven + run: mvn clean package + + - name: Create changelog text + id: changelog + uses: loopwerk/tag-changelog@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + exclude_types: other,doc,chore + config_file: .github/tag-changelog-config.js + + - name: Parse changelog markdown to HTML + id: changelog-html + uses: lifepal/markdown-to-html@v1.2 + with: + text: ${{ steps.changelog.outputs.changelog }} + + - name: Release to GitHub releases + uses: softprops/action-gh-release@v1 + with: + body: ${{ steps.changelog.outputs.changes }} + fail_on_unmatched_files: true + tag_name: ${{ steps.version.outputs.number }} + + - name: Upload JAR to release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./target/${{ steps.get_name.outputs.name }}-${{ steps.get_version.outputs.version }}.jar + asset_name: ${{ steps.get_name.outputs.name }}-${{ steps.get_version.outputs.version }}.jar + asset_content_type: application/java-archive \ No newline at end of file