Publish new version #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish new version | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
required: true | |
env: | |
NODE_VERSION: 16.x | |
TOOLKIT_VERSION: ${{ inputs.version }} | |
jobs: | |
publish: | |
if: github.repository_owner == 'AxaFrance' | |
environment: | |
name: Release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
registry-url: 'https://registry.npmjs.org' | |
cache: 'npm' | |
- run: npm ci | |
- run: npm run build | |
- run: npm run check | |
- run: npm test -- --coverage | |
- name: Build storybook | |
run: npm run storybook:build | |
- name: Upload Storybook into workflow artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: storybook | |
path: storybook-static | |
- name: Publish release packages to npm | |
run: npx lerna publish from-git --yes --registry https://registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
deploy-storybook: | |
runs-on: ubuntu-latest | |
needs: publish | |
defaults: | |
run: | |
working-directory: gh-pages/react-toolkit | |
outputs: | |
previousVersion: ${{ steps.rename-latest-storybook.outputs.prevVersion }} | |
steps: | |
- name: Checkout Axa Github Pages | |
uses: actions/checkout@v3 | |
with: | |
repository: AxaFrance/AxaFrance.github.io | |
ref: master | |
path: gh-pages | |
token: ${{ secrets.PUSH_PAT }} | |
- name: Rename latest Storybook folder | |
id: rename-latest-storybook | |
run: | | |
prevVersion=`node -p "require('./latest/version.json').version"` | |
mv latest v$prevVersion | |
echo "::set-output name=prevVersion::$prevVersion" | |
- uses: actions/download-artifact@v3 | |
with: | |
name: storybook | |
path: gh-pages/react-toolkit/latest | |
- name: Add version json file into latest | |
run: | | |
echo {\"version\":\"${TOOLKIT_VERSION#v}\"} >> ./latest/version.json | |
- name: Git config | |
run: | | |
git config user.name "Build-CI" | |
git config user.email "[email protected]" | |
- name: Add files | |
run: git add . | |
- name: Commit changes | |
run: git commit -a -m "publish storybook ${TOOLKIT_VERSION}" | |
- name: Push | |
run: git push |