2

I have a multi module GitHub project which I would like to build using GitHub actions. The action script that I have written is a publish script that triggers when a tag is pushed. I need two things here that should work out, but before here is my project structure:

main-project:
 build.sbt
 module1:
   build.sbt
   src/main/scala/.... 
 module2:
   build.sbt
   src/main/scala/....

I need to have a mechanism check that does the following:

  1. When I push a tag, I will trigger my workflow and I would like that my workflow is only publishing module 1 changes

  2. Is there a way to git tag only module 1?

torek
  • 448,244
  • 59
  • 642
  • 775
joesan
  • 13,963
  • 27
  • 95
  • 232
  • 1
    Do you really have a build.sbt in each submodule? Usually we declare submodules in the root build.sbt and that's all. – Gaël J Jan 01 '23 at 09:03
  • 1
    I'd also argue that if your two submodules have different lifecycles (tags, versions..) they should probably be in different repos. – Gaël J Jan 01 '23 at 09:05
  • To avoid some clutter. I have build.sbt files in each module. – joesan Jan 01 '23 at 09:58
  • Here is the project that I'm working on: https://github.com/open-electrons/open-electrons-templates – joesan Jan 01 '23 at 10:08
  • The project is a collection of templates like g8, some sbt plugins. I already have publish skip for the root by default. I just added it to the other modules where I do not want it to publish. So now since I'm using tags for publishing, my action gets triggered only when I push an annotated tag. So this already helps. – joesan Jan 01 '23 at 10:12

2 Answers2

2

If your modules are on different paths within the same Git repository, you could use a path-filter action, as illustrated here.

Note that you cannot tag just a part of a repository, but, if your changes involves only that one module, you can then decide apply a (global) tag with a naming convention reflecting the nature of the change (IE only module1 or only module2).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • And if you have a naming convention on the tag, you can have a GitHub action to trigger only for this tag's pattern you're interested in. Like `module1-*` – Gaël J Jan 01 '23 at 10:41
2

If you only ever want to publish module1, you can set publish / skip := true in the project settings in build.sbt for other modules and the root project.

Gaël J
  • 11,274
  • 4
  • 17
  • 32