From bdbf53fa9b4a1ed5e0c1602a61ceaff0448c9d19 Mon Sep 17 00:00:00 2001 From: stonebuzz Date: Thu, 31 Aug 2023 15:08:47 +0200 Subject: [PATCH] feat(build): update ChangeLog --- .github/workflows/release-new-version.yml | 38 +++++++++++++++++++++-- RoboFile.php | 25 +++++++++++---- 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release-new-version.yml b/.github/workflows/release-new-version.yml index 0846b1ba0..9b7060c19 100644 --- a/.github/workflows/release-new-version.yml +++ b/.github/workflows/release-new-version.yml @@ -27,6 +27,9 @@ jobs: - name: "Extract Current Tag Name" run: echo "tag_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: "Update Release Version" + run: echo "$(jq '.version = "${{ env.tag_name }}"' package.json)" > package.json + - name: Extract Previous Tag Name run: echo "previous_tag_name=$(git tag --sort=taggerdate | tail -1)" >> $GITHUB_ENV @@ -50,6 +53,24 @@ jobs: ##################### # Prepare release # ##################### + - name: "Extract Full ChangeLog (Conventional Commit)" + run: | + { + echo 'full_change_log<> "$GITHUB_ENV" + + - name: "Update Full ChangeLog" + run: echo "${{ env.full_change_log }}" > CHANGELOG.md + + - name: Push Update to repo + uses: EndBug/add-and-commit@v9 + with: + default_author: github_actions + push: origin HEAD:develop + message: "ci(release): release new version ${{ env.tag_name }}" + - name: "Extract Clean Git Log (Conventional Commit)" run: | { @@ -58,6 +79,19 @@ jobs: echo EOF } >> "$GITHUB_ENV" + - name: "Rename ${{ env.module_java }} APK" + run: mv ${{ env.module_java }}/build/outputs/apk/release/${{ env.module_java }}-release-unsigned.apk ${{ env.module_java }}/build/outputs/apk/release/${{ env.module_java }}-v${{ env.tag_name }}.apk + + - name: "Rename ${{ env.module_kotlin }} APK" + run: mv ${{ env.module_kotlin }}/build/outputs/apk/release/${{ env.module_kotlin }}-release-unsigned.apk ${{ env.module_kotlin }}/build/outputs/apk/release/${{ env.module_kotlin }}-v${{ env.tag_name }}.apk + + - name: "Rename ${{ env.module_inventory }} AAR" + run: mv ${{ env.module_inventory }}/build/outputs/aar/${{ env.module_inventory }}-release.aar ${{ env.module_inventory }}/build/outputs/aar/${{ env.module_inventory }}-release-v${{ env.tag_name }}.aar + + - name: "Rename ${{ env.module_inventory }} JAR" + run: mv $${{ env.module_inventory }}/build/libs/${{ env.module_inventory }}-sources.jar ${{ env.module_inventory }}/build/libs/${{ env.module_inventory }}-sources-v${{ env.tag_name }}.jar + + - name: Create Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') @@ -66,7 +100,7 @@ jobs: draft : true body : ${{ env.release_body }} files: | - ${{ env.module_java }}/build/outputs/apk/release/${{ env.module_java }}-release-unsigned.apk - ${{ env.module_kotlin }}/build/outputs/apk/release/${{ env.module_kotlin }}-release-unsigned.apk + ${{ env.module_java }}/build/outputs/apk/release/${{ env.module_java }}-v${{ env.tag_name }}.apk + ${{ env.module_kotlin }}/build/outputs/apk/release/${{ env.module_kotlin }}-v${{ env.tag_name }}.apk ${{ env.module_inventory }}/build/outputs/aar/${{ env.module_inventory }}-release.aar ${{ env.module_inventory }}/build/libs/${{ env.module_inventory }}-sources.jar diff --git a/RoboFile.php b/RoboFile.php index d6ee1888c..f8c45ab85 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -78,6 +78,8 @@ public static function buildLog($a, $b = 'HEAD', $with_head = true) { return Semver::isSemVer($tag); }); + + $startVersion = $a; $endVersion = $b; $prefix = 'v'; @@ -88,6 +90,7 @@ public static function buildLog($a, $b = 'HEAD', $with_head = true) { $endVersion = substr($endVersion, strlen($prefix)); } + $tags = array_filter($tags, function ($version) use ($startVersion, $endVersion) { $prefix = 'v'; if (substr($version, 0, strlen($prefix)) == $prefix) { @@ -120,17 +123,19 @@ public static function buildLog($a, $b = 'HEAD', $with_head = true) { $startRef = $endRef; } + $log = array_merge($log, self::buildLogOneBump($startRef, null , $with_head)); + return $log; } public static function buildLogOneBump($a, $b, $with_head = true) { $tag = $a; - if (!Git::tagExists($b)) { + /*if (!Git::tagExists($b)) { // $b is not a tag, try to find a matching one if ($tag = Git::getTagOfCommit($b) === false) { $tag = 'Unreleased'; } - } + }*/ // get remote $remotes = Git::getRemotes(); @@ -330,10 +335,18 @@ public static function createCommitList($commits) { } public static function getLog($a, $b = 'HEAD') { - exec("git log --oneline $a..$b", $output, $retCode); - if ($retCode != '0') { - // An error occured - throw new Exception("Unable to get log from the repository"); + if ($a === null) { + exec("git log --oneline $b", $output, $retCode); + if ($retCode != '0') { + // An error occured + throw new Exception("Unable to get log from the repository"); + } + } else { + exec("git log --oneline $a..$b", $output, $retCode); + if ($retCode != '0') { + // An error occured + throw new Exception("Unable to get log from the repository"); + } } return $output;