Skip to content

Commit 7d9629c

Browse files
committed
feat!: add a change
1 parent 09fa0fd commit 7d9629c

File tree

2 files changed

+69
-9
lines changed

2 files changed

+69
-9
lines changed

.github/workflows/release-please.yaml

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,47 +15,50 @@ jobs:
1515
with:
1616
github-token: ${{secrets.GITHUB_TOKEN}}
1717
script: |
18+
const allowlist = ['test-api'];
1819
const {execSync} = require('child_process');
19-
execSync('git pull --tags');
2020
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
2121
const latestRelease = await github.repos.getLatestRelease({
2222
owner,
2323
repo
2424
});
2525
console.log(`latest release: ${JSON.stringify(latestRelease.data)}`);
26+
execSync('git pull --tags');
2627
execSync(`git reset --hard ${latestRelease.data.tag_name}`);
2728
const status = execSync(`git diff --name-only origin/master`, { encoding: 'utf-8'});
2829
console.log(status);
2930
const changes = status.split('\n');
3031
let nodePaths = new Set();
3132
for (const change of changes) {
3233
if (change.startsWith('src/apis/')) {
33-
nodePaths.add(change.split('/')[2]);
34+
const library = change.split('/')[2];
35+
if (allowlist.includes(library) {
36+
nodePaths.add(library);
37+
}
3438
};
3539
}
3640
nodePaths = Array.from(nodePaths);
3741
console.log(`::set-output name=nodePaths::${JSON.stringify(nodePaths)}`);
38-
release:
42+
release-pr:
3943
runs-on: ubuntu-latest
4044
needs: changeFinder
4145
strategy:
4246
fail-fast: false
4347
matrix:
4448
package: ${{fromJson(needs.changeFinder.outputs.nodePaths)}}
45-
outputs:
46-
prNumber: ${{ steps.release-please.outputs.pr }}
4749
steps:
48-
- uses: GoogleCloudPlatform/release-please-action@v2.9.3
50+
- uses: GoogleCloudPlatform/release-please-action@v2
4951
id: release-please
5052
with:
5153
path: src/apis/${{ matrix.package }}
5254
token: ${{ secrets.CREATE_A_FORK }}
5355
fork: true
54-
clean: false
5556
release-type: node
5657
package-name: ${{ matrix.package }}
5758
monorepo-tags: true
59+
command: release-pr
5860
- id: label
61+
if: ${{steps.release-please.outputs.pr}})
5962
uses: actions/github-script@v3
6063
with:
6164
github-token: ${{secrets.GITHUB_TOKEN}}
@@ -68,5 +71,60 @@ jobs:
6871
labels: ['autorelease: pending']
6972
});
7073
console.log(`Tagged ${{steps.release-please.outputs.pr}}`)
71-
if: ${{steps.release-please.outputs.pr}})
74+
release-please-release:
75+
runs-on: ubuntu-latest
76+
needs: changeFinder
77+
strategy:
78+
fail-fast: false
79+
matrix:
80+
package: ${{fromJson(needs.changeFinder.outputs.nodePaths)}}
81+
steps:
82+
- uses: GoogleCloudPlatform/release-please-action@v2
83+
id: tag-release
84+
with:
85+
path: src/apis/${{ matrix.package }}
86+
token: ${{ secrets.GITHUB_TOKEN }}
87+
release-type: node
88+
monorepo-tags: true
89+
package-name: ${{ matrix.package }}
90+
command: github-release
91+
- uses: actions/checkout@v2
92+
if: ${{ steps.tag-release.outputs.release_created }}
93+
- uses: actions/setup-node@v1
94+
if: ${{ steps.tag-release.outputs.release_created }}
95+
with:
96+
node-version: 14
97+
registry-url: 'https://wombat-dressing-room.appspot.com/'
98+
- name: publish
99+
if: ${{ steps.tag-release.outputs.release_created }}
100+
env:
101+
NODE_AUTH_TOKEN: ${{secrets.NPM_MONOREPO_TOKEN}}
102+
run: |
103+
cd src/apis/${{ matrix.package }}
104+
npm install
105+
npm publish
106+
- id: untag-release
107+
- uses: actions/github-script@v3
108+
if: ${{steps.tag-release.outputs.pr}}
109+
with:
110+
github-token: ${{secrets.GITHUB_TOKEN}}
111+
script: |
112+
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
113+
await github.issues.addLabels({
114+
owner,
115+
repo,
116+
issue_number: ${{steps.tag-release.outputs.pr}},
117+
labels: ['autorelease: published']
118+
});
119+
github.issues.removeLabel({
120+
owner,
121+
repo,
122+
issue_number: ${{steps.tag-release.outputs.pr}},
123+
name: 'autorelease: tagged',
124+
});
125+
console.log(`Tagged ${{steps.tag-release.outputs.pr}}`)
126+
127+
128+
129+
72130

src/apis/test-api/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
ANOTHER ONE!
1+
ANOTHER ONE!
2+
3+
A test

0 commit comments

Comments
 (0)