|
3 | 3 | on:
|
4 | 4 | push:
|
5 | 5 | branches:
|
6 |
| - - master |
| 6 | + - develop |
7 | 7 | repository_dispatch:
|
8 | 8 | types: [semantic-release]
|
9 | 9 |
|
@@ -35,13 +35,81 @@ jobs:
|
35 | 35 |
|
36 | 36 | - name: Gatsby Build
|
37 | 37 | run: npm run build:production
|
| 38 | + |
| 39 | + job-generate-third-party-notices: |
| 40 | + runs-on: ubuntu-latest |
| 41 | + needs: job-checkout-and-build |
| 42 | + steps: |
| 43 | + # Checkout fetch-depth: 2 because there's a check to see if package.json |
| 44 | + # was updated, and need at least 2 commits for the check to function properly |
| 45 | + - name: Checkout repo |
| 46 | + uses: actions/checkout@v2 |
| 47 | + with: |
| 48 | + fetch-depth: 2 |
| 49 | + |
| 50 | + - name: Setup Node.js |
| 51 | + uses: actions/setup-node@v1 |
| 52 | + with: |
| 53 | + node-version: 10.x |
| 54 | + |
| 55 | + - name: Download Cached Deps |
| 56 | + id: cache-node-modules |
| 57 | + uses: actions/cache@v1 |
| 58 | + env: |
| 59 | + cache-name: node-modules |
| 60 | + with: |
| 61 | + path: ~/.npm |
| 62 | + key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} |
| 63 | + restore-keys: | |
| 64 | + ${{ runner.os }}-${{ env.cache-name }}- |
| 65 | +
|
| 66 | + - name: Install Dependencies |
| 67 | + run: npm ci |
| 68 | + |
| 69 | + - name: Install OSS CLI |
| 70 | + run: | |
| 71 | + sudo npm install -g @newrelic/newrelic-oss-cli |
| 72 | +
|
| 73 | + - name: Generate Third Party Notices |
| 74 | + id: generate-notices |
| 75 | + run: | |
| 76 | + if [ ! -f "third_party_manifest.json" ]; then |
| 77 | + echo "::error::third_party_manifest.json is missing. Must generate using the newrelic-oss-cli." |
| 78 | + exit 1 |
| 79 | + fi |
| 80 | +
|
| 81 | + # latest commit |
| 82 | + LATEST_COMMIT=$(git rev-parse HEAD) |
| 83 | +
|
| 84 | + # latest commit where package.json was changed |
| 85 | + LAST_CHANGED_COMMIT=$(git log -1 --format=format:%H --full-diff package.json) |
| 86 | +
|
| 87 | + if [ $LAST_CHANGED_COMMIT = $LATEST_COMMIT ]; then |
| 88 | + git config user.email "${{ env.THIRD_PARTY_GIT_AUTHOR_EMAIL }}" |
| 89 | + git config user.name "${{ env.THIRD_PARTY_GIT_AUTHOR_NAME }}" |
| 90 | +
|
| 91 | + oss third-party manifest |
| 92 | + oss third-party notices |
| 93 | +
|
| 94 | + git add third_party_manifest.json |
| 95 | + git add THIRD_PARTY_NOTICES.md |
| 96 | +
|
| 97 | + git commit -m 'chore: update third-party manifest and notices [skip-cd]' |
| 98 | + echo "::set-output name=commit::true" |
| 99 | + else |
| 100 | + echo "No change in package.json, not regenerating third-party notices" |
| 101 | + fi |
38 | 102 |
|
39 | 103 | job-generate-release:
|
40 | 104 | runs-on: ubuntu-latest
|
41 | 105 | needs: job-checkout-and-build
|
42 | 106 | steps:
|
| 107 | + # Checkout ref: develop because previous job potentially committed third_party_notices and |
| 108 | + # we need to checkout latest to pick up that commit |
43 | 109 | - name: Checkout repo
|
44 | 110 | uses: actions/checkout@v2
|
| 111 | + with: |
| 112 | + ref: master |
45 | 113 |
|
46 | 114 | - name: Setup Node.js
|
47 | 115 | uses: actions/setup-node@v1
|
|
61 | 129 |
|
62 | 130 | - name: Install dependencies
|
63 | 131 | run: npm ci
|
64 |
| - # Don't actually run release yet |
65 |
| - # - name: Release |
66 |
| - # env: |
67 |
| - # GITHUB_TOKEN: ${{ secrets.OPENSOURCE_BOT_TOKEN }} |
68 |
| - # run: npx semantic-release |
| 132 | + |
| 133 | + - name: Release |
| 134 | + env: |
| 135 | + GITHUB_TOKEN: ${{ secrets.OPENSOURCE_BOT_TOKEN }} |
| 136 | + run: npx semantic-release |
0 commit comments