gperdomor / nx-tools

Nx Workspaces builders and tools
MIT License
356 stars 56 forks source link

Tagging dosent seem to infer semver for independant tags #972

Open fjanicki opened 8 months ago

fjanicki commented 8 months ago

Hi,

I am using the new release module in NX to tag my individual apps and use the following pattern, as suggested by the NX docs: release/{projectName}/{version}. However I cannot make the tags work for this. I tried with the following pattern:

    "container": {
      "executor": "@nx-tools/nx-container:build",
      "options": {
        "build-args": ["APP_NAME={projectName}"],
        "target": "release",
        "file": "{workspaceRoot}/Dockerfile",
        "engine": "docker",
        "metadata": {
          "images": ["-redacted-.dkr.ecr.-redacted-1.amazonaws.com/{projectName}"],
          "load": true,
          "flavor": ["latest=auto"],
          "tags": [
            "type=schedule",
            "type=ref,event=tag",
            "type=ref,event=pr",
            "type=match,pattern=release/{projectName}/(\\d+\\.\\d+\\.\\d+)(?!-)/i,group=1",
            "type=match,pattern=release/{projectName}/(\\d+\\.\\d+)\\.\\d+(?!-)/i,group=1",
            "type=match,pattern=release/{projectName}/(\\d+)\\.\\d+\\.\\d+(?!-)/i,group=1",
            "type=sha"
          ]
        }
      }
    }

But when running locally and after pushing the git tags to origin, I end up with 2 tags: the name of my current branch and the git SHA. The regex seems to work according to regex101 so I am a bit lost here on what to do next.

fjanicki commented 8 months ago

I think I misunderstood how this works. I thought it would read the last tag and build the docker container with this tag as I wanted to make it part of the same build step. I changed my pipeline to have the merge event in main to auto create a tag and add a only: tag to the build pipeline and this tags properly.

CaporalDead commented 7 months ago

Hi @fjanicki, I'm trying to achieve the same goal. Can you please share your project.json config and your pipeline config ? Thanks a lot !