Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue on creating new tag in gradle, local machine and github action #677

Closed
yuvaraj119 opened this issue Nov 6, 2023 · 5 comments
Closed

Comments

@yuvaraj119
Copy link

yuvaraj119 commented Nov 6, 2023

I create a tag manually using github release tag and once the tag is created i see in github action the cV becomes snapshot.
Using latest v1.15.5
gradle-7.5

./gradlew cV
Project version: 1.0.3-SNAPSHOT
./gradlew release
Creating tag: v1.0.3
$ git tag
v0.0.1
v1.0.0
v1.0.1
v1.0.2
v1.0.3

./gradlew cV
Project version: 1.0.4-SNAPSHOT

Here is my version gradle 
apply plugin: 'pl.allegro.tech.build.axion-release'

scmVersion {
    monorepo {
        projectDirs = project.subprojects.collect({ p -> p.name })
    }
    checks {
        uncommittedChanges.set(false)
        aheadOfRemote.set(false)
        snapshotDependencies.set(false)
    }
    repository {
        pushTagsOnly = true
        remote = "pushback"
    }
}

Issue here is after merging multiple feature, develop branches into main and then when i generate release tag this issue occurs.
If i do one commit directly to main then it works good and generates the given tag version.

@yuvaraj119 yuvaraj119 changed the title Issue on creating new tag Issue on creating new tag in gradle and github action Nov 6, 2023
@yuvaraj119 yuvaraj119 changed the title Issue on creating new tag in gradle and github action Issue on creating new tag in gradle, local machine and github action Nov 6, 2023
@bgalek
Copy link
Member

bgalek commented Nov 29, 2023

hi!
did you remembered to add fetch-depth: 0 to your checkout github action?

@yuvaraj119
Copy link
Author

hi!

did you remembered to add fetch-depth: 0 to your checkout github action?

Yes

@scprek
Copy link

scprek commented Jan 13, 2024

I have a similar issue even running the action on main directly. I do the release in the action, which creates/pushes the correct tags, but then publish adds snapshot to the artifacts

Even tho the tags are in the repo and pushed do I need to fetch again before doing the gradle publish?

@bgalek
Copy link
Member

bgalek commented Jan 14, 2024

@scprek do you create your release tasks using axion-release-plugin?

@scprek
Copy link

scprek commented Jan 14, 2024

So I believe the issue was me trying to be clever setting everything in subprojects block. I went through a ton of variations of setting up submodules in the most unified way. The only way I could reverse engineer what to do was via tasks.withType<BaseAxionTask>.

Breaking the docs rule I believe

keep in mind, that scmVersion must be initialized before scmVersion.version is accessed

Maybe we should add an example of how to best do this when not applying the plugin at the root level. I wanted to avoid having any root versioning/artifacts and simply use the repo has a mono repo for a collection of modules. No BOM or anything (See my struggle trying to disable the root one in any other way besides not applying the plugin #694). Does this seem reasonable?

Top level build.gradle.kts

plugins {
   id("pl.allegro.tech.build.axion-release") version "1.16.1" apply false
}

subprojects {
   plugins.apply("pl.allegro.tech.build.axion-release")


  tasks.withType<BaseAxionTask> {
      version = versionConfig.version // <-- This only works with release NOT cV and publish whoops! Moved to each module
  
      versionConfig.tag {
          prefix.set(project.name)
          versionSeparator.set("_")
      }
  
      versionConfig.branchVersionIncrementer.putAll(
          mapOf<String, Any>(
              "micronaut.*" to VersionProperties.Incrementer { c: VersionIncrementerContext -> c.currentVersion.incrementPatchVersion() }
          )
      )
  }
}

In module/build.gradle.kts

version = scmVersion.version

Result 🥳

Tags

Screenshot 2024-01-13 at 9 52 03 PM

Github Packges

NO MORE SNAPSHOT!!!!

Screenshot 2024-01-13 at 9 52 17 PM

@bgalek bgalek closed this as completed Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants