Semantic Release Drone plug-in

Drone Community:

I thought I would ask it here. It saves me from spending work doing it if it is already done. You know, “all that don’t reinvent the wheel stuff”. :slight_smile:

Has anyone developed a Semantic-Release drone plugin that I could use in my drone workflow?
If not, I was going to create one and contribute it back.

Thanks in Advance.

Cheers!

1 Like

Hi, SGTGunner!

I need this plugin and have planned to implement it in October. It would be nice to use your implementation or to be involved in it. Let me know if I may help you.

Best regards,
Denis.

Hi Denis,

I am always looking for folks to collaborate with. Many hands make light work. :slight_smile:
I have not created the drone plugin template yet. I will be doing that this week. I will send you a PM, with details and we can go from there.

Cheers,

SGTGunner

Hello, SGTGunner!

Is there any progress on semantic-release plugin?

Best regards,
Denis.

Perfect timing. I am nearly finished with it.

Thought, I have hit an issues and I will post here what the problem is:

I have the script.sh which looks like this:

#!/bin/sh

GH_TOKEN=${GITHUBTOKEN} npx semantic-release --branch ${PLUGIN_BRANCH} --no-ci

and within the .drome.yml it is called and looks like this:

semantic_release:
    image: sgtgunner/drone-semantic-release:1.0.0
    secrets: [ githubtoken ]
    branch: feature/drone-semantic-release
    when:
      event:
        - push
        - pull-request

However, when I start the pipeline, I get the following error, where both variables are not being passed in.
And this is at the start of the image being called.

sh: missing ] 0s
2 npx: installed 768 in 13.966s 13s
3 [10:15:08 AM] [semantic-release] › ℹ Running semantic-release version 15.10.6 14s
4 [10:15:08 AM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/npm" 14s
5 [10:15:08 AM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/github" 14s
6 [10:15:08 AM] [semantic-release] › ✔ Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer" 14s
7 [10:15:08 AM] [semantic-release] › ✔ Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator" 14s
8 [10:15:08 AM] [semantic-release] › ✔ Loaded plugin "prepare" from "@semantic-release/npm" 14s
9 [10:15:08 AM] [semantic-release] › ✔ Loaded plugin "publish" from "@semantic-release/github" 14s
10 [10:15:08 AM] [semantic-release] › ✔ Loaded plugin "success" from "@semantic-release/github" 14s
11 [10:15:08 AM] [semantic-release] › ✔ Loaded plugin "fail" from "@semantic-release/github"
...

Any assistance would be greatly appreciated!

Cheers!

Thinking about this more, would the branch: having something to do with it given it is passing a special character?

Update: When I tested it locally it did not have a problem and worked correctly passing in the -e variables.

Hi, not sure what is the problem here, although if you suspect it is the special character from “branch” you could try wrapping it with single quotes, i.e.: branch: 'feature/drone-semantic-release'

That said, drone injects into every build step a list of environment variables, including a DRONE_BRANCH, which includes your current branch, on ‘push’ events, at least, not sure about ‘pull-request’… in this case, I think it holds the branch your PR is pointing to!

Not sure if this is the most up-to-date list, but works for 0.8: http://docs.drone.io/environment-reference/

Thank you for your assistance. I did try using single quotes around branch: And I still got the same error.

You could also run a command like “env” inside your script to be sure that the arguments are being passed down correctly. And maybe also start the shell in debug mode (set -x) so it prints the “npx” command.

I like to add a “debug:” parameter to my plugins to print stuff like that, so it’s easy to find errors.

I have private repos on github. Mostly backends and frontends for web apps, they’re not npm libraries.

Here’s a drone plugin using semantic release for automating github releases.