semver icon indicating copy to clipboard operation
semver copied to clipboard

CI/CD

Open promontis opened this issue 2 years ago • 5 comments

I was wondering if you guys use this plugin in your CI/CD pipelines. Or is this plugin more something you run locally?

promontis avatar Sep 12 '21 17:09 promontis

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 avatar Sep 13 '21 07:09 edbzn

@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 }}

SunStupic avatar Nov 23 '21 14:11 SunStupic

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.

Screen Shot 2021-12-29 at 13 26 46

rodrigomata avatar Dec 29 '21 19:12 rodrigomata

Our main branch is also protected and we use the automatically generated GITHUB_TOKEN that allows us to push.

edbzn avatar Dec 30 '21 09:12 edbzn

@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.

mrsufgi avatar Feb 02 '23 09:02 mrsufgi