Skip to content

Commit

Permalink
feat!: add a change
Browse files Browse the repository at this point in the history
  • Loading branch information
sofisl committed Dec 3, 2020
1 parent 09fa0fd commit 7d9629c
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 9 deletions.
74 changes: 66 additions & 8 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,47 +15,50 @@ jobs:
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const allowlist = ['test-api'];
const {execSync} = require('child_process');
execSync('git pull --tags');
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/master`, { encoding: 'utf-8'});
console.log(status);
const changes = status.split('\n');
let nodePaths = new Set();
for (const change of changes) {
if (change.startsWith('src/apis/')) {
nodePaths.add(change.split('/')[2]);
const library = change.split('/')[2];
if (allowlist.includes(library) {
nodePaths.add(library);
}
};
}
nodePaths = Array.from(nodePaths);
console.log(`::set-output name=nodePaths::${JSON.stringify(nodePaths)}`);
release:
release-pr:
runs-on: ubuntu-latest
needs: changeFinder
strategy:
fail-fast: false
matrix:
package: ${{fromJson(needs.changeFinder.outputs.nodePaths)}}
outputs:
prNumber: ${{ steps.release-please.outputs.pr }}
steps:
- uses: GoogleCloudPlatform/release-please-action@v2.9.3
- uses: GoogleCloudPlatform/release-please-action@v2
id: release-please
with:
path: src/apis/${{ matrix.package }}
token: ${{ secrets.CREATE_A_FORK }}
fork: true
clean: false
release-type: node
package-name: ${{ matrix.package }}
monorepo-tags: true
command: release-pr
- id: label
if: ${{steps.release-please.outputs.pr}})
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
Expand All @@ -68,5 +71,60 @@ jobs:
labels: ['autorelease: pending']
});
console.log(`Tagged ${{steps.release-please.outputs.pr}}`)
if: ${{steps.release-please.outputs.pr}})
release-please-release:
runs-on: ubuntu-latest
needs: changeFinder
strategy:
fail-fast: false
matrix:
package: ${{fromJson(needs.changeFinder.outputs.nodePaths)}}
steps:
- uses: GoogleCloudPlatform/release-please-action@v2
id: tag-release
with:
path: src/apis/${{ matrix.package }}
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
monorepo-tags: true
package-name: ${{ matrix.package }}
command: github-release
- uses: actions/checkout@v2
if: ${{ steps.tag-release.outputs.release_created }}
- uses: actions/setup-node@v1
if: ${{ steps.tag-release.outputs.release_created }}
with:
node-version: 14
registry-url: 'https://wombat-dressing-room.appspot.com/'
- name: publish
if: ${{ steps.tag-release.outputs.release_created }}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_MONOREPO_TOKEN}}
run: |
cd src/apis/${{ matrix.package }}
npm install
npm publish
- id: untag-release
- uses: actions/github-script@v3
if: ${{steps.tag-release.outputs.pr}}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
await github.issues.addLabels({
owner,
repo,
issue_number: ${{steps.tag-release.outputs.pr}},
labels: ['autorelease: published']
});
github.issues.removeLabel({
owner,
repo,
issue_number: ${{steps.tag-release.outputs.pr}},
name: 'autorelease: tagged',
});
console.log(`Tagged ${{steps.tag-release.outputs.pr}}`)



4 changes: 3 additions & 1 deletion src/apis/test-api/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
ANOTHER ONE!
ANOTHER ONE!

A test

0 comments on commit 7d9629c

Please sign in to comment.