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

output released version in github actions environement #737

Merged
merged 6 commits into from
Apr 30, 2024

Conversation

bgalek
Copy link
Collaborator

@bgalek bgalek commented Apr 19, 2024

No description provided.

@bgalek bgalek force-pushed the github-action-output branch 4 times, most recently from 7615490 to e222019 Compare April 19, 2024 15:15
@bgalek bgalek force-pushed the github-action-output branch 3 times, most recently from 1c64c9d to 60e5b03 Compare April 19, 2024 15:31

if (isGitHubWorkflowContext()) {
def gitHubOutputFile = new File(System.getenv('GITHUB_OUTPUT'))
"current-version=${outputContent}\n" >> gitHubOutputFile
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do it here, it will still require to explicitly run ./gradlew currentVersion task to produce the step output with current version. I would prefer it to happen during every ./gradlew release (only we would need to rename the output variable to released-version).

Alternatively, outputting the current-version seems like a very general (yet useful) feature that I would like to have on every ./gradlew execution. I can think of it as a responsibility of the setup-gradle action, not any plugin (let actions do Github stuff and plugins do Gradle stuff). It could be implemented like this:

// init.gradle.kts

rootProject {
    afterEvaluate {
        File(System.getenv('GITHUB_OUTPUT')).writeText("current-version=$version)
    }
}

This solution also doesn't require bumping axion-release plugin in every repo, we only need to remove the Read released version step (and maybe rename the output variable)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We won't need to init.gradle in our case, so I think we should implement this feature here anyway - to be used in the future ;)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementing it here will require you to apply axion-release plugin if you want to use the reusable workflow java-package. IMO it should be done in our setup-gradle action so any other plugin for reading version from nearest tag (or even git describe) can be used- the current-version output will just always be present in every step executing ./gradlew

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but I think this feature can be separated from our usecase

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline - let's do it as described in my first proposition:

I would prefer it to happen during every ./gradlew release (only we would need to rename the output variable to released-version).

So basically: move it to release task and rename from current-version to released-version

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@radoslaw-panuszewski code updated!

@bgalek bgalek force-pushed the github-action-output branch 2 times, most recently from b3f166c to 0e4197a Compare April 21, 2024 16:57
@bgalek bgalek force-pushed the github-action-output branch 2 times, most recently from 5add7c4 to 8ba29a0 Compare April 25, 2024 19:30
@bgalek bgalek marked this pull request as ready for review April 29, 2024 07:14
@bgalek bgalek changed the title output current version in github actions environement output released version in github actions environement Apr 29, 2024
@@ -34,6 +39,24 @@ class SimpleIntegrationTest extends BaseIntegrationTest {
result.task(":currentVersion").outcome == TaskOutcome.SUCCESS
}

def "should define an github output when running release task in github workflow context"() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an -> a

@bgalek bgalek merged commit d4fff1e into main Apr 30, 2024
1 check passed
@rafalh
Copy link
Contributor

rafalh commented May 2, 2024

I think you should add some info about this feature in docs. I would not expect gradle plugin to mess with github variables under the hood so it may be trickier to analyse what is happening in CI for people who do not know about this change. Good docs would probably help.
I assume this is something people are supposed to use and not some kind of PoC (in the letter case having it undocumented would make sense)

@bgalek
Copy link
Collaborator Author

bgalek commented May 3, 2024

Yes, I'm going to update docs

@bgalek
Copy link
Collaborator Author

bgalek commented May 3, 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

Successfully merging this pull request may close these issues.

None yet

5 participants