filipdutescu / modern-cpp-template

A template for modern C++ projects using CMake, Clang-Format, CI, unit testing and more, with support for downstream inclusion.
The Unlicense
1.69k stars 214 forks source link

[FEATURE] Release workflow for github #4

Closed thebino closed 4 years ago

thebino commented 4 years ago

Is your feature request related to a problem? Please describe. No one should do manual deployments.

Describe the solution you'd like Create a new tag or push on a release branch to trigger an automated release

Provide usage examples There are already actions for the different tasks available: https://github.com/actions/create-release https://github.com/actions/upload-release-asset

And filtering for specific branches and tags can be achieved by:

on:
  push:
    branches:    
      - master
    tags:        
      - v1

P.S.: Amazing work on the template. Working on a similar approach but using a strategy matrix https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix

filipdutescu commented 4 years ago

@thebino, thank you very much for both the kind words and the request. I was not familiar with this type of workflow, but it does make sense. I wish you the best with your template, really nice to have options for the community, I think it is great for the ecosystem.

Now, regarding the actual feature request. I want for the template to require minimal dependencies, or at least as few as possible, but from the links you provided, it seems like it can all take place in GitHub, no 3rd parties involved. Correct me if I am wrong, but it also allows for easily swapping GH with other platforms, right?

I do have an additional issue with this approach. Since C++ projects need to be compiled on a per-platform/architecture basis, how would you go about releasing on multiple platforms at once, without creating such an Action for each and their respective architectures?

Other than this I do like your request and if we can clear out stuff like this (should more come up), I do want to add it to the template. Thank you once more for your involvement, much appreciated!

thebino commented 4 years ago

If github supports workflow dependencies, you could create a release before starting the builds and upload the build artifacts to it. Another solution I can imagine could be uploading each platform to a different release.

filipdutescu commented 4 years ago

@thebino, I think it would be a bit hard to manage one action/platform + architecture. I think it is a bit easier to group all into one action, which handles releasing.

I do agree, workflow dependencies would be preferred over the aforementioned approach. I do have a couple more ideas, if you don't mind giving me some input.

  1. Add a job for each platform/architecture, and then upload each jobs artefact to the release made by the first job which was ran (if this is possible, I cannot find good docs on upload-release-asset regarding if you can upload multiple times, with it just adding more artefacts to an existing release).

  2. Do what TensorFlow does, for example, meaning the only asset of releases being the zipped source code.

What do you think? Got any other suggestions?

filipdutescu commented 4 years ago

After rereading Upload a release asset from the docs, I think it is possible to just upload as many artefact as you wish, granted you do not do it at a higher rate than permitted and they are not named the same, so it seems possible to implement no. 1 (Add a job for each platform/architecture...).

thebino commented 4 years ago

I used a single github workflow, up- and downloaded the artifacts in a separate job and published them to as artifact to a new release

    - name: Upload to Release
      uses: meeDamian/github-release@2.0
      with:
        files: >
          Windows-MSVC.tar.xz
          Windows-MinGW.tar.xz
          Linux.tar.xz
          macOS.tar.xz
filipdutescu commented 4 years ago

@thebino could you leave me a link to the repo/actions so I can use them as reference? Thanks.

thebino commented 4 years ago

I just published a minimal sample where you can also see the release step triggered by a pushed tag: https://github.com/thebino/CmakeGithubAction/actions

Also I tried to add a workflow to your project, perhaps you can take over ;) https://github.com/filipdutescu/modern-cpp-template/pull/5

filipdutescu commented 4 years ago

Many thanks for all the help provided and your contribution as well! Will take a look tomorrow, aiming for a proper review as well. If all good, maybe I adapt it a bit, if necessary, I will integrate it in the template.