Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c4190a61 authored by Corey Bryant's avatar Corey Bryant Committed by Philipp Kewisch
Browse files

Allow different release notes in k9mail vs thunderbird



Co-authored-by: default avatarPhilipp Kewisch <mozilla@kewis.ch>
parent cda4357c
Loading
Loading
Loading
Loading
+32 −13
Original line number Diff line number Diff line
@@ -180,6 +180,8 @@ jobs:
    outputs:
      k9mail_sha: ${{ steps.commit.outputs.k9mail_sha }}
      thunderbird_sha: ${{ steps.commit.outputs.thunderbird_sha }}
      k9mail_github_notes: ${{ steps.render_notes.outputs.k9mail_github_notes }}
      thunderbird_github_notes: ${{ steps.render_notes.outputs.thunderbird_github_notes }}
    steps:
      - name: Checkout repository
        if: ${{ contains(matrix.releaseTarget, 'github') }}
@@ -257,18 +259,30 @@ jobs:
          cat $GITHUB_OUTPUT

      - name: Render Release Notes
        id: render_notes
        if: ${{ contains(matrix.releaseTarget, 'github') }}
        shell: bash
        env:
          APP_NAME: ${{ matrix.appName }}
          APPLICATION_ID: ${{ steps.appinfo.outputs.APPLICATION_ID }}
          APPLICATION_LABEL: ${{ steps.appinfo.outputs.APPLICATION_LABEL }}
          VERSION_CODE: ${{ steps.bump_version_code.outputs.CODE }}
          FULL_VERSION_NAME: ${{ steps.appinfo.outputs.VERSION_NAME }}${{ steps.bump_version_suffix.outputs.SUFFIX || steps.appinfo.outputs.VERSION_NAME_SUFFIX }}
        run: |
          echo "<h2>${APPLICATION_LABEL} ${FULL_VERSION_NAME} Release Notes (${VERSION_CODE})</h2><pre>" | tee -a $GITHUB_STEP_SUMMARY
          mkdir -p ./app-metadata/${APPLICATION_ID}/en-US/changelogs
          python ./scripts/render-notes.py ${APPLICATION_ID} ${FULL_VERSION_NAME} ${VERSION_CODE} | tee -a $GITHUB_STEP_SUMMARY
          echo "</pre>" | tee -a $GITHUB_STEP_SUMMARY
          GITHUB_NOTES_FILE="$(mktemp -d)/long-notes.txt"
          python ./scripts/render-notes.py ${APPLICATION_ID} ${FULL_VERSION_NAME} ${VERSION_CODE} ${GITHUB_NOTES_FILE}

          echo "${APP_NAME}_github_notes<<EOF" >> $GITHUB_OUTPUT
          cat $GITHUB_NOTES_FILE >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT

          echo "<h2>${APPLICATION_LABEL} ${FULL_VERSION_NAME} Release Notes (${VERSION_CODE})</h2>" | tee -a $GITHUB_STEP_SUMMARY
          echo -e "Summarized Version Notes\n\n\`\`\`" | tee -a $GITHUB_STEP_SUMMARY
          cat ./app-metadata/${APPLICATION_ID}/en-US/changelogs/${VERSION_CODE}.txt | tee -a $GITHUB_STEP_SUMMARY
          echo -e "\n\`\`\`\n\nLong Version Notes\n\n\`\`\`" | tee -a $GITHUB_STEP_SUMMARY
          cat $GITHUB_NOTES_FILE | tee -a $GITHUB_STEP_SUMMARY
          echo -e "\`\`\`" | tee -a $GITHUB_STEP_SUMMARY

      - name: Validate Release Notes Length
        if: ${{ contains(matrix.releaseTarget, 'github') }}
