forked from elastic/elastic-otel-java
-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (111 loc) · 3.85 KB
/
pre-post-release.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
119
120
121
122
123
124
125
126
127
128
---
name: Pre/Post Release
on:
workflow_call:
inputs:
ref:
description: 'Branch or tag ref to run the workflow on'
type: string
required: true
default: 'main'
version:
description: 'The version to release (e.g. 1.2.3). This workflow will automatically perform the required version bumps'
type: string
required: true
phase:
description: 'Pre or post release phase'
type: string # valid values are 'pre' or 'post'
required: true
pr_title:
description: 'pull-request title'
type: string
required: true
pr_body:
description: 'pull-request body'
type: string
required: true
changelog:
description: 'The changelog to prepend to CHANGELOG.md without heading'
type: string
required: false
default: ''
env:
RELEASE_VERSION: ${{ inputs.version }}
BRANCH_NAME: ${{ inputs.phase }}-release-v${{ inputs.version }}
permissions:
contents: read
jobs:
validate-tag:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate release tag does not exist in repo
uses: ./.github/workflows/validate-tag
with:
tag: v${{ env.RELEASE_VERSION }}
create-pr:
name: "Bump versions and create PR"
runs-on: ubuntu-latest
needs:
- validate-tag
steps:
- name: Get token
id: get_token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
with:
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
permissions: >-
{
"contents": "write",
"pull_requests": "write"
}
repositories: >-
["elastic-otel-java"]
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
token: ${{ steps.get_token.outputs.token }}
- uses: elastic/oblt-actions/git/setup@v1
with:
github-token: ${{ steps.get_token.outputs.token }}
- name: Create the release tag (post phase)
if: inputs.phase == 'post'
run: |
git tag "v${{ env.RELEASE_VERSION }}"
git push origin "v${{ env.RELEASE_VERSION }}"
- name: Create a ${{ inputs.phase }} release branch
run: git checkout -b ${{ env.BRANCH_NAME }}
- name: Set release version (pre release)
if: inputs.phase == 'pre'
uses: ./.github/workflows/gradle-goal
with:
command: ./gradlew -q setVersion -PnewVersion=${{ env.RELEASE_VERSION }}
- name: Set next snapshot version (post release)
if: inputs.phase == 'post'
uses: ./.github/workflows/gradle-goal
with:
command: ./gradlew -q setNextVersion
- name: Insert notes into cumulative changelog (post release)
if: inputs.phase == 'post'
run: |
echo "# ${{ inputs.version }} - $(date +'%d/%m/%Y')" > tmpchangelog
echo '${{ inputs.changelog }}' >> tmpchangelog
cat CHANGELOG.md >> tmpchangelog
mv tmpchangelog CHANGELOG.md
- name: Clear next release changelog (post release)
if: inputs.phase == 'post'
run: |
echo '' > CHANGELOG.next-release.md
- name: Push the ${{ inputs.phase }} release branch
run: |
git add --all
git commit -m "${{ inputs.phase }} release: elastic-otel-java v${{ env.RELEASE_VERSION }}"
git push origin ${{ env.BRANCH_NAME }}
- name: Create the ${{ inputs.phase }} release PR
run: gh pr create --title="${{ inputs.pr_title }}" --base main --head ${{ env.BRANCH_NAME }} -b "${{ inputs.pr_body }}"
env:
GH_TOKEN: ${{ steps.get_token.outputs.token }}