-
Notifications
You must be signed in to change notification settings - Fork 31
101 lines (101 loc) · 3.97 KB
/
release.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
on:
push:
branches:
- main
name: release
jobs:
changeFinder:
runs-on: ubuntu-latest
outputs:
nodePaths: ${{ steps.interrogate.outputs.nodePaths }}
steps:
- uses: actions/checkout@v2
- id: interrogate
uses: actions/github-script@v4
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
});
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/main`, { 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('/');
nodePaths.add(library);
};
}
nodePaths = Array.from(nodePaths);
if(nodePaths.length === 0){
console.log(`::warning::No changes found, release will be skipped.`)
}
console.log(`::set-output name=nodePaths::${JSON.stringify(nodePaths)}`);
release-pr:
runs-on: ubuntu-latest
needs: changeFinder
if: ${{ fromJson(needs.changeFinder.outputs.nodePaths)[0] != '' }}
strategy:
fail-fast: false
matrix:
package: ${{fromJson(needs.changeFinder.outputs.nodePaths)}}
steps:
- uses: google-github-actions/release-please-action@v2
id: release-please
with:
path: packages/${{ matrix.package }}
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
package-name: "@web-std/${{ matrix.package }}"
monorepo-tags: true
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"refactor","section":"Changes","hidden":false},{"type":"chore","section":"Changes","hidden":false}]'
command: release-pr
release:
runs-on: ubuntu-latest
needs: changeFinder
if: ${{ fromJson(needs.changeFinder.outputs.nodePaths)[0] != '' }}
strategy:
fail-fast: false
matrix:
package: ${{fromJson(needs.changeFinder.outputs.nodePaths)}}
steps:
- uses: GoogleCloudPlatform/release-please-action@v2
id: release
with:
path: packages/${{ matrix.package }}
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
package-name: "@web-std/${{ matrix.package }}"
monorepo-tags: true
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"refactor","section":"Changes","hidden":false},{"type":"chore","section":"Changes","hidden":false}]'
command: github-release
# The logic below handles the npm publication:
- name: Checkout
uses: actions/checkout@v2
# these if statements ensure that a publication only occurs when
# a new release is created:
if: ${{ steps.release.outputs.release_created }}
- name: Setup
uses: actions/setup-node@v2
with:
node-version: 16
registry-url: https://registry.npmjs.org/
if: ${{ steps.release.outputs.release_created }}
- name: Install
uses: bahmutov/npm-install@v1
if: ${{ steps.release.outputs.release_created }}
- name: Publish
if: ${{ steps.release.outputs.release_created }}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
run: |
cd packages/${{ matrix.package }}
npm publish --access=public