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

Automatic release of tags from Travis to npm #92

Open
PowerKiKi opened this issue Apr 15, 2020 · 12 comments
Open

Automatic release of tags from Travis to npm #92

PowerKiKi opened this issue Apr 15, 2020 · 12 comments
Labels
ci Continuous Integration enhancement

Comments

@PowerKiKi
Copy link
Contributor

Following this #91 (comment), it would be nice to have automatic release of tags from Travis to npm to reduce bus factor for this project.

Here is an example on how to automatically publish tags as release which should be easy to adapt for this lib. But I cannot create a PR for it since I don't know the credentials to be encoded: https://github.com/Ecodev/fab-speed-dial/blob/123e63c7faeef1d469618dcefb4a111d82fc817f/.travis.yml#L32-L47

So, to copy tag version into our package, package.json would look like:

{
  "scripts": {
    "postbuild": "node scripts/copy-artifacts.js && cd dist/ngx-avatar && git describe --tags --always | xargs npm version --no-git-tag-version",
  }
}

And for Travis to actually pusblish, .travis.yml would be similar to:

    - stage: publish npm package
      if: tag is present
      script:
        - npm run build
      before_deploy:
        - rm .gitignore
        - cd dist/ngx-avatar
      deploy:
        provider: npm
        edge: true
        email:
          secure: YOUR ENCRYPTED EMAIL HERE
        api_token:
          secure: YOUR ENCRYPTED API TOKEN HERE
        on:
          tags: true
@odahcam
Copy link
Collaborator

odahcam commented Apr 16, 2020

I think this is very important and with Reviews and Checks in Pull Requests we can rely in this automatic system to publish new package versions for us.

We can even go further and create a configuration for auto releasing dev versions of the repo, so users can test nightly builds and access new features before major release and before our intervention.

@odahcam odahcam added the ci Continuous Integration label Apr 16, 2020
@PowerKiKi
Copy link
Contributor Author

auto releasing dev versions

IMHO I wouldn't go that far. I feel it could be creating new expectations for users and more maintenance work in the build system for us. And I'd would rather spend our precious time on fixing bugs/adding useful features than maintaining something that might not be used by many people.

@odahcam
Copy link
Collaborator

odahcam commented Apr 16, 2020

I like the dev builds because they are free of responsability and they saved me many times when a user asked for something I couldn't get ready for a release and I just said "oh there's that build, probably buggy, but you can try it out, blah blah...", hehe. Build, tag and publish daily the develop branch is pretty easy I must say, but that's just and idea. I just wanna make clear that I support continuous deployment for the master branch and we should pursue that.

@HaithemMosbahi
Copy link
Owner

Hi @PowerKiKi @odahcam,
I was planning to do this and I believe now it's a must to avoid blocking this project in the future.
I like your suggestions, I will add one more thing: I believe we need to have good test coverage for the core features of the component before starting the auto release process.

@PowerKiKi
Copy link
Contributor Author

There is two different approaches to auto release. First is to release every commit that pass tests entirely automatically. Second it that we, humans, decide whenever we feel like to create and push a tag, and then Travis release that tag.

I'm in favor of the second option, keeping humans in control of when the release happens. Mostly because I don't have experience with the first solution, and because keeping controls give us a chance to manually tests things before releasing. So that it is not an absolute requirement to wait for better test coverage (although test coverage is always a great thing of course).

Which alternative did you imagine ?

@odahcam
Copy link
Collaborator

odahcam commented Jun 4, 2020

I also prefer the second one, which can be easily achieved with GitHub Actions and the Releases from GitHub based on manual tagging. Auto-release would also have the challenge of auto-generating release tags. So second is easier and faster and will already help now.

@odahcam
Copy link
Collaborator

odahcam commented Jun 4, 2020

I have an workflow for publishing packages with Releases integration via GH Actions on this repo: https://github.com/zxing-js/text-encoding/blob/master/.github/workflows/npmpublish.yml

@PowerKiKi
Copy link
Contributor Author

I have no experience with GitHub Action, so I'll leave it to you then. I suppose we would also move test from Travis to GitHub Action then ? That's fine by me.

I notice your Action is using yarn, not npm. I also prefer yarn and we could migrate this project to yarn, but it should be done properly (removing package-lock.json and updating angular.json). I can take care of that if you agree.

@odahcam
Copy link
Collaborator

odahcam commented Jun 5, 2020

I like yarn, so I do agree.

I suppose we would also move test from Travis to GitHub Action then

Actually we can let that tests running there too. The action will only run tests before publishing a package. But yes, we can move from Travis with no problems, but I do find Travis environment a little more robust for testing, so I wouldn't say we should move from it so soon.

I'm taking a little of my free time this week to relax a little, but I can implement the Action here in the next days. I'll prepare a PR.

@PowerKiKi
Copy link
Contributor Author

@odahcam did you do something for automatic release ? I couldn't find anything in current code or PR.

@odahcam
Copy link
Collaborator

odahcam commented Sep 27, 2020

Sorry I did not implement anything here yet. But here's some example of how I'm doing in another repository: https://github.com/zxing-js/text-encoding/blob/master/.github/workflows/npmpublish.yml

Please ask me any questions about this config and I will answer ASAP!

@odahcam
Copy link
Collaborator

odahcam commented Sep 30, 2020

@HaithemMosbahi can you add the NPM required security key (auth token) for publishing on the repository and share it's name (usually NPM_TOKEN) in here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci Continuous Integration enhancement
Projects
None yet
Development

No branches or pull requests

3 participants