Skip to content

Commit

Permalink
ci(@leav/ui): publish build on push on develop
Browse files Browse the repository at this point in the history
  • Loading branch information
renaudAmsellem committed Mar 29, 2024
1 parent 69e550c commit 2305855
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 21 deletions.
21 changes: 1 addition & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,8 @@ concurrency:
cancel-in-progress: true

jobs:

install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: 18.x
cache: 'yarn'
- name: Cache NPM dependencies
uses: actions/cache@v3
with:
path: '**/node_modules'
key: |
${{ runner.OS }}-yarn-${{ hashFiles('**/yarn.lock') }}
${{ runner.OS }}-yarn
- name: Install dependency
run: sudo apt-get update && sudo apt-get install -y libpoppler-dev libpoppler-cpp-dev libpoppler-private-dev poppler-utils
- name: install node module
run: yarn install
uses: ./.github/workflows/install.yml

setup-workspaces-list-name:
runs-on: ubuntu-latest
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "install dependencies"

on:
workflow_dispatch:
workflow_call:

jobs:
install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
cache: 'yarn'
- name: Install dependency
run: sudo apt-get update && sudo apt-get install -y libpoppler-dev libpoppler-cpp-dev libpoppler-private-dev poppler-utils
- name: install node module
run: yarn install
88 changes: 88 additions & 0 deletions .github/workflows/publish-ui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: "Publish @leav/ui @next package to npmjs on push on develop"

on:
push:
branches:
- develop
- chore/publish-ui-next # TO DELETE
paths:
- libs/ui/**
- .github/workflows/** # TO DELETE
workflow_dispatch:
secrets:
NPM_TOKEN:
description: 'Npm Token'
required: false

jobs:
install:
uses: ./.github/workflows/install.yml
build:
runs-on: ubuntu-latest
needs:
- install
steps:
- uses: actions/checkout@v4
with:
ref: 'chore/publish-ui-next' #CHANGE TO DEVELOP
- uses: actions/setup-node@v4
with:
node-version: 18.x
cache: 'yarn'
#- run: sudo apt-get update && sudo apt-get install -y libpoppler-dev libpoppler-cpp-dev libpoppler-private-dev poppler-utils
- name: build @leav/ui
run: yarn --cwd "libs/ui" build
prepublish:
runs-on: ubuntu-latest
needs: build
outputs:
version: ${{ steps.version.outputs.next_version }}
exists: ${{ steps.check.outputs.exists }}
steps:
- uses: actions/checkout@v4
with:
ref: 'chore/publish-ui-next' #CHANGE TO DEVELOP
- name: get next version
id: version
run: |
echo "next_version=$(cat libs/ui/package.json | jq -r '.version')-$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_OUTPUT"
echo "next_version=$(cat libs/ui/package.json | jq -r '.version')-$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV"
- name: Update package.json version
uses: jossef/action-set-json-field@v2.1
with:
file: libs/ui/package.json
field: version
value: ${{ env.next_version }}
- name: Check publish status
id: check_npm
uses: tehpsalmist/npm-publish-status-action@v1
- name: set check npm variable
id: check
run: |
echo "exists=${{ steps.check_npm.outputs.exists }}" >> "$GITHUB_OUTPUT"
publish-next:
runs-on: ubuntu-latest
needs: prepublish
if: ${{needs.prepublish.outputs.exists == '0'}}
steps:
- uses: actions/checkout@v4
with:
ref: 'chore/publish-ui-next' #CHANGE TO DEVELOP
- uses: actions/setup-node@v4
with:
node-version: 18.x
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
- name: Update package.json version
uses: jossef/action-set-json-field@v2.1
with:
file: libs/ui/package.json
field: version
value: ${{ needs.prepublish.outputs.version }}
- name: build project
run: yarn --cwd "libs/ui" build
- name: publish next version
run: yarn --cwd "libs/ui" publish-ui --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

2 changes: 1 addition & 1 deletion libs/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test:ci": "jest --maxWorkers=2",
"test:commit": "jest --maxWorkers=50% --onlyChanged",
"create_comp": "scripts/createComponent.js",
"publish": "npm publish --access public"
"publish-ui": "npm publish --access public"
},
"main": "dist/index",
"files": [
Expand Down

0 comments on commit 2305855

Please sign in to comment.