diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 62fd4f78..9effbac5 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -24,24 +24,28 @@ jobs: branch-major: ${{ steps.branchnames.outputs.major-branch }} branch-minor: ${{ steps.branchnames.outputs.minor-branch }} branch-patch: ${{ steps.branchnames.outputs.patch-branch }} + previous-tag: ${{ steps.getprevioustag.outputs.previous-tag }} steps: - name: Check out code uses: actions/checkout@v3 with: fetch-depth: 0 + tags: true - name: Get Previous Tag - id: previoustag - uses: "WyriHaximus/github-action-get-previous-tag@v1" - with: - fallback: 0.0.0 + id: getprevioustag + run: | + previous_tag=$(git describe --tags $(git rev-list --tags --max-count=1)) + echo "Previous Tag: $previous_tag" + echo "previous_tag=$previous_tag" >> $GITHUB_ENV + echo "::set-output name=previous-tag::$previous_tag" - name: Get Next Versions id: nexttag uses: "WyriHaximus/github-action-next-semvers@v1" with: - version: ${{ steps.previoustag.outputs.tag }} + version: ${{ steps.getprevioustag.outputs.previous-tag }} - name: Build Branch Names id: branchnames @@ -105,46 +109,88 @@ jobs: if: ${{ github.event.inputs.release-type == 'major' }} run: | new_version=${{ needs.determine-next-versions.outputs.next-major }} + awk -v new_version="$new_version" ' + { + if ($0 ~ /^ s.version/) { + print " s.version = \x27" new_version "\x27" + } else { + print $0 + } + }' ios/passage_flutter.podspec > temp_podspec.podspec + mv temp_podspec.podspec ios/passage_flutter.podspec sed -i "s/version: .*/version: $new_version/" pubspec.yaml - sed -i "s/s.version = '.*'/s.version = '$new_version'/" ios/passage_flutter.podspec echo "Updated to major version $new_version" - name: Update minor version in pubspec.yaml and podspec if: ${{ github.event.inputs.release-type == 'minor' }} run: | new_version=${{ needs.determine-next-versions.outputs.next-minor }} + awk -v new_version="$new_version" ' + { + if ($0 ~ /^ s.version/) { + print " s.version = \x27" new_version "\x27" + } else { + print $0 + } + }' ios/passage_flutter.podspec > temp_podspec.podspec + mv temp_podspec.podspec ios/passage_flutter.podspec sed -i "s/version: .*/version: $new_version/" pubspec.yaml - sed -i "s/s.version = '.*'/s.version = '$new_version'/" ios/passage_flutter.podspec echo "Updated to minor version $new_version" - name: Update patch version in pubspec.yaml and podspec if: ${{ github.event.inputs.release-type == 'patch' }} run: | new_version=${{ needs.determine-next-versions.outputs.next-patch }} + awk -v new_version="$new_version" ' + { + if ($0 ~ /^ s.version/) { + print " s.version = \x27" new_version "\x27" + } else { + print $0 + } + }' ios/passage_flutter.podspec > temp_podspec.podspec + mv temp_podspec.podspec ios/passage_flutter.podspec sed -i "s/version: .*/version: $new_version/" pubspec.yaml - sed -i "s/s.version = '.*'/s.version = '$new_version'/" ios/passage_flutter.podspec echo "Updated to patch version $new_version" - - name: Update CHANGELOG.md - major release + - name: Prepend to CHANGELOG.md - major release if: ${{ github.event.inputs.release-type == 'major' }} run: | new_version=${{ needs.determine-next-versions.outputs.next-major }} - echo "## $new_version\n\n- Description of changes\n" >> CHANGELOG.md - echo "Updated CHANGELOG.md with version $new_version" - - - name: Update CHANGELOG.md - minor release + previous_tag=${{ needs.determine-next-versions.outputs.previous-tag }} + git fetch --tags + git fetch --all + git log -1 + release_notes=$(git log --pretty=format:"* %s" $previous_tag..HEAD) + echo "Release Notes: $release_notes" + echo -e "## $new_version\n\n$release_notes\n\n$(cat CHANGELOG.md)" > CHANGELOG.md + echo "Prepended CHANGELOG.md with version $new_version" + + - name: Prepend to CHANGELOG.md - minor release if: ${{ github.event.inputs.release-type == 'minor' }} run: | new_version=${{ needs.determine-next-versions.outputs.next-minor }} - echo "## $new_version\n\n- Description of changes\n" >> CHANGELOG.md - echo "Updated CHANGELOG.md with version $new_version" - - - name: Update CHANGELOG.md - patch release + previous_tag=${{ needs.determine-next-versions.outputs.previous-tag }} + git fetch --tags + git fetch --all + git log -1 + release_notes=$(git log --pretty=format:"* %s" $previous_tag..HEAD) + echo "Release Notes: $release_notes" + echo -e "## $new_version\n\n$release_notes\n\n$(cat CHANGELOG.md)" > CHANGELOG.md + echo "Prepended CHANGELOG.md with version $new_version" + + - name: Prepend to CHANGELOG.md - patch release if: ${{ github.event.inputs.release-type == 'patch' }} run: | new_version=${{ needs.determine-next-versions.outputs.next-patch }} - echo "## $new_version\n\n- Description of changes\n" >> CHANGELOG.md - echo "Updated CHANGELOG.md with version $new_version" + previous_tag=${{ needs.determine-next-versions.outputs.previous-tag }} + git fetch --tags + git fetch --all + git log -1 + release_notes=$(git log --pretty=format:"* %s" $previous_tag..HEAD) + echo "Release Notes: $release_notes" + echo -e "## $new_version\n\n$release_notes\n\n$(cat CHANGELOG.md)" > CHANGELOG.md + echo "Prepended CHANGELOG.md with version $new_version" - name: Commit major version change uses: stefanzweifel/git-auto-commit-action@v4