-
Notifications
You must be signed in to change notification settings - Fork 55
91 lines (82 loc) · 2.88 KB
/
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
name: Release
permissions:
contents: write
pull-requests: write
env:
GIT_AUTHOR_EMAIL: "[email protected]"
GIT_AUTHOR_NAME: "ci.datadog-api-spec"
on:
pull_request:
types: [closed]
branches:
- master
jobs:
create_release:
name: Create release
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/')
steps:
- name: Get GitHub App token
id: get_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.PIPELINE_GITHUB_APP_ID }}
private_key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}
- name: Create release
uses: actions/github-script@v6
env:
RELEASE_BRANCH: ${{ github.head_ref }}
with:
github-token: ${{ steps.get_token.outputs.token }}
script: |
const tagName = `v${process.env.RELEASE_BRANCH.split("/")[1]}`;
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${tagName}`,
sha: context.payload.pull_request.merge_commit_sha,
});
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
generate_release_notes: true,
tag_name: tagName,
});
- uses: actions/checkout@v3
with:
token: ${{ steps.get_token.outputs.token }}
- name: Setup Git
run: |
git config user.name "${GIT_AUTHOR_NAME}"
git config user.email "${GIT_AUTHOR_EMAIL}"
- name: Bump version
run: |
git switch -c "${POST_RELEASE_BRANCH}"
VERSION=$(sed -n 's/const Version = "\(.*\)"/\1/p' version.go | awk -F. '{OFS="."; $NF+=1; print $0 "+dev"}')
sed -i 's/".*"/"'$VERSION'"/' version.go
git commit -a -m "Post release bump"
git push -f --set-upstream origin "${POST_RELEASE_BRANCH}"
env:
POST_RELEASE_BRANCH: post-${{ github.head_ref }}
- name: Create PR
uses: actions/github-script@v6
env:
POST_RELEASE_BRANCH: post-${{ github.head_ref }}
BASE: master
with:
github-token: ${{ steps.get_token.outputs.token }}
script: |
const { data: pr } = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
head: process.env.POST_RELEASE_BRANCH,
base: process.env.BASE,
title: "Post release",
body: "Bump to dev version",
});
await github.rest.issues.addLabels({
issue_number: pr.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["changelog/no-changelog"],
});