Skip to content
This repository was archived by the owner on Apr 7, 2025. It is now read-only.

Commit 83d095d

Browse files
committed
fix: generate release off develop branch and add third-party manifest/notices updates
1 parent 53b9b01 commit 83d095d

File tree

1 file changed

+74
-6
lines changed

1 file changed

+74
-6
lines changed

.github/workflows/release.yml

+74-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: CI
33
on:
44
push:
55
branches:
6-
- master
6+
- develop
77
repository_dispatch:
88
types: [semantic-release]
99

@@ -35,13 +35,81 @@ jobs:
3535

3636
- name: Gatsby Build
3737
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
38102
39103
job-generate-release:
40104
runs-on: ubuntu-latest
41105
needs: job-checkout-and-build
42106
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
43109
- name: Checkout repo
44110
uses: actions/checkout@v2
111+
with:
112+
ref: master
45113

46114
- name: Setup Node.js
47115
uses: actions/setup-node@v1
@@ -61,8 +129,8 @@ jobs:
61129
62130
- name: Install dependencies
63131
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

Comments
 (0)