Implement Github action to publish on npmjs #2
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: Adobe reusable workflows - Publish to npmjs | ||
on: | ||
workflow_call: | ||
secrets: | ||
auth-token: | ||
required: true | ||
jobs: | ||
publish: | ||
name: Publish packages | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Fetch build-cache | ||
uses: actions/cache@v3 | ||
id: build-cache | ||
with: | ||
path: | | ||
./* | ||
!./node_modules | ||
key: build-cache-${{ github.sha }} | ||
- name: Publish to registry | ||
shell: bash | ||
run: | | ||
OPTS=(); | ||
if [[ $(npm pkg get version) == *"-"* ]]; then OPTS+=('--tag=next') ; fi | ||
if [[ $(npm pkg get workspaces) != "{}" ]]; then OPTS+=('--workspaces') ; fi | ||
npm publish $OPTS --access=public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.auth-token }} | ||
<<<<<<< HEAD | ||
======= | ||
We use `autocrlf` here to fix flow in case this reusable workflow is use after another one run-on windows. | ||
- name: Configure git | ||
shell: bash | ||
run: | | ||
git config --global core.autocrlf false | ||
git config --global user.name "$(git --no-pager log --format=format:'%an' -n 1)" | ||
git config --global user.email "$(git --no-pager log --format=format:'%ae' -n 1)" | ||
- name: Tag commit | ||
shell: bash | ||
run: | | ||
TAG_VERSION=$(npm pkg get version | xargs) | ||
git tag $TAG_VERSION | ||
git push origin $TAG_VERSION | ||
>>>>>>> db161a5... Update |