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

feat: add semanatic release setup #46

Merged
merged 4 commits into from
Feb 8, 2024
Merged

feat: add semanatic release setup #46

merged 4 commits into from
Feb 8, 2024

Conversation

vgarciabnz
Copy link
Member

This PR adds the semantic-release setup. Here I am writing a few considerations about the setup that would be good to keep in some place (maybe the repo wiki or the README file).

About the version and the release process:

  • Version is not manually maintained anymore. It is always inferred at runtime using Nyx gradle plugin. This plugin is added as a gradle settings plugin.
  • Nyx is configured using the default "extended" preset. This preset configures different release types. The two types we are interested in are:
    • main branch: it generates versions such as x.y.z.
    • beta branch: it generates versions such as x.y.z-beta.i.
  • Publications:
    • On pull request: there is no publication on pull request, just unit test.
    • Push to beta branch: publication to Sonatype (snapshot) and NPMJS (beta).
    • Push to main branch: publication to Sonatype (central) and NPMJS (latest).
  • Commits starting with fix: or feat: will generate new patch or minor versions. Other commits won't generate versions. It means that a commit such as docs: improve description won't generate a new version and there won't be a new publication.

This PR is raised targeting beta branch, which means that snapshot (sonatype) and beta (nmpjs) packages will be published when merged. The published version would be 1.1.0-SNAPSHOT (sonatype) and 1.1.0-beta.1 (npmjs).

Comment on lines 1 to 20
name: Beta branch

on:
push:
branches:
- 'beta'

jobs:
unit-test:
uses: ./.github/workflows/job-test.yml

check-new-version:
needs: unit-test
uses: ./.github/workflows/job-check-new-version.yml

publish:
needs: check-new-version
if: ${{ needs.check-new-version.outputs.isNewVersion == 'true' }}
uses: ./.github/workflows/job-publish.yml
secrets: inherit
Copy link

@kabaros kabaros Feb 5, 2024

Choose a reason for hiding this comment

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

Two suggestions:

  • beta and main workflows can be merged? I don't see a difference
  • I don't think you need to manage the check for newVersion manually. You can just rely on the status code of running the script and if it's a success (zero), continue. Otherwise, abort.

I think these changes could make the scripts easier to follow.

Suggested change
name: Beta branch
on:
push:
branches:
- 'beta'
jobs:
unit-test:
uses: ./.github/workflows/job-test.yml
check-new-version:
needs: unit-test
uses: ./.github/workflows/job-check-new-version.yml
publish:
needs: check-new-version
if: ${{ needs.check-new-version.outputs.isNewVersion == 'true' }}
uses: ./.github/workflows/job-publish.yml
secrets: inherit
name: publish
on:
push:
branches:
- 'beta'
- 'main'
jobs:
unit-test:
uses: ./.github/workflows/job-test.yml
check-new-version:
id: checkNewVersion
needs: unit-test
run: sh ./.github/workflows/check-new-version.sh
publish:
needs: check-new-version
if: steps.checkNewVersion.outputs.status == 'success'
uses: ./.github/workflows/job-publish.yml
secrets: inherit

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the comment @kabaros.

  • Totally agree on the first point. Those workflows were different at the beginning; they ended up with the same structure and I forgot to remove one of them.
  • About the second point, it would be easier just to check for a failure as you suggested. The only reason why I preferred to check the output was to make the step not fail when the version has not change. The overall result would be the same (the version won't be published), but the "check-new-version" step will be colored in red, which could be considered a false positive because it is not an error, it is a valid. What do you think? I am not a pro with Github actions, maybe there is another way to deal with it

@kabaros
Copy link

kabaros commented Feb 6, 2024 via email

@vgarciabnz
Copy link
Member Author

umm... good point, let me try that

@vgarciabnz
Copy link
Member Author

After a call with @kabaros we decided to consolidate "beta" and "main" workflows in the same file and to keep the version validation as it was before. The PR is updated with these changes, so ready it would be ready when it comes to these comments.

@vgarciabnz vgarciabnz merged commit c9ae07a into beta Feb 8, 2024
1 check passed
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.

2 participants