antonreshetov / image-optimizer

A tool for optimizing images and vector graphics.
MIT License
888 stars 63 forks source link

ci: github action for mac, windows, and linux releases #25

Open Christopher-Hayes opened 2 years ago

Christopher-Hayes commented 2 years ago

Description

This creates a release.yml that runs a GitHub action when a tag (such as v1.3.3) is pushed to build releases for MacOS, Windows, and Linux.

MacOS: .dmg

Windows: .exe

Linux: .snap and .AppImage

Updated the README to provide useful info on how to install different releases. Might need to be split off into a separate Markdown file or shortened, since it's a little verbose.

Example Release on Fork

Here's an example of a release this action produced on my fork of this repo:

https://github.com/Christopher-Hayes/image-optimizer/releases/tag/v1.3.8

To produce that release, I ran this:

git add -A # Updated the version in the package.json
git commit -m "chore: new v1.3.8 release"
git tag v1.3.8
git push && git push --tags

When the GitHub Action finishes, it creates a "draft" release for the "v1.3.8" tag with all the release files, you'll just need to manually go to that release in GitHub and "publish" it.

Here are the details of that Action running: https://github.com/Christopher-Hayes/image-optimizer/actions/runs/2444457428

GitHub Action

Uses this electron-builder GH Action: https://github.com/samuelmeuli/action-electron-builder

That GitHub Action requires that yarn build does not run electron-builder, that it only builds the frontend. The GitHub Action separately runs the electron-builder. So, this PR needed to do some refactoring to meet that requirement:

GitHub Secrets

MacOS code-signing can be accomplished by adding the following GitHub secrets:

Required for MacOS development, so these GitHub secrets should be in place.

mac_certs The base64 encoded .p12 certificate.

mac_certs_password The password to the certificate above.

This doc talks about how to set the cert up: https://samuelmeuli.com/blog/2019-04-07-packaging-and-publishing-an-electron-app/#code-signing

The GitHub Action README describes how to put that cert into a GitHub Secret: https://github.com/samuelmeuli/action-electron-builder

If pushing builds to Snapcraft (Linux .snap marketplace) is desired, a token should be created and set on this GitHub secret:

Snaps work just fine without using Snapcraft, and I haven't set this fully up. So, this is an optional feature that can safely be ignored.

snapcraft_token

This doc talks about how to do that: https://abskmj.github.io/notes/posts/github/actions/setup-snapcraft/

Testing on Fork

Manual steps required to get working on antonreshetov/image-optimizer

Misc Notes

There's a PR (#19) for building on Windows. I believe this PR should still be compatible with that PR.

closes #18

antonreshetov commented 2 years ago

@Christopher-Hayes Wow, so much work done. I'll be sure to check it out.

P.S. better of course first discuss before you start work, because it may be so that the work was in vain.

Christopher-Hayes commented 2 years ago

@antonreshetov you're right, I was thinking it would be quick little yaml file, but became a bit more complicated than expected 😁 Though, I'll admit the commit count is a bit high because I had to push commits to test the GitHub Action.

Feel free to comment on any lines you want to me to explain the reasoning behind.