-
Notifications
You must be signed in to change notification settings - Fork 49
93 lines (79 loc) · 2.89 KB
/
tag-new-version.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
# -*- mode: yaml -*-
name: Tag new version
on:
push:
branches:
- master
jobs:
bump-and-tag:
runs-on: ubuntu-latest
steps:
- name: Parse commit message for bump type
run: |
if ${{ contains(github.event.head_commit.message, '[bump patch]') || contains(github.event.head_commit.message, '[ci build]') }}; then
echo "bump=patch" >> $GITHUB_ENV
elif ${{ contains(github.event.head_commit.message, '[bump minor]') }}; then
echo "bump=minor" >> $GITHUB_ENV
elif ${{ contains(github.event.head_commit.message, '[bump major]') }}; then
echo "bump=major" >> $GITHUB_ENV
fi
- name: Checkout eman2
if: ${{ env.bump }}
uses: actions/checkout@v2
- name: Set up Git user
if: ${{ env.bump }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "eman-bot"
- name: Bump and tag new version
if: ${{ env.bump }}
run: |
git fetch --tags
version=$(git tag -l 'v*' --sort=-v:refname | head -n 1)
if [[ "$version" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
patch="${BASH_REMATCH[3]}"
fi
case "${{ env.bump }}" in
major)
major=$((major + 1))
minor=0
patch=0
;;
minor)
minor=$((minor + 1))
patch=0
;;
patch)
patch=$((patch + 1))
;;
*)
echo "Unknown bump type: ${{ env.bump }}"
exit 1
;;
esac
new_version="${major}.${minor}.${patch}"
echo "new_version=${new_version}" >> $GITHUB_ENV
echo "Current version: ${version}"
echo "Requested bump : ${{ env.bump }}"
echo "New version : ${new_version}"
sed -i "s/VERSION\s*[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*/VERSION ${new_version}/" CMakeLists.txt
git add CMakeLists.txt
git commit -m v${new_version}
git tag -f v${new_version}
git push origin ${{ github.ref }} v${new_version}
- name: Checkout eman-feedstock
if: ${{ env.bump }}
uses: actions/checkout@v2
with:
repository: cryoem/eman-feedstock
token: ${{ secrets.EMAN_DEV_TOKEN }}
- name: Update version in eman-feedstock
if: ${{ env.bump }}
run: |
sed -i 's/set\s*version\s*=\s*"[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"/set version = "${{ env.new_version }}"/' recipe/meta.yaml
sed -i 's/set\s*build\s*=\s*[0-9][0-9]*/set build = 0/' recipe/meta.yaml
git add recipe/meta.yaml
git commit -m v${{ env.new_version }}
git push origin master