semver
semver copied to clipboard
CI/CD
I was wondering if you guys use this plugin in your CI/CD pipelines. Or is this plugin more something you run locally?
Hi,
Actually, we use semver by hand for our public projects but you can already use it in your CI, I just created an example with a simple GitHub action: https://github.com/edbzn/semver-ci
All you need to do is to configure the workflow:
name: default
on:
push:
branches:
- 'master'
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: git config
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- run: yarn install --frozen-lockfile
- run: yarn nx version tour-of-heroes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
and activating the push
option for semver:
"version": {
"executor": "@jscutlery/semver:version",
"options": {
"baseBranch": "master",
"syncVersions": false,
"push": true
}
}
Let me know if it helps you.
@edbzn Appreciate this useful tool.
I cannot make your snippet work because the master branch is protected. I tried to generate a token to use but still failed. Any thoughts?
- name: git config
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- run: npm ci --ignore-scripts
- run: npx nx run workspace:version --push --baseBranch master
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_VERSION_GITHUB_TOKEN }}
You can set a specific actor and then on the branch rules, bypass this protection for that user. Not the best solution but it works.
Our main
branch is also protected and we use the automatically generated GITHUB_TOKEN
that allows us to push.
@edbzn I need to find out how you're using the GITHUB_TOKEN on protected. I couldn't find how to allow you to push.