Skip to content

Commit

Permalink
feat(build): update ChangeLog
Browse files Browse the repository at this point in the history
  • Loading branch information
stonebuzz committed Aug 31, 2023
1 parent 4ed1579 commit 31b688f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/release-new-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -50,6 +53,23 @@ jobs:
#####################
# Prepare release #
#####################
- name: "Extract Full ChangeLog (Conventional Commit)"
run: |
{
echo 'full_change_log<<EOF'
./vendor/bin/robo build:log 0.9 HEAD
echo EOF
} >> "$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
message: "ci(release): release new version ${{ env.tag_name }}"

- name: "Extract Clean Git Log (Conventional Commit)"
run: |
{
Expand Down
25 changes: 19 additions & 6 deletions RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public static function buildLog($a, $b = 'HEAD', $with_head = true) {
return Semver::isSemVer($tag);
});



$startVersion = $a;
$endVersion = $b;
$prefix = 'v';
Expand All @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 31b688f

Please sign in to comment.