Skip to content

release-please-submodule #182

release-please-submodule

release-please-submodule #182

on: workflow_dispatch
permissions:
contents: write
pull-requests: write
name: release-please-submodule
jobs:
changeFinder:
runs-on: ubuntu-latest
outputs:
nodePaths: ${{ steps.interrogate.outputs.nodePaths }}
steps:
- uses: actions/checkout@v4
- id: interrogate
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
retries: 5
script: |
const {execSync} = require('child_process');
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
const latestRelease = await github.rest.repos.getLatestRelease({
owner,
repo
});
console.log(`latest release: ${JSON.stringify(latestRelease.data)}`);
execSync('git pull --tags');
execSync(`git reset --hard ${latestRelease.data.tag_name}`);
const status = execSync(`git diff --name-only origin/master`, { encoding: 'utf-8'});
console.log(status);
const changes = status.split('\n');
let nodePaths = new Set();
for (const change of changes) {
if (change.startsWith('packages/')) {
const library = change.split('/')[1];
nodePaths.add(library);
};
}
nodePaths = Array.from(nodePaths);
console.log(`::set-output name=nodePaths::${JSON.stringify(nodePaths)}`);
release-please-release:
runs-on: ubuntu-latest
needs: changeFinder
strategy:
fail-fast: false
matrix:
package: ${{fromJson(needs.changeFinder.outputs.nodePaths)}}
steps:
- uses: google-github-actions/release-please-action@v3
id: tag-release
with:
path: packages/${{ matrix.package }}
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
monorepo-tags: true
package-name: ${{ matrix.package }}
command: github-release
- uses: actions/checkout@v4
if: ${{ steps.tag-release.outputs.releases_created }}
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v4
if: ${{ steps.tag-release.outputs.releases_created }}
with:
node-version: 18
registry-url: 'https://external-dot-oss-automation.appspot.com/'
cache: 'pnpm'
- name: publish
if: ${{ steps.tag-release.outputs.releases_created }}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
run: |
pnpm install
pnpm publish --filter ${{ matrix.package }} --no-git-checks --access public
release-pr:
runs-on: ubuntu-latest
needs:
- changeFinder
- release-please-release
strategy:
fail-fast: false
matrix:
package: ${{fromJson(needs.changeFinder.outputs.nodePaths)}}
steps:
- uses: google-github-actions/release-please-action@v3
id: release-please
with:
path: packages/${{ matrix.package }}
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
package-name: ${{ matrix.package }}
monorepo-tags: true
command: release-pr