-
Notifications
You must be signed in to change notification settings - Fork 1
59 lines (56 loc) · 2.15 KB
/
release-please.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: release-please
on:
push:
branches:
- main
jobs:
find-changes:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.changes.outputs.packages }}
steps:
- uses: actions/checkout@v3
- id: changes
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { execSync } = require('child_process');
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
const latestRelease = await github.repos.getLatestRelease({ owner, repo });
execSync('git pull --tags');
const diff = execSync(`git diff --name-only tags/${latestRelease.data.tag_name}`, { encoding: 'utf-8'});
const packages = [...new Set([...diff.matchAll(/^packages\/(.+?)\//mg)].map(group => group[1]))]
console.log(`::set-output name=packages::${JSON.stringify(Array.from(packages))}`);
release-please:
runs-on: ubuntu-latest
needs: find-changes
if: needs['find-changes'].outputs.packages != '[]'
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs['find-changes'].outputs.packages) }}
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
monorepo-tags: true
path: packages/${{ matrix.package }}
token: ${{ secrets.GITHUB_TOKEN }}
package-name: ${{ matrix.package }}
- uses: actions/checkout@v3
if: ${{ steps.release.outputs.releases_created }}
- uses: actions/setup-node@v3
if: ${{ steps.release.outputs.releases_created }}
with:
node-version: 20.x
registry-url: https://registry.npmjs.org
- run: npm install
if: ${{ steps.release.outputs.releases_created }}
- run: npm run build --if-present -w packages/${{ matrix.package }}/
if: ${{ steps.release.outputs.releases_created }}
- run: npm publish packages/${{ matrix.package }}/ --access public
if: ${{ steps.release.outputs.releases_created }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}