Skip to content

Commit

Permalink
Automate more of the release process
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed Jun 17, 2024
1 parent 80977e9 commit 9a8a4c8
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 39 deletions.
53 changes: 18 additions & 35 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ curl -o /c/opt/flatpak-cargo-generator.py https://raw.githubusercontent.com/flat
pip install aiohttp toml
```

Also install the Crowdin CLI manually.
Also install the Crowdin and `yq` CLI tools manually.

#### Process
* Update version in CHANGELOG.md
Expand All @@ -70,44 +70,27 @@ Also install the Crowdin CLI manually.
* Add the new version to `.github/ISSUE_TEMPLATE/*.yaml`.
* Update the documentation if necessary for any new features.
Check for any new content that needs to be uncommented (`<!--`).
* Run:
```
export VERSION=$(invoke version)
git add .
git commit -m "Release v${VERSION}"
git tag v${VERSION} -m "Release"
git push
git push --tags
```
* Run: `cargo publish`
* Create a release on GitHub and attach the workflow build artifacts
(plus `dist/*-legal.zip`).

#### Publish
Commands assume you've set `VERSION=$(invoke version)`.

* Flatpak:
* Use fork of https://github.com/flathub/com.github.mtkennerly.ludusavi .
* From master, create a new branch (`release/v${VERSION}`).
* Update `com.github.mtkennerly.ludusavi.yaml` to reference the new tag.
* Replace `generated-sources.json` (new file produced by `invoke prerelease` earlier).
* Open a pull request.
* Recommended commit message and PR title:
`Update for v${VERSION}`
* Run `git add` for all relevant changes
* Run `invoke release`
* This will create a new commit/tag and push them.
* Manually create a release on GitHub and attach the workflow build artifacts
(plus `dist/*-legal.zip`).
* Run `cargo publish`
* Run `invoke release-flatpak`
* This will automatically push a branch to https://github.com/flathub/com.github.mtkennerly.ludusavi .
* Manually open a PR for that branch.
* After the PR is merged, publish via https://buildbot.flathub.org/#/apps/com.github.mtkennerly.ludusavi .
* winget:
* Use fork of https://github.com/microsoft/winget-pkgs .
* From master, create a new branch (`mtkennerly.ludusavi-${VERSION}`).
* Run `wingetcreate update mtkennerly.ludusavi --version ${VERSION} --urls https://github.com/mtkennerly/ludusavi/releases/download/v${VERSION}/ludusavi-v${VERSION}-win64.zip https://github.com/mtkennerly/ludusavi/releases/download/v${VERSION}/ludusavi-v${VERSION}-win32.zip`
* In the generated `manifests/m/mtkennerly/ludusavi/${VERSION}/mtkennerly.ludusavi.locale.en-US.yaml` file,
add the `ReleaseNotes` and `ReleaseNotesUrl` fields:
* Run `invoke release-winget`
* When the script opens VSCode and pauses,
manually edit `manifests/m/mtkennerly/ludusavi/${VERSION}/mtkennerly.ludusavi.locale.en-US.yaml`
to add the `ReleaseNotes` and `ReleaseNotesUrl` fields:

```yaml
ReleaseNotes: |-
<copy/paste from CHANGELOG.md>
ReleaseNotesUrl: https://github.com/mtkennerly/ludusavi/releases/tag/v${VERSION}
```
* Run `winget validate --manifest manifests/m/mtkennerly/ludusavi/${VERSION}`
* Open a pull request.
* Recommended commit message and PR title:
`mtkennerly.ludusavi version ${VERSION}`
Close the file, and the script will continue.
* This will automatically push a branch to a fork of https://github.com/microsoft/winget-pkgs .
* Manually open a pull request for that branch.
57 changes: 53 additions & 4 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,22 @@
LANG = ROOT / "lang"


def get_version(ctx) -> str:
return ctx.run('cargo pkgid', hide=True).stdout.split("#")[-1].strip()
def get_version() -> str:
for line in (ROOT / "Cargo.toml").read_text("utf-8").splitlines():
if line.startswith("version ="):
return line.replace("version = ", "").strip('"')

return "0.0.0"


@task
def version(ctx):
print(get_version(ctx))
print(get_version())


@task
def legal(ctx):
version = get_version(ctx)
version = get_version()
txt_name = f"ludusavi-v{version}-legal.txt"
txt_path = ROOT / "dist" / txt_name
try:
Expand Down Expand Up @@ -144,3 +148,48 @@ def prerelease(ctx, update_lang=True):
docs(ctx)
if update_lang:
lang(ctx)


@task
def release(ctx):
version = get_version()
ctx.run(f'git commit -m "Release v{version}"')
ctx.run(f'git tag v{version} -m "Release"')
ctx.run("git push")
ctx.run("git push --tags")


@task
def release_flatpak(ctx, target="/git/com.github.mtkennerly.ludusavi"):
target = Path(target)
version = get_version()

os.chdir(target)
ctx.run("git checkout master")
ctx.run("git pull")
ctx.run(f"git checkout -b release/v{version}")
shutil.copy(DIST / "generated-sources.json", target / "generated-sources.json")
ctx.run(f"yq -i '.modules.0.sources.0.tag = \"v{version}\"' com.github.mtkennerly.ludusavi.yaml")
ctx.run(f'git commit -m "Update for v{version}"')
ctx.run("git push origin HEAD")

os.chdir(ROOT)


@task
def release_winget(ctx, target="/git/_forks/winget-pkgs"):
target = Path(target)
version = get_version()

os.chdir(target)
ctx.run("git checkout master")
ctx.run("git pull upstream master")
ctx.run(f"git checkout -b mtkennerly.ludusavi-{version}")
ctx.run(f"wingetcreate update mtkennerly.ludusavi --version {version} --urls https://github.com/mtkennerly/ludusavi/releases/download/v{version}/ludusavi-v{version}-win64.zip https://github.com/mtkennerly/ludusavi/releases/download/v{version}/ludusavi-v{version}-win32.zip")
ctx.run(f"code --wait manifests/m/mtkennerly/ludusavi/{version}/mtkennerly.ludusavi.locale.en-US.yaml")
ctx.run(f"winget validate --manifest manifests/m/mtkennerly/ludusavi/{version}")
ctx.run("git add .")
ctx.run(f'git commit -m "mtkennerly.ludusavi version {version}"')
ctx.run("git push origin HEAD")

os.chdir(ROOT)

0 comments on commit 9a8a4c8

Please sign in to comment.