chore: release main (#130) #155
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: release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
release-please: | |
runs-on: ubuntu-latest | |
outputs: | |
releases_created: ${{ steps.release.outputs.releases_created }} | |
packages: ${{ steps.get-released-packages.outputs.result }} | |
steps: | |
- uses: google-github-actions/release-please-action@v3 | |
id: release | |
with: | |
command: manifest | |
monorepo-tags: true | |
- uses: actions/checkout@v3 | |
if: ${{ steps.release.outputs.releases_created }} | |
- id: get-released-packages | |
if: ${{ steps.release.outputs.releases_created }} | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const path = require('path'); | |
const outputs = ${{ toJSON(steps.release.outputs) }}; | |
return Object.keys(outputs) | |
.map((key) => { | |
const match = key.match(/^(.*\/.*)--release_created$/); | |
if (!match) return; | |
return require(path.join('${{ github.workspace }}', match[1], 'package.json')).name; | |
}) | |
.filter(Boolean); | |
npm-publish: | |
needs: release-please | |
if: ${{ needs.release-please.outputs.releases_created }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
strategy: | |
fail-fast: false | |
matrix: | |
package: ${{ fromJson(needs.release-please.outputs.packages )}} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: lts/* | |
registry-url: 'https://registry.npmjs.org' | |
- run: yarn install | |
- id: package-name | |
run: | | |
PACKAGE_NAME=$(node -p "PACKAGE_NAME='${{ matrix.package }}'.split('/')[1]") | |
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_OUTPUT | |
- run: npm publish --provenance --access public | |
working-directory: packages/${{ steps.package-name.outputs.PACKAGE_NAME }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |