feat: menu improvements (#531) #185
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 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
run-tests: | |
runs-on: ubuntu-latest | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Setup node and npm with the versions defined in package.json engines. | |
- name: Install node and npm | |
uses: './.github/actions/install-node-and-npm' | |
- name: Install dependencies | |
run: npm ci --legacy-peer-deps | |
- name: Run unit tests | |
run: npm run test:ci | |
# Publish package to npm | |
publish: | |
runs-on: ubuntu-latest | |
needs: run-tests | |
env: | |
# Used to publish the package to the npm registry | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Setup node and npm with the versions defined in package.json engines. | |
- name: Install node and npm | |
uses: './.github/actions/install-node-and-npm' | |
- name: Install dependencies | |
run: npm ci --legacy-peer-deps | |
- name: Build the package | |
run: npm run build | |
- name: Publish the package to npm | |
id: publish | |
uses: JS-DevTools/npm-publish@v3 | |
with: | |
token: ${{ env.NPM_TOKEN }} | |
# only publish if the version in package.json has changed | |
check-version: true | |
- name: Add git tag ${{ steps.publish.outputs.version }} | |
if: steps.publish.outputs.type != 'none' | |
uses: actions/github-script@v7 | |
env: | |
NEW_VERSION: '${{ steps.publish.outputs.version }}' | |
OLD_VERSION: '${{ steps.publish.outputs.old-version }}' | |
with: | |
script: | | |
const { OLD_VERSION, NEW_VERSION } = process.env; | |
console.log(`Version changed: ${OLD_VERSION} => ${NEW_VERSION}`); | |
// create the tag | |
const tagRes = await github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: `refs/tags/${NEW_VERSION}`, | |
sha: context.sha | |
}); | |
console.log(`Tag creation result: ${tagRes.status}`); | |
// create the release | |
console.log(`Creating release ${NEW_VERSION}`); | |
const relRes = await github.rest.repos.createRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
tag_name: NEW_VERSION, | |
name: NEW_VERSION, | |
body: `Please refer to [CHANGELOG.md](https://github.com/lob/ui-components/blob/main/CHANGELOG.md) for details.`, | |
generate_release_notes: true | |
}); | |
console.log(`Release creation result: ${relRes.status}`); |