Skip to content

Commit

Permalink
ci(release): separate prerequisites step, use composite actions, fix …
Browse files Browse the repository at this point in the history
…condition for npmrc setup (#1951)
  • Loading branch information
YossiSaadi authored Feb 13, 2024
1 parent 6fcad15 commit 8df6827
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 26 deletions.
11 changes: 11 additions & 0 deletions .github/actions/git-creds/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: "Git credentials setup"
description: "Set up git credentials"

runs:
using: "composite"
steps:
- name: Set up git credentials
shell: bash
run: |
git config --global user.name 'ci'
git config --global user.email '[email protected]'
21 changes: 11 additions & 10 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ inputs:
required: true

runs:
using: "composite"
steps:
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- name: Install
run: yarn
shell: bash
env:
NODE_AUTH_TOKEN: ${{inputs.npm_token}}
using: "composite"
steps:
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
registry-url: https://registry.npmjs.org/
- name: Install
run: yarn
shell: bash
env:
NODE_AUTH_TOKEN: ${{inputs.npm_token}}
49 changes: 33 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,54 @@ name: Release new version
on: workflow_dispatch

jobs:
prerequisites:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: "Test"
command: "test"
- name: "Lint"
command: "lint"
- name: "Stylelint"
command: "stylelint"
- name: "Build"
command: "build"
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run Setup
uses: ./.github/actions/setup
with:
npm_token: ${{secrets.npm_token}}
- name: Run ${{matrix.name}}
shell: bash
run: yarn lerna run ${{matrix.command}} --since
release:
needs: prerequisites
runs-on: ubuntu-latest
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
- name: Run Setup
uses: ./.github/actions/setup
with:
node-version-file: ".nvmrc"
registry-url: https://registry.npmjs.org/
- name: Install
run: yarn
- name: Lint
run: yarn lerna run lint --since
- name: Build
run: yarn lerna run build --since
- name: Test
run: yarn lerna run test --since
- name: Set up git credentials
run: |
git config --global user.name 'ci'
git config --global user.email '[email protected]'
npm_token: ${{secrets.npm_token}}
- uses: ./.github/actions/git-creds
- name: Generate new versions
run: yarn lerna version --conventional-commits -y
- run: yarn config set registry https://registry.npmjs.org/
- name: Setup .npmrc for publish
id: setup-npmrc
run: echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" > .npmrc
- name: Publish to npm
run: yarn lerna publish from-package -y
- name: Remove .npmrc
if: success() || failure()
if: steps.setup-npmrc.outcome == 'success'
run: rm .npmrc

0 comments on commit 8df6827

Please sign in to comment.