-
Notifications
You must be signed in to change notification settings - Fork 42
148 lines (141 loc) · 5.66 KB
/
release_management.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Release Management
on:
issue_comment:
types: [ created ]
pull_request:
branches: [ main ]
push:
branches: [ main ]
env:
GITHUB_ACTIONS_BOT_NAME: "github-actions[bot]"
GITHUB_ACTIONS_BOT_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com"
jobs:
prepare-release-command:
name: Process /prepare-release cmds
if: ${{ github.event.issue.pull_request }}
runs-on: ubuntu-latest
outputs:
command: ${{ steps.extract-command.outputs.command }}
steps:
- name: Match /prepare-release [major|minor|patch|xx.xx.xx] commands
id: extract-command
shell: bash
env:
COMMENT: ${{ github.event.comment.body }}
run: |
echo Processing comment "$COMMENT"
version=$(echo $COMMENT | sed -nE "s/^ *\/prepare-release +([0-9]+.[0-9]+.[0-9]+) *$/\1/p")
if [ -n "${version}" ]; then
echo command=--version ${version} >> $GITHUB_OUTPUT
exit
fi
bump=$(echo $COMMENT | sed -nE "s/^ *\/prepare-release +(major|minor|patch) *$/\1/p")
if [ -n "${bump}" ]; then
echo command=--bump ${bump} >> $GITHUB_OUTPUT
exit
fi
echo command="" >> $GITHUB_OUTPUT
prepare-release:
name: Prepare release
needs: [ prepare-release-command ]
if: ${{ needs.prepare-release-command.outputs.command }}
runs-on: [ self-hosted, vwire ]
container:
image: ros:noetic-ros-base-focal
steps:
- name: React to the comment to show it's being processed
uses: actions/github-script@v6
with:
script: |
github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: ${{ github.event.comment.id }},
content: 'rocket',
});
- name: Install dependencies
shell: bash
run: |
type -p curl >/dev/null || (apt-get update && apt-get install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
apt-get update
apt-get install -q -y --no-install-recommends git python3-catkin-tools gh
- name: Fetch the repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # To everything, instead of only the last commit
token: ${{ secrets.PAT }}
- name: Checkout PR branch
run: gh pr checkout ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Bring branch up to date with main
run: |
git config user.name ${GITHUB_ACTIONS_BOT_NAME}
git config user.email ${GITHUB_ACTIONS_BOT_EMAIL}
git merge origin/main
- name: Bump catkin package version numbers
shell: bash
run: python3 tooling/packages/wavemap_utils/scripts/ci_prepare_release.py --non-interactive ${{ needs.prepare-release-command.outputs.command }}
- name: Push to GitHub
run: git push
# - name: Post release note preview as PR comment
# uses: actions/github-script@v6
# with:
# script: |
# github.rest.issues.createComment({
# owner: context.repo.owner,
# repo: context.repo.repo,
# issue_number: context.issue.number,
# body: 'Preview of release notes will be added here.'
# })
ready-for-release:
name: Check version is incremental
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout the current branch
uses: actions/checkout@v3
- name: Compare local and main version numbers
shell: bash
run: |
version_main=$(curl -s https://raw.githubusercontent.com/ethz-asl/wavemap/main/libraries/wavemap/package.xml | sed -nE "s/.*<version>(.*)<\/version>.*/\1/p")
version_local=$(sed -nE "s/.*<version>(.*)<\/version>.*/\1/p" libraries/wavemap/package.xml)
if dpkg --compare-versions $version_main "lt" $version_local; then
echo "Local version ($version_local) is ahead of origin main ($version_main)"
exit 0
else
echo "Local version ($version_local) lags origin main ($version_main)"
exit 1
fi
tag-release:
name: Tag pushes to main
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- name: Checkout the current branch
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
- name: Detect version
id: detect-version
shell: bash
run: echo "version=$(sed -nE "s/.*<version>(.*)<\/version>.*/\1/p" libraries/wavemap/package.xml)" >> $GITHUB_OUTPUT
- name: Push tag
env:
TAG: v${{ steps.detect-version.outputs.version }}
shell: bash
run: |
if git show-ref --tags --verify --quiet "refs/tags/${TAG}"; then
echo "Tag ${TAG} already exists. Doing nothing."
else
echo "Creating and pushing tag ${TAG}."
git config user.name ${GITHUB_ACTIONS_BOT_NAME}
git config user.email ${GITHUB_ACTIONS_BOT_EMAIL}
git tag -a -m "Release ${TAG}" ${TAG}
git push origin ${TAG}
fi