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

Question - Does it have prerelease support? #16

Closed
PauloGoncalvesBH opened this issue Oct 23, 2021 · 7 comments · Fixed by #19
Closed

Question - Does it have prerelease support? #16

PauloGoncalvesBH opened this issue Oct 23, 2021 · 7 comments · Fixed by #19
Labels
enhancement New feature or request question Further information is requested released

Comments

@PauloGoncalvesBH
Copy link

PauloGoncalvesBH commented Oct 23, 2021

I'm looking for a semantic-release docker library that allows every release generated from the 'trunk' branch to generate an image tagged latest, and published in the 'beta' branch generate it with a beta tag and with the x.x.x-beta version. (example: 3.4.1-beta.1).


My release configuration is as follows:

https://github.com/ServeRest/ServeRest/blob/d30fcf68d7fe39d4f4f04917ed00ec43b7eb766c/.releaserc.js#L74

This page shows the releases and some generated beta pre-releases:

https://github.com/ServeRest/ServeRest/releases?page=2

@esatterwhite
Copy link
Owner

@PauloGoncalvesBH I can't say that I've tried it, but I don't see why it wouldn't as long as semantic release does what it normally does.

by default there is a templated tag that is just {version} which is passed through by semantic release. if it still does that - it should work

@esatterwhite esatterwhite added enhancement New feature or request question Further information is requested labels Dec 2, 2021
@infiniityr
Copy link

I try to tag the images differently if it is a pre-release but the nextRelease.version doesn't seems to exists.
I also tried with version and next.version, I got the same results : the release tags are used.

module.exports = {
  plugins: [
    [
      '@semantic-release/git',
      {
        assets: [
          'package.json'
        ],
        message: "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
      }
    ],
   [
      '@codedependant/semantic-release-docker',
      {
        dockerTags: "${nextRelease.version}".includes('sprint') ? ['beta', '{version}', '{major}-beta', '{major}.{minor}-beta'] : ['latest', '{version}', '{major}-latest', '{major}.{minor}'],
        dockerImage: 'image',
        dockerRegistry: 'my-registry.net',
        dockerProject: 'project',
        dockerLogin: false,
        dockerPublish: true
      }
    ]
  ]
}

@esatterwhite
Copy link
Owner

esatterwhite commented Dec 31, 2021

You are using the string literal "${nextRelease.version}" which does not include the string sprint. Docker tags isn't a lodash template, the template engine is very basic but could be expanded. Additionally, the JavaScript ternary is executed when the module is loaded rather than when the plugin is executed. So this will likely never work.

It seems like you are looking for some conditional processing?

{
  dockerTags: ["{#if prerelease}beta{/if}" ]
}

@infiniityr
Copy link

Indeed, i'm looking at this kind of preprocessing or maybe a custom function for the creation of the configuration.

@esatterwhite
Copy link
Owner

esatterwhite commented Dec 31, 2021

I think its pretty doable to swap out handlebars as the template engine and pre load some string helpers. and expose an option to specify additional helper functions. Then you can pretty much do what you want here.

esatterwhite added a commit that referenced this issue Dec 31, 2021
replaces the simple template engine with handlebars and a set of default
helpers

BREAKING CHANGE: Use handlebars as template engine. Place holders are
now double curlies `{{ }}`

resolves: #16
esatterwhite added a commit that referenced this issue Dec 31, 2021
replaces the simple template engine with handlebars and a set of default
helpers

BREAKING CHANGE: Use handlebars as template engine. Place holders are
now double curlies `{{ }}`

resolves: #16
esatterwhite added a commit that referenced this issue Dec 31, 2021
replaces the simple template engine with handlebars and a set of default
helpers

BREAKING CHANGE: Use handlebars as template engine. Place holders are
now double curlies `{{ }}`

resolves: #16
esatterwhite added a commit that referenced this issue Dec 31, 2021
replaces the simple template engine with handlebars and a set of default
helpers

BREAKING CHANGE: Use handlebars as template engine. Place holders are
now double curlies `{{ }}`

resolves: #16
esatterwhite added a commit that referenced this issue Dec 31, 2021
replaces the simple template engine with handlebars and a set of default
helpers

BREAKING CHANGE: Use handlebars as template engine. Place holders are
now double curlies `{{ }}`

resolves: #16
esatterwhite added a commit that referenced this issue Dec 31, 2021
replaces the simple template engine with handlebars and a set of default
helpers

BREAKING CHANGE: Use handlebars as template engine. Place holders are
now double curlies `{{ }}`

resolves: #16
esatterwhite added a commit that referenced this issue Dec 31, 2021
replaces the simple template engine with handlebars and a set of default
helpers

BREAKING CHANGE: Use handlebars as template engine. Place holders are
now double curlies `{{ }}`

resolves: #16
@github-actions
Copy link

🎉 This issue has been resolved in version 4.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@infiniityr
Copy link

infiniityr commented Jan 4, 2022

It works perfectly !

Here is the solution using Handlebars

module.exports = {
  plugins: [
    [
      '@semantic-release/git',
      {
        assets: [
          'package.json'
        ],
        message: "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
      }
    ],
   [
      '@codedependant/semantic-release-docker',
      {
        dockerTags: ['{{version}}', "{{#if (includes version 'sprint')}}beta{{else}}latest{{/if}}", "{{major}}-{{#if (includes version 'sprint')}}beta{{else}}latest{{/if}}", "{{major}}.{{minor}}{{#if (includes version 'sprint')}}-beta{{/if}}"],
        dockerImage: 'image',
        dockerRegistry: 'my-registry.net',
        dockerProject: 'project',
        dockerLogin: false,
        dockerPublish: true
      }
    ]
  ]
}

Thank you for the release ! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants