-
Notifications
You must be signed in to change notification settings - Fork 2
141 lines (127 loc) · 5.77 KB
/
bump.yaml
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Bump
on:
workflow_call:
inputs:
konfig_yaml_dir:
description: 'Path to directory which contains konfig.yaml'
type: string
required: true
default: '.'
jobs:
bump:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: true
- name: Detect changeset files
id: detect-changesets
uses: konfig-dev/automation/.github/actions/private/detect-changesets@main
with:
konfig_yaml_dir: ${{ inputs.konfig_yaml_dir }}
- name: Install konfig
if: steps.detect-changesets.outputs.has_changesets == 'true'
run: npm install -g konfig-cli
- name: Detect SDK submodules
if: steps.detect-changesets.outputs.has_changesets == 'true'
id: sdk-submodules
uses: konfig-dev/automation/.github/actions/private/detect-sdk-submodules@main
with:
konfig_yaml_dir: ${{ inputs.konfig_yaml_dir }}
- name: Set git config
if: steps.detect-changesets.outputs.has_changesets == 'true'
run: |
git config --global user.email "[email protected]"
git config --global user.name "konfig-publisher"
- name: Update submodule references
if: >
steps.detect-changesets.outputs.has_changesets == 'true' &&
steps.sdk-submodules.outputs.dirs != ''
uses: konfig-dev/automation/.github/actions/private/sync-submodules@main
with:
konfig_yaml_dir: ${{ inputs.konfig_yaml_dir }}
sdk_submodule_dirs: ${{ steps.sdk-submodules.outputs.dirs }}
- name: Get version bump branch name
id: branch-name
if: steps.detect-changesets.outputs.has_changesets == 'true'
uses: konfig-dev/automation/.github/actions/private/get-branch-name@main
with:
konfig_yaml_dir: ${{ inputs.konfig_yaml_dir }}
- name: Bump SDK versions
if: steps.detect-changesets.outputs.has_changesets == 'true'
run: konfig version
working-directory: ${{ inputs.konfig_yaml_dir }}
- name: Regenerate SDKs
if: steps.detect-changesets.outputs.has_changesets == 'true'
run: konfig generate
working-directory: ${{ inputs.konfig_yaml_dir }}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Push SDK submodules to PR
if: >
steps.detect-changesets.outputs.has_changesets == 'true' &&
steps.sdk-submodules.outputs.dirs != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
KONFIG_API_KEY: ${{ secrets.KONFIG_API_KEY }}
uses: konfig-dev/automation/.github/actions/private/push-submodules-to-pr@main
with:
konfig_yaml_dir: ${{ inputs.konfig_yaml_dir }}
sdk_submodule_dirs: ${{ steps.sdk-submodules.outputs.dirs }}
submodule_deploy_keys: |
${{ secrets.SUBMODULE_DEPLOY_KEY_PYTHON }}
${{ secrets.SUBMODULE_DEPLOY_KEY_TYPESCRIPT }}
${{ secrets.SUBMODULE_DEPLOY_KEY_JAVA }}
${{ secrets.SUBMODULE_DEPLOY_KEY_CSHARP }}
${{ secrets.SUBMODULE_DEPLOY_KEY_GO }}
${{ secrets.SUBMODULE_DEPLOY_KEY_PHP }}
${{ secrets.SUBMODULE_DEPLOY_KEY_PHP7 }}
${{ secrets.SUBMODULE_DEPLOY_KEY_RUBY }}
${{ secrets.SUBMODULE_DEPLOY_KEY_SWIFT }}
head: ${{ steps.branch-name.outputs.branch_name }}
commit_msg: "Version Bump SDKs"
pr_title: "Version Bump SDKs"
pr_body: "Do not manually merge this PR. It will be merged automatically once the top-level PR is merged."
force: "true" # force push because we only want to bump version once per PR
# Capturing the verison bump PR submodule SHAs in the top-level PR does not matter
# because merging the submodule's version bump PRs creates a different SHA anyways
# They will be updated by the publishing process once the top-level version bump PR is merged
- name: Commit and push (top-level repo)
if: steps.detect-changesets.outputs.has_changesets == 'true'
working-directory: ${{ inputs.konfig_yaml_dir }}
env:
KONFIG_API_KEY: ${{ secrets.KONFIG_API_KEY }}
run: |
git add -A
git commit -m "Version Bump SDKs"
# force push because we only want to bump version once per PR
git push origin HEAD:refs/heads/${{ steps.branch-name.outputs.branch_name }} --force
repo=$(echo "${{ github.repository }}" | cut -d '/' -f 2)
konfig pr-create \
--head ${{ steps.branch-name.outputs.branch_name }} \
--base ${{ github.ref_name }} \
--owner ${{ github.repository_owner }} \
--repo $repo \
--title "Version Bump SDKs" \
--body "Version Bumps SDKs" # TODO: this should be replaced by a changelog
- name: Check if automatic merging for bump PR is disabled
if: steps.detect-changesets.outputs.has_changesets == 'true'
id: check-merge-disabled
uses: mikefarah/[email protected]
with:
cmd: yq '.doNotAutoMergeBumpPr' ${{ inputs.konfig_yaml_dir }}/konfig.yaml
# Submodule PRs are merged automatically in the subsequent triggered workflow
- name: Merge Top-Level Version Bump PR
if: >
steps.detect-changesets.outputs.has_changesets == 'true' &&
steps.check-merge-disabled.outputs.result != 'true'
env:
KONFIG_API_KEY: ${{ secrets.KONFIG_API_KEY }}
run: |
repo=$(echo "${{ github.repository }}" | cut -d '/' -f 2)
konfig pr-merge \
--head ${{ steps.branch-name.outputs.branch_name }} \
--base ${{ github.ref_name }} \
--owner ${{ github.repository_owner }} \
--repo $repo