@@ -639,20 +653,24 @@ jobs:
          app-id: ${{ vars.RELEASER_APP_CLIENT_ID }}
          private-key: ${{ secrets.RELEASER_APP_PRIVATE_KEY }}

      - name: Get release sha
        id: sha
      - name: Get release sha and notes
        id: shanotes
        shell: bash
        env:
          THUNDERBIRD_GITHUB_NOTES: ${{ needs.release_commit.outputs.thunderbird_github_notes }}
          K9MAIL_GITHUB_NOTES: ${{ needs.release_commit.outputs.k9mail_github_notes }}
          THUNDERBIRD_SHA: ${{ needs.release_commit.outputs.thunderbird_sha }}
          K9MAIL_SHA: ${{ needs.release_commit.outputs.k9mail_sha }}
          APP_NAME: ${{ matrix.appName }}
        run: |
          case "${APP_NAME}" in
            thunderbird) APP_SHA=$THUNDERBIRD_SHA ;;
            k9mail) APP_SHA=$K9MAIL_SHA ;;
          esac
          app_sha_name=${APP_NAME^^}_SHA
          echo "app_sha=${!app_sha_name}" >> $GITHUB_OUTPUT

          app_relnotes_name=${APP_NAME^^}_GITHUB_NOTES
          echo "app_github_notes<<EOF" >> $GITHUB_OUTPUT
          echo "${!app_relnotes_name}" >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT

          echo "app_sha=$APP_SHA" >> $GITHUB_OUTPUT
          cat $GITHUB_OUTPUT

      - name: Publish to GitHub Releases
@@ -661,9 +679,10 @@ jobs:
        uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191  # v2.0.8
        with:
          token: ${{ steps.app-token.outputs.token || github.token }}
          target_commitish: ${{ steps.sha.outputs.app_sha }}
          target_commitish: ${{ steps.shanotes.outputs.app_sha }}
          tag_name: ${{ steps.pkginfo.outputs.TAG_NAME }}
          name: ${{ steps.pkginfo.outputs.FULL_VERSION_NAME }}
          body: ${{ steps.shanotes.outputs.app_github_notes }}
          prerelease: ${{ env.RELEASE_TYPE != 'release' }}
          fail_on_unmatched_files: true
          files: |
@@ -676,7 +695,7 @@ jobs:
          VERSION_CODE: ${{ steps.pkginfo.outputs.VERSION_CODE }}
          APPLICATION_ID: ${{ steps.pkginfo.outputs.APPLICATION_ID }}
          REPO: ${{ github.repository }}
          APP_SHA: ${{ steps.sha.outputs.app_sha }}
          APP_SHA: ${{ steps.shanotes.outputs.app_sha }}
        run: |
          # r0adkll/upload-google-play expects the release notes in a different structure
          FILEPATH=app-metadata/${APPLICATION_ID}/en-US/changelogs/${VERSION_CODE}.txt
@@ -708,7 +727,7 @@ jobs:
          playTargetTrack: ${{ matrix.playTargetTrack }}
          applicationId: ${{ steps.pkginfo.outputs.APPLICATION_ID }}
          releaseTarget: ${{ matrix.releaseTarget }}
          appSha: ${{ steps.sha.outputs.app_sha }}
          appSha: ${{ steps.shanotes.outputs.app_sha }}
          appName: ${{ matrix.appName }}
        with:
          script: |
+49 −15
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import argparse
import os
import requests
import yaml
import time

from jinja2 import Template

@@ -13,11 +14,16 @@ def render_notes(
    versioncode,
    application,
    applicationid,
    printonly=False,
    longform_file,
    print_only=False,
    notesrepo="thunderbird/thunderbird-notes",
    notesbranch="master",
):
    """Update changelog files based on release notes from thunderbird-notes."""
    """Render release notes from thunderbird-notes

    Update changelog files based on short release notes from thunderbird-notes.
    Render long-form notes to specified file,
    """
    tb_notes_filename = f"{version}.yml"
    tb_notes_directory = "android_release"
    if "0b" in version:
@@ -28,7 +34,7 @@ def render_notes(
        f"refs/heads/{notesbranch}",
        tb_notes_directory,
        tb_notes_filename,
    )
    ) + "?token=" + str(int(time.time()))

    response = requests.get(tb_notes_url)
    response.raise_for_status()
