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

Release publishing #7

Merged
merged 3 commits into from
Sep 11, 2024
Merged

Release publishing #7

merged 3 commits into from
Sep 11, 2024

Conversation

cretz
Copy link
Contributor

@cretz cretz commented Sep 10, 2024

  • Added step for publishing to Maven/Sonatype Central
  • Added new GH workflow for preparing a release (making GH draft and publishing to staging area)

This workflow was confirmed to work through trial and error

@cretz cretz force-pushed the release-publishing branch 4 times, most recently from 266070c to 42ccff8 Compare September 10, 2024 18:03
@cretz cretz force-pushed the release-publishing branch from 42ccff8 to 2908c14 Compare September 10, 2024 18:05
@cretz cretz requested a review from a team September 10, 2024 18:06
@cretz cretz marked this pull request as ready for review September 10, 2024 18:06
@@ -30,3 +31,62 @@ spotless {
}

classes.dependsOn 'spotlessApply'

ext.getVersionName = { ->
def version = System.getenv('NEXUS_SDK_TAG')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is not really yet any value to the more advanced Temporal Java SDK approach of temporarily tagging and then git describe --tags to pull it right out. So our publishing step requires this env var instead.

@@ -2,6 +2,7 @@
plugins {
id 'java-library'
id 'com.diffplug.spotless'
id 'com.vanniktech.maven.publish' version '0.29.0'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is not good Gradle support for publishing on Central yet: https://central.sonatype.org/publish/publish-portal-gradle/. So https://github.com/vanniktech/gradle-maven-publish-plugin/ is the best of the available options based on trying multiple out.


import com.vanniktech.maven.publish.SonatypeHost

mavenPublishing {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

While technically some of this could be in the root project, the plugin didn't like that as much and this is the only project being published at this time. If/when we do add more JARs to this project, we can make some of this logic reusable.

Comment on lines +36 to +37
&& echo "::set-output name=already_exists::true" \
|| echo "::set-output name=already_exists::false"

Choose a reason for hiding this comment

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

This is the new way to setting step output.

Suggested change
&& echo "::set-output name=already_exists::true" \
|| echo "::set-output name=already_exists::false"
&& echo "already_exists=true" >> $GITHUB_OUTPUT \
|| echo "already_exists=false" >> $GITHUB_OUTPUT

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is taken from Java SDK repo, didn't want to deviate if I didn't have to

Comment on lines +50 to +56
gh release create
"$NEXUS_SDK_TAG"
--draft
--repo "$GITHUB_REPOSITORY"
--title "$NEXUS_SDK_TAG"
--target "$NEXUS_SDK_REF"
--generate-notes

Choose a reason for hiding this comment

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

Missing \ for the command line break

Copy link
Contributor Author

@cretz cretz Sep 10, 2024

Choose a reason for hiding this comment

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

This is not needed when using the > yaml multiline approach. This is taken from Java SDK repo, didn't want to deviate if I didn't have to.

Choose a reason for hiding this comment

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

Hm, I see. I like to keep things consistent, so I'd suggest changing the > to | as in other steps above, but a big deal either way.

--target "$NEXUS_SDK_REF"
--generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Choose a reason for hiding this comment

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

I think you need to set the permissions for the token to be able to create a release.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This workflow has been tested as successful both here and at the Java SDK repo where much of this was taken

Choose a reason for hiding this comment

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

Oh, interesting. This means the repo is set to give write permissions by default to the token.

Comment on lines +50 to +56
gh release create
"$NEXUS_SDK_TAG"
--draft
--repo "$GITHUB_REPOSITORY"
--title "$NEXUS_SDK_TAG"
--target "$NEXUS_SDK_REF"
--generate-notes

Choose a reason for hiding this comment

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

Hm, I see. I like to keep things consistent, so I'd suggest changing the > to | as in other steps above, but a big deal either way.

--target "$NEXUS_SDK_REF"
--generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Choose a reason for hiding this comment

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

Oh, interesting. This means the repo is set to give write permissions by default to the token.

@cretz cretz merged commit 1ac23aa into main Sep 11, 2024
1 check passed
@cretz cretz deleted the release-publishing branch September 11, 2024 14:41
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.

3 participants