forked from spinnaker/deck
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (93 loc) · 4.07 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
name: Create package bump PR
concurrency:
group: create-package-bump-pr
cancel-in-progress: true
on:
push:
branches:
- 'master'
tags:
- '@spinnaker/*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
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@v1
name: node - setup
with:
node-version: ${{ env.NODE_VERSION }}
- name: yarn - get cache dir
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
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
run: |
npx lerna version --yes --no-push --conventional-commits
if [[ $(git rev-list --count @{u}..HEAD) -ne 0 ]] ; then
# Fix the lerna commit message to also use conventional commits
git commit --amend -m "$(git log -1 --pretty=%B | sed -e 's/^Publish/chore(publish): publish packages/')"
fi
- name: gha - get bumped packages
id: bumps
run: |
scripts/gha_output_bumped_packages.sh
scripts/gha_output_changelog.sh
- name: Create Pull Request
id: createpullrequest
# if: ${{ steps.bumps.outputs.bumps != '' }}
uses: peter-evans/create-pull-request@v3
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.bumps.outputs.bumps == '' }}
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.pulls.update({ owner, repo, pull_number, state: 'closed' });
- name: Approve package bump
if: ${{ steps.bumps.outputs.bumps != '' && 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.pulls.listReviews({ owner, repo, pull_number });
const approved = reviews.data.some((review) => users.includes(review.user.login) && review.state == 'APPROVED');
if (!approved) {
await github.pulls.createReview({ owner, repo, pull_number, event: 'APPROVE' });
}