-
Notifications
You must be signed in to change notification settings - Fork 902
118 lines (97 loc) · 4.22 KB
/
package-bump-pr.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Create package bump PR
concurrency:
group: create-package-bump-pr
cancel-in-progress: true
on:
push:
branches:
- 'master'
tags:
- '@spinnaker/*'
env:
NODE_VERSION: 14.21.3
jobs:
build:
# Only run this on repositories in the 'spinnaker' org, not on forks.
if: startsWith(github.repository, 'spinnaker/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: master
- name: git - configure commit user
run: |
git config user.name spinnakerbot
git config user.email [email protected]
git checkout master
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: yarn - get cache dir
id: yarn-cache
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: yarn - Install Dependencies
run: yarn --frozen-lockfile
- name: lerna - Bump packages
id: lerna_bump
run: |
scripts/gha_bump_packages.sh
env:
COMMIT_SHA: ${{ github.sha }}
- name: gha - get bumped packages
id: bumps
run: |
scripts/gha_output_bumped_packages.sh
scripts/gha_output_changelog.sh
env:
PACKAGE_BUMP_COMMIT_HASH: ${{ steps.lerna_bump.outputs.packageBumpCommitHash }}
PEERDEP_BUMP_COMMIT_HASH: ${{ steps.lerna_bump.outputs.peerdepBumpCommitHash }}
- name: Create Pull Request
id: createpullrequest
uses: peter-evans/create-pull-request@v7
with:
token: '${{ secrets.SPINNAKERBOT_PERSONAL_ACCESS_TOKEN }}'
commit-message: 'chore(package): Publish ${{ steps.bumps.outputs.bumps }}'
title: 'Publish packages to NPM'
labels: publish
body: |
### This PR bumps the version(s) of all Deck package(s) that have unpublished changes.
${{ steps.bumps.outputs.changelog }}
---
This PR bumps each package to the next semver version (patch/minor/major) based on the commit messages of unpublished changes using [Conventional Commits](https://conventionalcommits.org).
- fix: patch release
- feat: minor release
- BREAKING CHANGE: major release
It also updates dependency versions in other packages in the monorepo which depend on the bumped package(s).
After this PR is merged, Github Actions will publish any bumped packages to the NPM registry.
_Auto-generated by `.github/workflows/package-bump-pr.yml`_
- name: Close package bump due to no changes
if: ${{ steps.lerna_bump.outputs.packageBumpCommitHash == '' && steps.createpullrequest.outputs.pull-request-number != '' }}
uses: actions/[email protected]
with:
github-token: '${{ secrets.SPINNAKERBOT_PERSONAL_ACCESS_TOKEN }}'
script: |
const { owner, repo } = context.repo;
const pull_number = ${{ steps.createpullrequest.outputs.pull-request-number }};
await github.rest.pulls.update({ owner, repo, pull_number, state: 'closed' });
- name: Approve package bump
if: ${{ steps.lerna_bump.outputs.packageBumpCommitHash != '' && steps.createpullrequest.outputs.pull-request-number != '' }}
uses: actions/[email protected]
with:
github-token: '${{ secrets.SPINNAKERBOT_TOKEN }}'
script: |
const { owner, repo } = context.repo;
const pull_number = ${{ steps.createpullrequest.outputs.pull-request-number }};
const users = ['spinnakerbot', 'spinnakerbot2'];
const reviews = await github.rest.pulls.listReviews({ owner, repo, pull_number });
const approved = reviews.data.some((review) => users.includes(review.user.login) && review.state == 'APPROVED');
if (!approved) {
await github.rest.pulls.createReview({ owner, repo, pull_number, event: 'APPROVE' });
}