@@ -42,13 +48,25 @@ def render_notes(
        render_data["releases"][vers]["versioncode"] = int(versioncode)
        render_data["releases"][vers]["application"] = application
        render_data["releases"][vers]["date"] = release["release_date"]
        render_data["releases"][vers]["changes"] = []
        render_data["releases"][vers]["short_notes"] = []
        render_data["releases"][vers]["notes"] = {}
        for note in yaml_content["notes"]:
            if "0b" in version:
                if note["group"] == int(vers[-1]):
                    render_data["releases"][vers]["changes"].append(note["note"])
            else:
                render_data["releases"][vers]["changes"].append(note["note"])
            if ("0b" not in version) or (
                "0b" in version and note["group"] == int(vers[-1])
            ):
                if (
                    note.get("thunderbird_only", False) and application == "k9mail"
                ) or (note.get("k9mail_only", False) and application == "thunderbird"):
                    continue
                if "note" in note:
                    tag = note["tag"].lower().capitalize()
                    if tag not in render_data["releases"][vers]["notes"]:
                        render_data["releases"][vers]["notes"][tag] = []
                    render_data["releases"][vers]["notes"][tag].append(note["note"].strip())
                if "short_note" in note:
                    render_data["releases"][vers]["short_notes"].append(
                        note["short_note"].strip()
                    )

    render_files = {
        "changelog_master": {
@@ -56,11 +74,16 @@ def render_notes(
            "outfile": f"./app-{application}/src/main/res/raw/changelog_master.xml",
            "render_data": render_data["releases"][version],
        },
        "changelog.txt": {
        "changelog": {
            "template": "./scripts/templates/changelog.txt",
            "outfile": f"./app-metadata/{applicationid}/en-US/changelogs/{versioncode}.txt",
            "render_data": render_data["releases"][version],
        },
        "changelog_long": {
            "template": "./scripts/templates/changelog_long.txt",
            "outfile": longform_file,
            "render_data": render_data["releases"][version],
        },
    }

    for render_file in render_files:
@@ -77,15 +100,22 @@ def render_notes(
                            break
                        lines.insert(index + 1, rendered)
                        break
            if not printonly:
            if print_only:
                print(f"\n==={render_files[render_file]['outfile']}===")
                print("...")
                print(rendered)
                print("...")
            else:
                with open(render_files[render_file]["outfile"], "w") as file:
                    file.writelines(lines)
        elif render_file == "changelog.txt":
        elif render_file == "changelog" or render_file == "changelog_long":
            stripped = rendered.lstrip()
            if not printonly:
            if print_only:
                print(f"\n==={render_files[render_file]['outfile']}===")
                print(stripped)
            else:
                with open(render_files[render_file]["outfile"], "x") as file:
                    file.write(stripped)
            print(stripped)


def main():
@@ -120,6 +150,9 @@ def main():
    )
    parser.add_argument("version", type=str, help="Version name for this release")
    parser.add_argument("versioncode", type=str, help="Version code for this release")
    parser.add_argument(
        "longform_file", type=str, help="File to render long-form notes to"
    )
    args = parser.parse_args()

    if args.applicationid == "com.fsck.k9":
@@ -132,7 +165,8 @@ def main():
        args.versioncode,
        application,
        args.applicationid,
        printonly=args.print,
        args.longform_file,
        print_only=args.print,
        notesrepo=args.repository,
        notesbranch=args.branch,
    )
+1 −2
Original line number Diff line number Diff line
{%- if application == 'thunderbird' -%}
Thunderbird for Android version {{ version }}, based on K-9 Mail. Changes include:
{%- endif -%}
{%- for note in changes %}
{%- for note in short_notes %}
- {{ note }}
{%- endfor %}
+7 −0
Original line number Diff line number Diff line
{% for tag, long_notes in notes.items() %}
{{ tag }}:
{%- for note in long_notes %}
- {{ note }}
{%- endfor %}

{% endfor %}
+1 −2
Original line number Diff line number Diff line
    <release version="{{ version }}" versioncode="{{ versioncode }}" date="{{ date }}">
{%- for note in changes %}
{%- for note in short_notes %}
        <change>{{ note }}</change>
{%- endfor %}
    </release>