-
Notifications
You must be signed in to change notification settings - Fork 60
155 lines (137 loc) · 4.98 KB
/
Release.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Release
on:
pull_request:
branches:
- master
types:
- closed
- labeled
- opened
- reopened
- synchronize
- unlabeled
concurrency: release
jobs:
release:
name: Release
runs-on: ubuntu-22.04
permissions:
actions: write
checks: write
contents: write
deployments: write
issues: write
packages: write
pull-requests: write
repository-projects: write
security-events: write
statuses: write
timeout-minutes: 10
container: ros:humble
outputs:
new_version: ${{ steps.new_version.outputs.new_version }}
steps:
- name: Restore branch
uses: levonet/action-restore-branch@master
- name: Install bloom
run: apt update && apt install -y python3-bloom git curl
- name: Checkout
uses: actions/checkout@v4
with:
ref: master
fetch-depth: 0
fetch-tags: true
- name: Setup git
run: |
git config --global user.name "Release Bot"
git config --global user.email "action@github.com"
git config --global --add safe.directory /__w/scenario_simulator_v2/scenario_simulator_v2
git config --global credential.helper ${{ secrets.GITHUB_TOKEN }}
git config pull.rebase false
- name: Get old version
id: old_version
run: |
echo "old_version=$(catkin_package_version)" >> $GITHUB_OUTPUT
- name: Merge branch
run: git pull origin ${{ github.head_ref }}
- name: Bump patch version
if: (contains(github.event.pull_request.labels.*.name, 'bump patch'))
run: |
catkin_generate_changelog -y
catkin_tag_changelog --bump patch
catkin_package_version --bump patch
- name: Bump minor version
if: (contains(github.event.pull_request.labels.*.name, 'bump minor'))
run: |
catkin_generate_changelog -y
catkin_tag_changelog --bump minor
catkin_package_version --bump minor
- name: Bump major version
if: (contains(github.event.pull_request.labels.*.name, 'bump major'))
run: |
catkin_generate_changelog -y
catkin_tag_changelog --bump major
catkin_package_version --bump major
- name: Get new version
id: new_version
run: |
echo "new_version=$(catkin_package_version)" >> $GITHUB_OUTPUT
- name: Commit changes
if: github.event.pull_request.merged == true
run: |
git add .
git commit -m "Bump version of scenario_simulator_v2 from version ${{ steps.old_version.outputs.old_version }} to version ${{ steps.new_version.outputs.new_version }}"
- name: Pushing to the protected branch 'master'
if: github.event.pull_request.merged == true
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.BLOOM_GITHUB_TOKEN }}
branch: master
force: true
- name: Get linked issues
id: linked_issues
uses: hossainemruz/linked-issues@main
with:
pr_url: ${{github.event.pull_request.html_url}}
format: ExternalIssueRef
continue-on-error: true
- name: Update release description
env:
PULL_REQUEST_BODY: ${{ github.event.pull_request.body }}
run: |
echo "$PULL_REQUEST_BODY" >> release_description.txt
echo "" >> release_description.txt
echo "# Related Issues " >> release_description.txt
echo "${{ steps.linked_issues.outputs.issues }}" >> release_description.txt
- name: Get release description
id: get_release_description
uses: mathiasvr/command-output@v2.0.0
with:
run: cat release_description.txt
- name: Create a GitHub release
if: github.event.pull_request.merged == true
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.new_version.outputs.new_version }}
name: ${{ steps.new_version.outputs.new_version }}
body: ${{ steps.get_release_description.outputs.stdout }}
- name: Delete branch if merged
if: github.event.pull_request.merged == true
uses: actions/github-script@v5
with:
script: |
github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `heads/${context.payload.pull_request.head.ref}`,
})
- name: Kick docker build action
if: github.event.pull_request.merged == true
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token ${{ secrets.BLOOM_GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/tier4/scenario_simulator_v2/actions/workflows/Docker.yaml/dispatches \
-d '{"ref":"master","inputs":{"version":"${{ steps.new_version.outputs.new_version }}"}}'