[Javascript] Automating Releases with semantic-release

There are so many repeated steps when releasing a new version of a library. The tool semantic-release automates this process by pushing off the responsibility of your releases to continuous integration. Trust us, this will change your workflow for the better.

 

Install:

npm i -D semantic-release

 

Run:

semantic-release-cli setup

You can choose Travis and Single Node instance for now.

 

Notice Semantic release require Travis account (if you choose to use Travis), so you need to create a Travis account with your Github account. So it will sync your repos. After this done. you can setup semantic release.

 

Semantic release will delete "version" from the package.json, it will auto handle version according to your commit.

Also it creates a travis.yml file, you can add script to make sure it runs test before it commits.

复制代码
sudo: false
language: node_js
cache:
  directories:
    - node_modules
notifications:
  email: false
node_js:
  - '5.8'
before_install:
  - npm i -g npm@^2.0.0
before_script:
  - npm prune
script:
  - npm run test:single
after_success:
  - npm run semantic-release
branches:
  except:
    - /^v\d+\.\d+\.\d+$/
复制代码

 

script in package.json:

    "test:single": "cross-env NODE_ENV=test karma start --single-run",
    "semantic-release": "semantic-release pre && npm publish && semantic-release post"

 

posted @   Zhentiw  阅读(335)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2015-05-13 [Whole Web] [Node.js, PM2] Controlling runaway apps using pm2
2015-05-13 [AngularJS] angular-formly: Default Options
点击右上角即可分享
微信分享提示