-
Notifications
You must be signed in to change notification settings - Fork 120
101 lines (88 loc) · 3.83 KB
/
Copy pathrelease-post.yml
File metadata and controls
101 lines (88 loc) · 3.83 KB
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
name: Post Release
on:
pull_request:
types: [closed]
branches: [develop]
workflow_dispatch:
inputs:
release_ref:
description: 'Git ref (branch or commit SHA) to sync to master, e.g. release-0.56.0'
required: true
type: string
jobs:
post-release:
# Only run when a release-* branch is merged into develop, or manually triggered
if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release-'))
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Generate App token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: ${{ secrets.VECTORDOTDEV_BOT_APP_ID }}
private-key: ${{ secrets.VECTORDOTDEV_BOT_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.release_ref || 'develop' }}
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- name: Configure Git
run: |
git config user.name "vectordotdev-bot[bot]"
git config user.email "${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com"
- name: Install helm-docs
uses: envoy/install-helm-docs@05313083ef2cfaea27c4c3d7cb725242d22ea88b # v1.0.0
with:
version: 1.11.0
- name: Merge develop into master
run: |
CHART_VERSION=$(grep '^version:' charts/vector/Chart.yaml | sed 's/version: "\(.*\)"/\1/')
SYNC_BRANCH="release-sync/${CHART_VERSION}"
git checkout -b "$SYNC_BRANCH"
git push origin "$SYNC_BRANCH"
PR_URL=$(gh pr create \
--title "chore(releasing): Merge develop into master for ${CHART_VERSION}" \
--body "Post release: sync master with the release changes from develop for ${CHART_VERSION}." \
--base master \
--head "$SYNC_BRANCH")
gh pr merge "$PR_URL" --auto --merge
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Read and bump chart version
id: version
run: |
CHART_VERSION=$(grep '^version:' charts/vector/Chart.yaml | sed 's/version: "\(.*\)"/\1/')
MAJOR=$(echo "$CHART_VERSION" | cut -d. -f1)
MINOR=$(echo "$CHART_VERSION" | cut -d. -f2)
NEW_VERSION="${MAJOR}.$((MINOR + 1)).0"
echo "current=$CHART_VERSION" >> "$GITHUB_OUTPUT"
echo "next=$NEW_VERSION" >> "$GITHUB_OUTPUT"
- name: Create version bump branch
run: |
git switch develop
git checkout -b "bump-chart-version-${{ steps.version.outputs.next }}"
- name: Bump chart version
run: |
sed -i 's/version: "${{ steps.version.outputs.current }}"/version: "${{ steps.version.outputs.next }}"/' \
charts/vector/Chart.yaml
- name: Update Helm docs
run: helm-docs
- name: Commit and push
run: |
git add .
git commit -m "chore(releasing): Bump chart version to ${{ steps.version.outputs.next }}"
git push -u origin "bump-chart-version-${{ steps.version.outputs.next }}"
- name: Create and auto-merge PR
run: |
gh pr create \
--title "chore(releasing): Bump chart version to ${{ steps.version.outputs.next }}" \
--body "Post release version bump." \
--base develop \
--head "bump-chart-version-${{ steps.version.outputs.next }}"
gh pr merge "bump-chart-version-${{ steps.version.outputs.next }}" --auto --squash
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}